From 3c33b364b4b3a9fef64a005713979f02fe04d4b9 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 11 Apr 2016 14:49:06 -0400 Subject: draconian json parsing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'package.json') diff --git a/package.json b/package.json index 2d5df49..2a927d5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "okcms", - "version": "0.1.27", + "version": "0.1.30", "description": "great", "main": "app/index.js", "scripts": { -- cgit v1.2.3-70-g09d2 From 5922279561c1998a3e158c26f951348f4c031928 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 14 Apr 2016 14:17:00 -0400 Subject: support adding custom services per-project --- app/index.js | 42 ++++++++++++++++++------------- app/node_modules/okserver/index.js | 11 +++----- app/node_modules/okservices/oks3/index.js | 3 --- package.json | 5 ++-- themes/okadmin/public/js/upload.js | 3 --- 5 files changed, 32 insertions(+), 32 deletions(-) (limited to 'package.json') diff --git a/app/index.js b/app/index.js index 1a8f97e..7fd88f4 100644 --- a/app/index.js +++ b/app/index.js @@ -94,19 +94,30 @@ function OKCMS(options) { errorHandler); // Create services - if (serviceConfig.s3) { - var s3Service = OKS3Service({ - express: express, - s3: serviceConfig.s3, - }); - } - - if (serviceConfig.twitter) { - var twitterService = OKTwitterService({ - express: express, - credentials: serviceConfig.twitter, - }) - } + var services = {} + Object.keys(serviceConfig).forEach(function(key){ + var config = serviceConfig[key] + switch (key) { + case 's3': + services.s3 = OKS3Service({ + express: express, + s3: config, + }); + break + case 'twitter': + services.twitter = OKTwitterService({ + express: express, + credentials: config, + }); + break + default: + services[key] = config.lib({ + express: express, + config: config, + }); + break + } + }); var server = this._server = new OKServer({ express: express, @@ -117,10 +128,7 @@ function OKCMS(options) { root: root, adminRoot: adminRoot, adminPath: adminPath, - services: { - s3: s3Service, - twitter: twitterService, - }, + services: services, errorHandler: errorHandler }); } diff --git a/app/node_modules/okserver/index.js b/app/node_modules/okserver/index.js index 302911d..a89676f 100644 --- a/app/node_modules/okserver/index.js +++ b/app/node_modules/okserver/index.js @@ -52,7 +52,7 @@ function OKServer(options) { * other middleware. */ - // Disable silly express header + // Disable x-powered-by express header app.disable('x-powered-by') // Serve user static files app.use(express.static(root)); @@ -61,12 +61,9 @@ function OKServer(options) { // Application router app.use(router); // Add services - if (services.s3) { - app.use('/_services/s3', services.s3.middleware()); - } - if (services.twitter) { - app.use('/_services/twitter', services.twitter.middleware()) - } + Object.keys(services).forEach(function(key){ + app.use('/_services/' + key, services[key].middleware()); + }) // Make sure this lady is last. Checks whether the desired // route has a trailing-slash counterpart and redirects there app.use(slash()); diff --git a/app/node_modules/okservices/oks3/index.js b/app/node_modules/okservices/oks3/index.js index c636308..cc40b71 100644 --- a/app/node_modules/okservices/oks3/index.js +++ b/app/node_modules/okservices/oks3/index.js @@ -20,9 +20,6 @@ function OKS3(options) { if (!options.s3.audio) options.s3.audio = {} if (!options.s3.video) options.s3.video = {} - // TODO: maxBytes property doesn't work - if you upload a large file, - // it will just hang until you reload the browser, and then CRASH. - // Make sure maxbytes property is there - it can be a number, // or zero/undefined (for no maximum upload size) if (options.s3.maxbytes) { diff --git a/package.json b/package.json index 2a927d5..bd5719b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "okcms", - "version": "0.1.30", + "version": "0.1.31", "description": "great", "main": "app/index.js", "scripts": { @@ -13,7 +13,8 @@ "dotenv": "^1.1.0", "express": "^4.12.3", "object-assign": "^2.0.0", - "q": "^1.2.0" + "q": "^1.2.0", + "request": "^2.71.0" }, "devDependencies": { "grunt": "^0.4.5", diff --git a/themes/okadmin/public/js/upload.js b/themes/okadmin/public/js/upload.js index da23b1b..6ff7ac9 100644 --- a/themes/okadmin/public/js/upload.js +++ b/themes/okadmin/public/js/upload.js @@ -177,9 +177,6 @@ OKUpload.prototype.add = function(media){ OKUpload.prototype.addMedia = function(media){ console.log(media) } -OKUpload.prototype.addAudio = function(media){ - console.log(media) -} OKUpload.prototype.error = function(error){ throw error } -- cgit v1.2.3-70-g09d2 From 1d5c1c1525dbefd7891acbdf7492ee9e62e24e16 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 14 Apr 2016 20:32:43 -0400 Subject: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'package.json') diff --git a/package.json b/package.json index bd5719b..619b1c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "okcms", - "version": "0.1.31", + "version": "0.1.33", "description": "great", "main": "app/index.js", "scripts": { -- cgit v1.2.3-70-g09d2 From f76ec56f3d70da6359905e9b9666f581599edd4f Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 21 Apr 2016 18:02:31 -0400 Subject: fix issue with single input fields, store image width/height --- examples/db.json | 24 ++++++++++++++++++++++- examples/index.js | 6 ++++++ package.json | 4 ++-- themes/okadmin/public/css/main.css | 4 +++- themes/okadmin/public/js/app.js | 26 ++++++++++++++++--------- themes/okadmin/templates/partials/inputs.liquid | 18 +++++++++++++++-- 6 files changed, 67 insertions(+), 15 deletions(-) (limited to 'package.json') diff --git a/examples/db.json b/examples/db.json index 8805342..401bf26 100644 --- a/examples/db.json +++ b/examples/db.json @@ -153,6 +153,13 @@ "id": "red", "title": "Red", "media": [ + { + "uri": "https://ltho.s3.amazonaws.com/okcms-example/a91c4210-080c-11e6-8a7d-f30231d4ec26.png", + "width": "800", + "height": "800", + "caption": "", + "type": "image" + }, { "uri": "http://asdf.us/", "caption": "ASDF", @@ -160,7 +167,8 @@ } ], "__index": 0, - "dateCreated": "Mon, 28 Mar 2016 23:02:45 GMT" + "dateCreated": "Mon, 28 Mar 2016 23:02:45 GMT", + "flagged": false }, { "id": "blue", @@ -210,5 +218,19 @@ ], "flagged": true } + ], + "flour": [ + { + "id": "test", + "title": "TEST", + "image": { + "uri": "https://ltho.s3.amazonaws.com/okcms-example/7be163d0-080b-11e6-8a7d-f30231d4ec26.png", + "caption": "", + "width": "800", + "height": "800" + }, + "__index": 0, + "dateCreated": "Thu, 21 Apr 2016 21:52:44 GMT" + } ] } \ No newline at end of file diff --git a/examples/index.js b/examples/index.js index efbfc38..341a50b 100644 --- a/examples/index.js +++ b/examples/index.js @@ -29,6 +29,11 @@ var app = okcms.createApp({ title: {type: 'string'}, flagged: {type: 'flag'}, media: {type: 'media-list'}, + }, + flour: { + id: {type: 'string', hidden: true}, + title: {type: 'string'}, + image: {type: 'image'}, } }, @@ -37,6 +42,7 @@ var app = okcms.createApp({ { type: 'page', static: {id: 'contact'}}, { type: 'bread' }, { type: 'test' }, + { type: 'flour' }, ], services: { diff --git a/package.json b/package.json index 619b1c8..971efed 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "okcms", - "version": "0.1.33", - "description": "great", + "version": "0.1.34", + "description": "The dopest CMS on the planet.", "main": "app/index.js", "scripts": { "postinstall": "./install.sh", diff --git a/themes/okadmin/public/css/main.css b/themes/okadmin/public/css/main.css index 15b8781..e539a71 100644 --- a/themes/okadmin/public/css/main.css +++ b/themes/okadmin/public/css/main.css @@ -291,7 +291,9 @@ button, input[type=submit] { height: 7em; } .main.resource form img { - width: 10em; + width: auto; + height: auto; + max-width: 10em; max-height: 6em; border: 0; } diff --git a/themes/okadmin/public/js/app.js b/themes/okadmin/public/js/app.js index 59fc6ae..578d99f 100644 --- a/themes/okadmin/public/js/app.js +++ b/themes/okadmin/public/js/app.js @@ -9,8 +9,10 @@ var OKAdmin = function(){ var url = media.url var imageTemplate = $(".image-template", parent).html() var $el = $(imageTemplate) - $el.find(".uri").val(url) - $el.find("img").attr("src", url) + $el.find(".uri").val(media.url) + $el.find(".image-width").val(media.width) + $el.find(".image-height").val(media.height) + $el.find("img").attr("src", media.url) $("ol", parent).prepend($el) } }) @@ -44,8 +46,10 @@ var OKAdmin = function(){ var url = media.url var imageTemplate = $(".image-template", parent).html() var $el = $(imageTemplate) - $el.find(".uri").val(url) - $el.find("img").attr("src", url) + $el.find(".uri").val(media.url) + $el.find(".image-width").val(media.width) + $el.find(".image-height").val(media.height) + $el.find("img").attr("src", media.url) $("ol", parent).prepend($el) } uploader.addMedia = function(media){ @@ -103,11 +107,13 @@ var OKAdmin = function(){ var $el = $(this) var uploader = new OKUpload () uploader.bind( this ) - uploader.add = function(url){ - console.log(url) - $el.find(".uri").val(url) + uploader.add = function(media){ + console.log(media) + $el.find(".uri").val(media.url) $el.find(".caption").val("") - $el.find("img").attr("src", url).show() + $el.find(".image-width").val(media.width) + $el.find(".image-height").val(media.height) + $el.find("img").attr("src", media.url).show() $el.addClass("loaded") } }) @@ -117,6 +123,8 @@ var OKAdmin = function(){ var $el = $(this).closest(".image") $el.removeClass('loaded') $el.find(".uri").val("") + $el.find(".image-width").val("") + $el.find(".image-height").val("") $el.find(".caption").val("") $el.find("img").attr("src", "") } @@ -141,7 +149,7 @@ var OKAdmin = function(){ $el.parent().addClass("loaded") $el.parent().find(".video-type").val( media.type ) $el.parent().find(".video-token").val( media.token ) - $el.parent().find(".video-uri").val( media.uri ) + $el.parent().find(".video-uri").val( media.url ) $el.parent().find(".video-title").val( media.title ) $el.parent().find(".video-thumb").val( media.thumbnail ) $el.parent().find(".video-width").val( media.width ) diff --git a/themes/okadmin/templates/partials/inputs.liquid b/themes/okadmin/templates/partials/inputs.liquid index 373e580..e71f4ad 100644 --- a/themes/okadmin/templates/partials/inputs.liquid +++ b/themes/okadmin/templates/partials/inputs.liquid @@ -48,6 +48,8 @@
+ + {{spec.value.caption | escape}}
@@ -154,6 +156,8 @@ + + @@ -165,8 +169,8 @@ - - + + @@ -249,6 +253,8 @@
  • + + {{image.caption | strip_html}} @@ -271,6 +277,8 @@