Skip to content

Commit

Permalink
Merge pull request octobercms#3908 from octobercms/wip/halcyon-db-dat…
Browse files Browse the repository at this point in the history
…asource

Database layer for the CMS objects
  • Loading branch information
daftspunk authored Jun 1, 2019
2 parents 85c7ba3 + 6f021d5 commit e7ec0be
Show file tree
Hide file tree
Showing 19 changed files with 1,185 additions and 95 deletions.
34 changes: 30 additions & 4 deletions config/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
| Back-end login remember
|--------------------------------------------------------------------------
|
| Define live duration of backend sessions :
| Define live duration of backend sessions:
|
| true - session never expire (cookie expiration in 5 years)
|
Expand Down Expand Up @@ -211,6 +211,32 @@

'enableAssetDeepHashing' => null,

/*
|--------------------------------------------------------------------------
| Database-driven Themes
|--------------------------------------------------------------------------
|
| Stores theme templates in the database instead of the filesystem.
|
| false - All theme templates are sourced from the filesystem.
|
| true - Source theme templates from the database with fallback to the filesytem.
|
| null - Setting equal to the inverse of app.debug: debug enabled, this disabled.
|
| The database layer stores all modified CMS files in the database. Files that are
| not modified continue to be loaded from the filesystem. The `theme:sync $themeDir`
| console command is available to populate the database from the filesystem with
| the `--toFile` flag to sync in the other direction (database to filesystem) and
| the `--paths="/path/to/file.md,/path/to/file2.md" flag to sync only specific files.
|
| Files modified in the database are cached to indicate that they should be loaded
| from the database.
|
*/

'databaseTemplates' => false,

/*
|--------------------------------------------------------------------------
| Public plugins path
Expand Down Expand Up @@ -346,20 +372,20 @@
*/

'forceBytecodeInvalidation' => true,

/*
|--------------------------------------------------------------------------
| Twig Strict Variables
|--------------------------------------------------------------------------
|
| If strict_variables is disabled, Twig will silently ignore invalid
| If strict_variables is disabled, Twig will silently ignore invalid
| variables (variables and or attributes/methods that do not exist) and
| replace them with a null value. When enabled, Twig throws an exception
| instead. If set to null, it is enabled when debug mode (app.debug) is
| enabled.
|
*/

'enableTwigStrictVariables' => false,

/*
Expand Down
17 changes: 17 additions & 0 deletions modules/cms/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function register()
$this->registerComponents();
$this->registerThemeLogging();
$this->registerCombinerEvents();
$this->registerHalcyonModels();

/*
* Backend specific
Expand Down Expand Up @@ -324,4 +325,20 @@ protected function bootRichEditorEvents()
}
});
}

/**
* Registers the models to be made available to the theme database layer
*/
protected function registerHalcyonModels()
{
Event::listen('system.console.theme.sync.getAvailableModelClasses', function () {
return [
Classes\Meta::class,
Classes\Page::class,
Classes\Layout::class,
Classes\Content::class,
Classes\Partial::class
];
});
}
}
26 changes: 21 additions & 5 deletions modules/cms/assets/js/october.cmspage.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
var dataId = $target.closest('li').attr('data-tab-id'),
title = $target.attr('title'),
$sidePanel = $('#cms-side-panel')

if (title)
this.setPageTitle(title)

Expand Down Expand Up @@ -250,6 +250,8 @@

$form.on('changed.oc.changeMonitor', function() {
$panel.trigger('modified.oc.tab')
$panel.find('[data-control=commit-button]').addClass('hide');
$panel.find('[data-control=reset-button]').addClass('hide');
self.updateModifiedCounter()
})

Expand Down Expand Up @@ -279,6 +281,10 @@
CmsPage.prototype.onAjaxSuccess = function(ev, context, data) {
var element = ev.target

// Update the visibilities of the commit & reset buttons
$('[data-control=commit-button]', element).toggleClass('hide', !data.canCommit)
$('[data-control=reset-button]', element).toggleClass('hide', !data.canReset)

if (data.templatePath !== undefined) {
$('input[name=templatePath]', element).val(data.templatePath)
$('input[name=templateMtime]', element).val(data.templateMtime)
Expand Down Expand Up @@ -313,6 +319,11 @@
if (context.handler == 'onSave' && (!data['X_OCTOBER_ERROR_FIELDS'] && !data['X_OCTOBER_ERROR_MESSAGE'])) {
$(element).trigger('unchange.oc.changeMonitor')
}

// Reload the form if the server has requested it
if (data.forceReload) {
this.reloadForm(element)
}
}

CmsPage.prototype.onAjaxError = function(ev, context, message, data, jqXHR) {
Expand Down Expand Up @@ -359,7 +370,7 @@
}).done(function(data) {
var tabs = $('#cms-master-tabs').data('oc.tab');
$.each(data.deleted, function(index, path){
var
var
tabId = templateType + '-' + data.theme + '-' + path,
tab = tabs.findByIdentifier(tabId)

Expand All @@ -375,7 +386,12 @@
}

CmsPage.prototype.onInspectorShowing = function(ev, data) {
$(ev.currentTarget).closest('[data-control="toolbar"]').data('oc.dragScroll').goToElement(ev.currentTarget, data.callback)
var $dragScroll = $(ev.currentTarget).closest('[data-control="toolbar"]').data('oc.dragScroll')
if ($dragScroll) {
$dragScroll.goToElement(ev.currentTarget, data.callback)
} else {
data.callback();
}

ev.stopPropagation()
}
Expand Down Expand Up @@ -640,7 +656,7 @@
}

CmsPage.prototype.reloadForm = function(form) {
var
var
$form = $(form),
data = {
type: $('[name=templateType]', $form).val(),
Expand Down Expand Up @@ -682,7 +698,7 @@
$(form).request('onGetTemplateList', {
success: function(data) {
$('#cms-master-tabs > .tab-content select[name="settings[layout]"]').each(function(){
var
var
$select = $(this),
value = $select.val()

Expand Down
Loading

0 comments on commit e7ec0be

Please sign in to comment.