Linked data Browser, primarily for use with linked_rails backends.
Also powers Argu.
Either use as part of Argu, or as a standalone browser;
npm install
oryarn
to install dependencies.- When using Libro standalone, create a .env file by copying
.env.template
. yarn run start
to start the hot reload enabled development build.- Visit http://localhost:3001/
Commit messages are automatically checked for compliance with conventional commits. Make sure that nodejs is available in the environment where modifying git commands (i.e. commit, rebase, etc) are executed.
yarn run start
run the development server.yarn run build
to create production builds, stored in/dist
.yarn run lint
to run the ES linter. See .eslintrc for the plugins and exceptions to the recommended set used.yarn run test
to run all tests.
Tests are placed in __tests__
folders and should end in .spec.ts(x)
.
Most of the actual runtime code of the app is divided into the various "modules".
- app - Code that runs in the browser
- components - React components needed to bootstrap Libro.
- helpers - Helpers for bootstrapping Libro.
- modules - Encapsulated modules of behaviour.
- ontology - Shared ontology definitions which don't fit into a particular module.
- routes - The different routes in Libro, almost always routes to
LinkedObject
. - translations - Stores translations. See the I18n chapter.
- bin - Binaries
- dist - Generated and managed by the build scripts. Here are the distribution files stored, they aren't necessarily public.
- tests - Helpers related to testing.
- webpack - Configuration for your favorite bundler.
Most of the code should be placed into the async
submodule, so it can be loaded on-demand.
- async - Code which is to be loaded asynchronously, via
Suspense
orimport()
- Contains the module structure (except for
async
).
- Contains the module structure (except for
- components - Plain React components and suspense loaders for async components.
- hooks - Custom React hooks.
- lib - Other code which can't be properly categorized into the other folders
- middleware - Link middlewares, use for processing custom actions.
- ontology - Files containing ontology related to the module.
- theme - Custom theme, only applicable to
App
modules. - topologies - Topology Provider components.
- index.ts - Default export should contain an array of all the topology IRIs this module defines.
- views - Link components which are registered in the store, mounted by Libro automatically via the
Resource
component. - index.ts - The module definition.
- dependencies.ts - A list of other modules the test suite of this module needs to run.
Libro uses the makeStyles hook from @material/styles
for styling.
These can plug into the theming system to enable runtime (server provided) theming options.
Themes and their settings can be found in the theme
folder of App
modules. Whenever writing
components be sure to use the appropriate theme variables if applicable.
Tests are written using jest and @testing-library/react. An enhanced version for views can be found in the test-utilities.
Test which render react components need to declare their environment as jsdom
Internationalization is done via react-intl.
Do not touch the en.json
and all *.json
files in /app/lang, they are autogenerated from source.
- Use the translation in code
- Run the
t10s:extract
script, take note of any warning or errors (esp. duplicates) - Add the key and translation to the other locales.
- Run the
t10s:compile
script - Commit
CAUTION: When deleting translations (e.g. removing a react-intl component), make sure to manually search/check and update the translations files to ensure consistency.
When a component isn't rendering as expected. So, your Link View / Property isn't showing. Check the following:
- Is the record in the store?
LRS.collectRecord("insert record_id")
to see the data if present.LRS.collectRecord($r.props.subject)
when having the Resource component selected in React Devtools component panel.
- Is the record being fetched?
- Check the
/bulk
requests in thenetwork
tab in your browser's debugger view. - The requested records are in the
payload
panel. - The retrieved records are in the
preview
orresponse
panel.
- Check the
- Check if your view is actually registered, i.e. is the component properly exported and included?
- Is the element present in the virtual DOM? Use the React debugging tools to find the component. Does it contain the Property components that you expect it to have?
- If there is an element, check its data by selecting the
Resource
element in the React debugging tools and executingdev.data
in the console.
If you want to preview data from the web:
- Run this in an apex Rails console:
Page.argu.update(allowed_external_sources: ['https://myexternaldomain.com'])
- Open the resource in libro using the
/org/resource?
endpoint:https://argu.localdev/argu/resource?iri=externalresource
- Chrome plugins: React Dev Tools, Redux Dev Tools