-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Database layer for the CMS objects #3908
Conversation
@LukeTowers Having this in the framework layer seems like a wonderful alternative to patching the pages plugin. 👌 I'm available to test the progression of this PR if you need me. For reference, this plugin approached the same idea I believe (adding tables and intercepting saves towards DB instead of filesystem with the ability of pointing back to FS). https://octobercms.com/plugin/axmit-storage Since you're at the CMS/Framework level you can definitely make this a lot more "invisible", which is very nice. |
Properly remove deleted paths from results returned by AutoDatasource->select() and utilize the cache exclusively when only selecting the fileName column preventing calls to the source datasources.
This comment has been minimized.
This comment has been minimized.
@seanthepottingshed @ayumihamsaki @w20k @teranode Would you guys be willing to help test this out as it's worked on? |
@LukeTowers, count me in! |
@LukeTowers I would absolutely love to! |
@w20k @seanthepottingshed feel free to get started. You'll need octobercms/library#356 as well, and I don't think RainLab.Pages works right now but everything else in the CMS section should work fine (excluding the items that I haven't checked off the todo list yet) |
Excellent, I will have a play with it this week. |
Thanks, I'll tag along and start testing on this week. Busy month all of a sudden. |
This comment has been minimized.
This comment has been minimized.
I haven't forgotten about this - big site launch this week which I've been helping my colleague with, will have a play thereafter. |
I haven't forgotten this either, i've just been preoccupied with my own project since i just started getting into Vue. Just ping me if you need me to do something. |
…cause both the original and new records to display
This comment has been minimized.
This comment has been minimized.
…tually implemented the logic for them yet, just added the initial shells / UI for them.
@bennothommo awesome! Merged one of your suggestions, clarified the other. Could you test it with the StaticPages plugin and let me know if you can replicate / fix @w20k's reported issue here: #3908 (comment) |
Static Pages is working well as well. Just suggested a fix for the issue spotted by @w20k above. |
Credit to @bennothommo. Fixes #3908 (comment) Co-Authored-By: LukeTowers <github@luketowers.ca>
Awesome! @w20k could you run another test on this? @bennothommo Do you have any input on the theme:sync command? I think where I left off I was struggling to figure out the best way to determine what datasource paths should be mirrored when no explicit paths are provided given that the available datasource paths returned by a datasource (specifically the filesystem) could include binary files that don't necessarily have a Halycon object to handle them, in which case we would want to ignore them. However, I'm stuck on what would be the best way of determining that and filtering out the files that don't have Halcyon classes to reference them. I don't really want the command to be syncing binary asset files into the DB after all 😉 |
@LukeTowers Would it be a case where you can make some presumptions about the scope of paths that should be checked and synchronised? Given the conventions already established with the CMS and Static Page objects in themes, you would realistically only need to sync the following folders (and any sub-folders and files) in a theme:
With each of these folders, you would just need to limit the files scanned and synchronised to files with the Is there any examples of content that exist outside of these folders that you would also want to be synchronised? |
@bennothommo I've been thinking about having an event that allows you to include paths / extensions to be listened to. Core shouldn't know about static-pages, and default extensions could be |
@LukeTowers Ah yeah, that could work, maybe as a list of globs to match. For example:
|
@bennothommo good idea, and then the event can process that as default input allowing it to be added to or removed from. Do you think you could take a stab at implementing that on this branch? |
@LukeTowers sure thing, will try have a crack at it in the next day or 2. |
@LukeTowers what was your main concern(s) in regards to the code you already have implemented that retrieves and filters the source paths? Looking over it, I think it might actually make more sense continuing with your implementation, as the CmsObjects already define the directories and valid extensions, and the filter you have in place is already stripping out any other paths (ie. assets). |
Hmm, not sure exactly. Perhaps you could take a stab at finishing it off and then we'll see where that gets us? |
@LukeTowers My first pass at |
@bennothommo looks pretty good! I've added a comment to it, then it can be merged and we can test it out! |
@LukeTowers all sorted! |
Credit to @bennothommo. Fixes octobercms/october#3908 (comment) Co-Authored-By: LukeTowers <github@luketowers.ca>
This comment has been minimized.
This comment has been minimized.
Credit to @bennothommo. Fixes octobercms/october#3908 (comment) Co-Authored-By: LukeTowers <github@luketowers.ca>
Moved from rainlab/pages-plugin#307. Related: octobercms/library#356, rainlab/pages-plugin#368
Problems that will be solved:
theme:sync
command.Outline of how the feature will work:
cms.enableDatabaseLayer
and have a database already will see this feature set.theme:sync
with the--target=filesystem
flag).Task list:
cms.enableDatabaseLayer
configuration option. Defaults to false. Other values:true
=> enabled;null
=> inverse ofapp.debug
theme:sync themedir --paths=path/to/specific/file/to/sync.md,path/to/other/file.md --target=filesystem
, defaulting to the current theme, all paths inthemedir
for the--paths
flag anddatabase
for the target flag. Replaces all paths specified in the target with contents from the source. If no paths specified will empty the target entirely before populating with source files.Reset
button to CMS & RainLab.StaticPages. Appears when DB & FS copy exists, removes the DB version therefore populating content from the FS.Commit
button to CMS & RainLab.StaticPages. Appears whenapp.debug
enabled (meant only for developers) & DB content exists, populates the FS version and then removes the DB version from the DB for performance.DB layer can be described as the client, filesystem as dev. If the client has said "I don't want home.htm" then that will be true forever. (such records will be marked as deleted in the DB layer and then cached as a removed item in the AutoDatasource). Dev can delete and replace as much as they want, it won't change that fact that the client doesn't want that object.
If the client later inserts that file again into the DB layer through the CMS then the existing flagged record will simply be unflagged and populated with new content.
Current issues:
Test this feature
For those who would like to test this, simply follow these steps:
Clone the
octobercms/october
repo.Switch the main branch to
wip/halcyon-db-datasource
(ex:git checkout wip/halcyon-db-datasource
).Set
cms.enableDatabaseLayer
totrue
in/config/cms.php
.Run
composer update
to install dependencies.Run
php artisan october:env
to generate an.env
file (from project root).Input your local DB connection info in the
.env
file.In
/plugins/rainlab/pages
(create folder if it doesn't exist), clone the repo for therainlab/pages
plugin.Switch the plugin's branch to
wip/halcyon-db-datasource
(ex:git checkout wip/halcyon-db-datasource
).In
/vendor/october/rain
, remove the existing contents and clone the repo for theoctober/library
package.Switch the package's branch to
wip/halcyon-db-datasource
(ex:git checkout wip/halcyon-db-datasource
).Run
php artisan october:up
(from project root) to install the localRainLab.Pages
plugin from the cloned repo.