From 2218cbd252d23a188e772f03167d08dc05bd104c Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 8 Dec 2014 19:08:12 +0000 Subject: [PATCH 01/12] docs --- doc/api/hooks_server-side.md | 17 +++++++++++++++++ src/node/utils/ExportHtml.js | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index 435872ea1..90f1b59c4 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -247,6 +247,23 @@ Things in context: This hook will allow a plug-in developer to re-write each line when exporting to HTML. +## stylesForExport +Called from: src/node/utils/ExportHtml.js + +Things in context: + +1. padId - The Pad Id + +This hook will allow a plug-in developer to append Styles to the Exported HTML. + +Example: + +``` +exports.stylesForExport = function(hook, context){ + return("body{margin-left:20px;body{color:orange}"); +} +``` + ## exportFileName Called from src/node/handler/ExportHandler.js diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js index 01920da79..16c676180 100644 --- a/src/node/utils/ExportHtml.js +++ b/src/node/utils/ExportHtml.js @@ -425,6 +425,9 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback) { if(ERR(err, callback)) return; + // Include some Styles into the Head for Export + var stylesForExport = hooks.callAllStr("stylesForExport") || '' + var head = (noDocType ? '' : '\n') + '\n' + (noDocType ? '' : '\n' + @@ -442,6 +445,7 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback) 'ol ol ol ol ol ol{ list-style-type: lower-roman; }' + 'ol ol ol ol ol ol ol { list-style-type: decimal; }' + 'ol ol ol ol ol ol ol ol{ list-style-type: lower-latin; }' + + stylesForExport + '\n' + '\n') + ''; @@ -452,6 +456,7 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback) if(ERR(err, callback)) return; callback(null, head + html + foot); }); + }); }; From 7cf0e4a9ae1b6171c24cee72b5579e2774fdde45 Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 8 Dec 2014 19:11:45 +0000 Subject: [PATCH 02/12] allow padId to be passed into the hook --- src/node/utils/ExportHtml.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js index 16c676180..da2eb2b31 100644 --- a/src/node/utils/ExportHtml.js +++ b/src/node/utils/ExportHtml.js @@ -426,7 +426,7 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback) if(ERR(err, callback)) return; // Include some Styles into the Head for Export - var stylesForExport = hooks.callAllStr("stylesForExport") || '' + var stylesForExport = hooks.callAllStr("stylesForExport", padId) || '' var head = (noDocType ? '' : '\n') + From f2c155ee1aa743be689ad898220462d13d2cc885 Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 8 Dec 2014 19:44:40 +0000 Subject: [PATCH 03/12] blah use async --- src/node/utils/ExportHtml.js | 56 ++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js index da2eb2b31..bd6b160cd 100644 --- a/src/node/utils/ExportHtml.js +++ b/src/node/utils/ExportHtml.js @@ -426,37 +426,37 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback) if(ERR(err, callback)) return; // Include some Styles into the Head for Export - var stylesForExport = hooks.callAllStr("stylesForExport", padId) || '' + hooks.aCallAll("stylesForExport", padId, function(err, stylesForExport){ - var head = - (noDocType ? '' : '\n') + - '\n' + (noDocType ? '' : '\n' + - '' + Security.escapeHTML(padId) + '\n' + - '\n' + - '\n' + '\n') + - ''; + // Core inclusion of head etc. + var head = + (noDocType ? '' : '\n') + + '\n' + (noDocType ? '' : '\n' + + '' + Security.escapeHTML(padId) + '\n' + + '\n' + + '\n' + '\n') + + ''; + var foot = '\n\n'; - var foot = '\n\n'; - - getPadHTML(pad, revNum, function (err, html) - { - if(ERR(err, callback)) return; - callback(null, head + html + foot); + getPadHTML(pad, revNum, function (err, html) + { + if(ERR(err, callback)) return; + callback(null, head + html + foot); + }); }); - }); }; From ce004f9c59fbb7ea786ef4051498b2e895c5da37 Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 8 Dec 2014 19:48:02 +0000 Subject: [PATCH 04/12] docs --- doc/api/hooks_server-side.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index 90f1b59c4..e730f18ee 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -259,8 +259,8 @@ This hook will allow a plug-in developer to append Styles to the Exported HTML. Example: ``` -exports.stylesForExport = function(hook, context){ - return("body{margin-left:20px;body{color:orange}"); +exports.stylesForExport = function(hook, padId, cb){ + cb("body{font-size:13.37em !important}"); } ``` From f11bdc1b440d5777b55e55e0313195b618f3d977 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 9 Dec 2014 01:31:40 +0000 Subject: [PATCH 05/12] also logic to add attributes for properties --- src/static/js/linestylefilter.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/static/js/linestylefilter.js b/src/static/js/linestylefilter.js index cb1ee1d50..757fac5ae 100644 --- a/src/static/js/linestylefilter.js +++ b/src/static/js/linestylefilter.js @@ -34,7 +34,6 @@ var linestylefilter = {}; var _ = require('./underscore'); var AttributeManager = require('./AttributeManager'); - linestylefilter.ATTRIB_CLASSES = { 'bold': 'tag:b', 'italic': 'tag:i', @@ -59,6 +58,13 @@ linestylefilter.getAuthorClassName = function(author) linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFunc, apool) { + // Plugin Hook to add more Attrib Classes + hooks.aCallAll('aceAttribClasses', linestylefilter.ATTRIB_CLASSES, function(err, ATTRIB_CLASSES){ + if(ATTRIB_CLASSES){ + linestylefilter.ATTRIB_CLASSES = ATTRIB_CLASSES[0]; + } + }); + if (lineLength == 0) return textAndClassFunc; var nextAfterAuthorColors = textAndClassFunc; From b94a525e07a54529a4f1cfa3a9b328b551e13d70 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 9 Dec 2014 01:35:59 +0000 Subject: [PATCH 06/12] docs --- doc/api/hooks_client-side.md | 16 ++++++++++++++++ doc/api/hooks_server-side.md | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/doc/api/hooks_client-side.md b/doc/api/hooks_client-side.md index b8a58b316..ca429a075 100644 --- a/doc/api/hooks_client-side.md +++ b/doc/api/hooks_client-side.md @@ -80,6 +80,22 @@ This hook is called during the attribute processing procedure, and should be use The return value for this function should be a list of classes, which will then be parsed into a valid class string. +## aceAttribClasses +Called from: src/static/js/linestylefilter.js + +Things in context: +1. Attributes - Object of Attributes + +This hook is called when attributes are investigated on a line. It is useful if you want to add another attribute type or property type to a pad. + +Example: +``` +exports.aceAttribClasses = function(hook_name, attr, cb){ + attr.sub = 'tag:sub'; + cb(attr); +} +``` + ## aceGetFilterStack Called from: src/static/js/linestylefilter.js diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index e730f18ee..69f5ab5c4 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -264,6 +264,23 @@ exports.stylesForExport = function(hook, padId, cb){ } ``` +## aceAttribClasses +Called from: src/static/js/linestylefilter.js + +Things in context: +1. Attributes - Object of Attributes + +This hook is called when attributes are investigated on a line. It is useful if you want to add another attribute type or property type to a pad. + +Example: + +``` +exports.aceAttribClasses = function(hook_name, attr, cb){ + attr.sub = 'tag:sub'; + cb(attr); +} +``` + ## exportFileName Called from src/node/handler/ExportHandler.js From 653cc6c87fe8956b17261cb6cb3b5fbc00128ba1 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 9 Dec 2014 14:57:18 +0000 Subject: [PATCH 07/12] this class was in before, it is used to show when a style is applied to a piece of content --- src/static/css/pad.css | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/static/css/pad.css b/src/static/css/pad.css index fb2cb82ba..7ecf8e226 100644 --- a/src/static/css/pad.css +++ b/src/static/css/pad.css @@ -105,6 +105,17 @@ a img { -moz-box-shadow: 0 0 8px rgba(0,0,0,.1) inset; box-shadow: 0 0 8px rgba(0,0,0,.1) inset; } +.toolbar ul li .activeButton { + background: #eee; + background: -webkit-linear-gradient(#ddd, #fff); + background: -moz-linear-gradient(#ddd, #fff); + background: -o-linear-gradient(#ddd, #fff); + background: -ms-linear-gradient(#ddd, #fff); + background: linear-gradient(#ddd, #fff); + -webkit-box-shadow: 0 0 8px rgba(0,0,0,.1) inset; + -moz-box-shadow: 0 0 8px rgba(0,0,0,.1) inset; + box-shadow: 0 0 8px rgba(0,0,0,.1) inset; +} .toolbar ul li a { background: #fff; background: -webkit-linear-gradient(#fff, #f0f0f0); From 3a2669b70488d26d2fbd9e0b20b8801fb8d7d8a5 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 9 Dec 2014 16:13:52 +0000 Subject: [PATCH 08/12] additional tag support hook --- src/node/utils/ExportHtml.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js index bd6b160cd..cc32ea321 100644 --- a/src/node/utils/ExportHtml.js +++ b/src/node/utils/ExportHtml.js @@ -78,6 +78,14 @@ function getHTMLFromAtext(pad, atext, authorColors) var tags = ['h1', 'h2', 'strong', 'em', 'u', 's']; var props = ['heading1', 'heading2', 'bold', 'italic', 'underline', 'strikethrough']; + + hooks.aCallAll("exportHtmlAdditionalTags", pad, function(err, newProps){ + newProps.forEach(function (propName, i){ + tags.push(propName); + props.push(propName); + }); + }); + // holds a map of used styling attributes (*1, *2, etc) in the apool // and maps them to an index in props // *3:2 -> the attribute *3 means strong From fccfc3bd417c574d52ec14c30922f32d5e883004 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 9 Dec 2014 16:16:19 +0000 Subject: [PATCH 09/12] docs --- doc/api/hooks_server-side.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index 69f5ab5c4..251cbf11e 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -298,6 +298,24 @@ exports.exportFileName = function(hook, padId, callback){ } ``` +## exportHtmlAdditionalTags +Called from src/node/utils/ExportHtml.js + +Things in context: + +1. Pad object + +This hook will allow a plug-in developer to include more properties and attributes to support during HTML Export. An Array should be returned. + +Example: +``` +// Add the props to be supported in export +exports.exportHtmlAdditionalTags = function(hook, pad, cb){ + var padId = pad.id; + cb(["massive","jugs"]); +}; + + ## userLeave Called from src/node/handler/PadMessageHandler.js From 197a41627d931e3ca6a6a756caefae05d09b7352 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 9 Dec 2014 17:34:52 +0000 Subject: [PATCH 10/12] allow plugins to add multiple styles --- src/node/utils/ExportHtml.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js index cc32ea321..693cf9cf3 100644 --- a/src/node/utils/ExportHtml.js +++ b/src/node/utils/ExportHtml.js @@ -433,9 +433,12 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback) { if(ERR(err, callback)) return; + var stylesForExportCSS = ""; // Include some Styles into the Head for Export hooks.aCallAll("stylesForExport", padId, function(err, stylesForExport){ - + stylesForExport.forEach(function(css){ + stylesForExportCSS += css; + }); // Core inclusion of head etc. var head = (noDocType ? '' : '\n') + @@ -454,7 +457,7 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback) 'ol ol ol ol ol ol{ list-style-type: lower-roman; }' + 'ol ol ol ol ol ol ol { list-style-type: decimal; }' + 'ol ol ol ol ol ol ol ol{ list-style-type: lower-latin; }' + - stylesForExport + + stylesForExportCSS + '\n' + '\n') + ''; var foot = '\n\n'; From a2dbf8761f4cdffbfae3549ca85ea153b163063a Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 10 Dec 2014 01:23:24 +0000 Subject: [PATCH 11/12] allow for timeslider custom messages --- src/static/js/broadcast.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/static/js/broadcast.js b/src/static/js/broadcast.js index 191d802e0..a25d889b9 100644 --- a/src/static/js/broadcast.js +++ b/src/static/js/broadcast.js @@ -27,6 +27,7 @@ var Changeset = require('./Changeset'); var linestylefilter = require('./linestylefilter').linestylefilter; var colorutils = require('./colorutils').colorutils; var _ = require('./underscore'); +var hooks = require('./pluginfw/hooks'); // These parameters were global, now they are injected. A reference to the // Timeslider controller would probably be more appropriate. @@ -534,6 +535,7 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro var savedRev = obj.savedRev; BroadcastSlider.addSavedRevision(savedRev.revNum, savedRev); } + hooks.callAll('handleClientTimesliderMessage_' + obj.type, {payload: obj}); } else if(obj.type == "CHANGESET_REQ") { From 3fe58068c0a80a334d1fbf43a1b00fe3ca4a0b3f Mon Sep 17 00:00:00 2001 From: John McLear Date: Sun, 21 Dec 2014 23:16:00 +0000 Subject: [PATCH 12/12] more fixes --- src/static/js/broadcast_revisions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/static/js/broadcast_revisions.js b/src/static/js/broadcast_revisions.js index 9774dc3f7..1980bdf30 100644 --- a/src/static/js/broadcast_revisions.js +++ b/src/static/js/broadcast_revisions.js @@ -48,7 +48,7 @@ function loadBroadcastRevisionsJS() }); } - var revisionInfo = {}; + revisionInfo = {}; revisionInfo.addChangeset = function(fromIndex, toIndex, changeset, backChangeset, timeDelta) { var startRevision = revisionInfo[fromIndex] || revisionInfo.createNew(fromIndex);