aboutsummaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
Diffstat (limited to 'data')
-rw-r--r--data/assets/css/admin.css2
-rw-r--r--data/assets/js/admin/dialogs/site-add.js25
-rw-r--r--data/assets/js/util.js4
-rw-r--r--data/init.yaml19
4 files changed, 39 insertions, 11 deletions
diff --git a/data/assets/css/admin.css b/data/assets/css/admin.css
index ba65585..4ab39b3 100644
--- a/data/assets/css/admin.css
+++ b/data/assets/css/admin.css
@@ -2,7 +2,7 @@
cursor: pointer;
}
-#page-edit-styles, #page-edit-scripts {
+textarea.asset-list {
min-height: 200px;
height: 20vh;
}
diff --git a/data/assets/js/admin/dialogs/site-add.js b/data/assets/js/admin/dialogs/site-add.js
index 8cdc772..bf95b8e 100644
--- a/data/assets/js/admin/dialogs/site-add.js
+++ b/data/assets/js/admin/dialogs/site-add.js
@@ -1,8 +1,12 @@
jQuery(function($) {
"use strict";
- var p = '#site-add-',
- IDS = ['name', 'slug', 'body', 'lang', 'theme_id'];
+ var p = '#site-add-';
+
+ var FIELDS = {
+ text: ['name', 'slug', 'body', 'lang', 'theme_id'],
+ list: ['domains', 'styles', 'scripts'],
+ }
var DEFAULTS = {
lang: DATA.default_lang,
@@ -10,12 +14,14 @@ jQuery(function($) {
};
$(p + 'dialog').on('show.bs.modal', function() {
- $.each(IDS, function(_, id) {
+ $.each(FIELDS.text, function(_, id) {
$(p + id).val(DEFAULTS[id] || '');
});
- // clear list of domains
- $(p + 'domains').val('');
+ // clear list textareas
+ $.each(FIELDS.list, function(_, id) {
+ $(p + id).val('');
+ });
});
$(p + 'dialog').on('shown.bs.modal', function() {
@@ -54,13 +60,16 @@ jQuery(function($) {
// toggle loading
me.toggleClass('disabled').find('.loading').toggleClass('hidden');
- send('site/add', IDS.reduce(function(r, id) {
+ send('site/add', FIELDS.text.reduce(function(r, id) {
r[id] = $(p + id).val();
return r;
+ }, FIELDS.list.reduce(function(r, id) {
+ r[id] = listify(p + id);
+ return r;
}, {
+ // hard-code this for now
is_full_feed: 't',
- domains: listify(p + 'domains'),
- })).always(function() {
+ }))).always(function() {
// toggle loading
me.toggleClass('disabled').find('.loading').toggleClass('hidden');
}).fail(function(r) {
diff --git a/data/assets/js/util.js b/data/assets/js/util.js
index 6379961..a812f1f 100644
--- a/data/assets/js/util.js
+++ b/data/assets/js/util.js
@@ -39,8 +39,8 @@ jQuery(function($) {
// convert textarea to jsonified array of strings
window.listify = function(el) {
- var r = $(el).val().replace(/^\s+|\s+$/m, '');
- return JSON.stringify((r.length > 0) ? r.split(/\s+/m) : []);
+ var s = $(el).val().replace(/^\s+|\s+$/m, '');
+ return JSON.stringify((s.length > 0) ? s.split(/\s+/m) : []);
}
diff --git a/data/init.yaml b/data/init.yaml
index f9a8ac1..de78d23 100644
--- a/data/init.yaml
+++ b/data/init.yaml
@@ -267,6 +267,25 @@ init_sql:
)
- |
+ CREATE TABLE site_assets (
+ site_id INTEGER NOT NULL
+ REFERENCES sites(site_id),
+
+ -- asset type
+ type_id INTEGER NOT NULL
+ REFERENCES asset_types(type_id),
+
+ -- asset path
+ path TEXT NOT NULL
+ CHECK (LENGTH(path) > 0),
+
+ -- load order
+ sort_order INTEGER NOT NULL,
+
+ PRIMARY KEY (site_id, type_id, path)
+ )
+
+ - |
CREATE TABLE states (
state_id INTEGER PRIMARY KEY,