Design and implement new module asset directory structure and naming in A3
See original GitHub issueAs we punch ahead through a3, we’ve started talking through some of our well-established naming conventions, and want to surface the following two proposals for open discussion.
Pushing Assets to the Browser Automatically: Scenes vs Builds
The good news is that A3 pushes assets to the browser automatically if you put them in the right folder in any Apostrophe module. This is a nice win over A2, where you had to call pushAsset
for each one.
But, we’d like your input on how to name these folders.
We’ve considered both this:
// browser js for all users, example: widget player
lib/modules/articles-widgets/builds/everyone/player.js
// vue components to register for apostrophe admin UI
lib/modules/articles-widgets/builds/user/components/*.vue
And this:
// browser js for all users, example: widget player
lib/modules/articles-widgets/scenes/everyone/player.js
// vue components to register for apostrophe admin UI
lib/modules/articles-widgets/scenes/user/components/*.vue
We like the name “builds” because it’s clearly about building assets for the frontend.
We like the name “scenes” because it relates to Apostrophe’s internal concept of an asset “scene”. But, we’re thinking of renaming that concept “builds” altogether.
You’ll also note that the rules for /user
are a little different from /everyone
. Because Apostrophe’s admin UI is built on Vue, we provide a specific folder to automatically register Vue components from any module. We have other special folder names as well. /everyone
is different: any .js files directly in that folder simply get pushed all the time, as part of the bundle for site visitors or editors.
Your input is welcome!
Singular vs Plural: Singularizing our module names
For a long time now we have had plural names for modules that manage many instances of something. For instance, an “articles” module that extends pieces might manage thousands of articles, so we gave the module a plural name. It seemed like a good idea, but in practice it has caused a lot of confusion. When is a module singular, and when is it plural? If it takes more than a second to explain, it’s not really helping.
So even though we are very far along with 3.x and the change is a little bit challenging, we are looking at moving to strictly singular module names. Here are some examples of the change we’re talking about, as folder paths, so you can visualize it in the context of a project:
lib/modules/articles —> lib/modules/article
lib/modules/events —> lib/modules/event
lib/modules/apostrophe-pages —> lib/modules/@apostrophecms/page
lib/modules/articles-widgets -> lib/modules/article-widget
We think this will be less confusing in the long run, but we would love to get your input before we make this change.
A special case: there are a few modules in Apostrophe that are never actually “instantiated” (you don’t turn them on in app.js
, and we don’t turn them on in defaults.js
). These modules are “abstract base classes:” you extend them to make your own modules. For these, we already made the change to add -type
to the name:
lib/modules/apostrophe-pieces --> lib/modules/@apostrophecms/piece-type
lib/modules/apostrophe-widgets --> lib/modules/@apostrophecms/widget-type
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (14 by maintainers)
Top GitHub Comments
Cool, I think that could work out:
“Apostrophe’s APIs are totally RESTful out of the box. The URL of the API matches the name of the module so that our UI code can always find it. Note that our module names are singular, so the API URLs are singular too. Want the API to be available under an additional name, such as a collective or plural noun, or simply at some other URL than /api/v1/your-modulename? Set the restAlias option for the module, and both URLs will work.”
Is this a story everyone is comfortable telling?
On Tue, Jul 14, 2020 at 3:26 PM Greg van Brug notifications@github.com wrote:
–
THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER APOSTROPHECMS | apostrophecms.com | he/him/his
Love singular. Consistent with REST convention (even though it is not related). I have the habit of having singular folders names for my personal Apos projects.