Portal and PortalService interfaces define the contract that all book source modules must implement in ReUCM.
Portal interface
ThePortal interface defines the basic metadata and properties of a book source.
Source: re_ucm_core/lib/models/portal/portal.dart:3-9
Properties
The base URL of the portal website (e.g.,
"https://author.today"). Used for URL matching and relative path resolution.The human-readable name of the portal (e.g.,
"Author.Today"). Displayed in the UI.A unique identifier for the portal (e.g.,
"at" for Author.Today). Used for portal registration and identification. Must be unique across all portals.The portal’s logo configuration, including the asset path and package name.
The service implementation that handles authentication, book fetching, and other portal-specific operations.
PortalLogo class
Source:re_ucm_core/lib/models/portal/portal.dart:11-16
The path to the logo asset file (e.g.,
"assets/logo.svg").The package name where the asset is located (e.g.,
"re_ucm_author_today"). Required for assets in portal packages.PortalService interface
ThePortalService interface defines the core functionality for interacting with a book source.
Source: re_ucm_core/lib/models/portal/portal_service.dart:3-17
Methods
Deserializes portal settings from JSON. Returns a default settings object if
json is null.Parameters:json: The JSON data to deserialize, or null for default settings
TBuilds the UI schema for the portal’s settings page. Returns a list of setting items that define the authentication UI and configuration options.Parameters:
settings: The current portal settings
PortalSettingItem objects that define the settings UIAvailable setting item types:PortalSettingSectionTitle- Section headerPortalSettingWebAuthButton- Web-based authentication buttonPortalSettingTextField- Text input fieldPortalSettingActionButton- Action button (e.g., logout)PortalSettingStateSwitcher- Conditional UI based on statePortalSettingGroup- Group of settings
Checks if the user is authorized with the portal.Parameters:
settings: The current portal settings
true if the user is authenticated, false otherwiseExtracts the book ID from a portal URL.Parameters:
url: The book URL (e.g.,https://author.today/work/12345)
"12345")Throws: ArgumentError if the URL is invalid or doesn’t match the portal’s formatOptional callback that can be invoked when settings need to be updated (e.g., after token refresh). The app will persist the updated settings automatically.Example:
Fetches book metadata from the portal.Parameters:
id: The book IDsettings: The current portal settings (for authentication)
Book object containing metadata (title, authors, chapters list, cover, etc.)Throws: Exception if the book is not found or authentication failsFetches all chapters of a book from the portal.Parameters:
id: The book IDsettings: The current portal settings (for authentication)
Chapter objects with titles and contentThrows: Exception if the chapters cannot be fetched or authentication failsImplementation example
Here’s how the Author.Today portal implements these interfaces: Source:re_ucm_author_today/lib/re_ucm_author_today.dart
re_ucm_author_today/lib/author_today_service.dart:11-17
Settings schema example
Here’s how Author.Today builds its settings UI schema: Source:re_ucm_author_today/lib/author_today_service.dart:28-74
- Shows a “Sign out” button when authenticated
- Shows web auth and token auth options when not authenticated
- Displays the user ID when logged in
Next steps
- Learn how to create a new portal
- Explore the portal system architecture
- Review the Book and Chapter model documentation