diff --git a/bin/gollum b/bin/gollum
index cd4e41e0..0de5fde6 100755
--- a/bin/gollum
+++ b/bin/gollum
@@ -135,6 +135,9 @@ MSG
"By default, uses the 'TeX-AMS-MML_HTMLorMML' config with the 'autoload-all' extension.") do
wiki_options[:mathjax] = true
end
+ opts.on("--critic-markup", "Enable support for annotations using CriticMarkup.") do
+ wiki_options[:critic_markup] = true
+ end
opts.on("--irb", "Launch Gollum in 'console mode', with a predefined API.") do
options[:irb] = true
end
diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb
index 6bd8081b..6c03fcc5 100644
--- a/lib/gollum/app.rb
+++ b/lib/gollum/app.rb
@@ -84,7 +84,9 @@ module Precious
before do
settings.wiki_options[:allow_editing] = settings.wiki_options.fetch(:allow_editing, true)
@allow_editing = settings.wiki_options[:allow_editing]
+ @critic_markup = settings.wiki_options[:critic_markup]
@per_page_uploads = settings.wiki_options[:per_page_uploads]
+
forbid unless @allow_editing || request.request_method == "GET"
Precious::App.set(:mustache, {:templates => settings.wiki_options[:template_dir]}) if settings.wiki_options[:template_dir]
@base_url = url('/', false).chomp('/').force_encoding('utf-8')
diff --git a/lib/gollum/assets.rb b/lib/gollum/assets.rb
index 50003804..c01ed0b8 100644
--- a/lib/gollum/assets.rb
+++ b/lib/gollum/assets.rb
@@ -1,6 +1,6 @@
module Precious
module Assets
- MANIFEST = %w(app.js app.css fileview.css ie7.css print.css *.png *.jpg *.svg *.eot *.ttf *.woff *.woff2)
+ MANIFEST = %w(app.js app.css criticmarkup.css fileview.css ie7.css print.css *.png *.jpg *.svg *.eot *.ttf *.woff *.woff2)
ASSET_URL = 'gollum/assets'
def self.sprockets(dir = File.dirname(File.expand_path(__FILE__)))
diff --git a/lib/gollum/public/gollum/javascript/editor/langs/asciidoc.js b/lib/gollum/public/gollum/javascript/editor/langs/asciidoc.js
index 8703bbee..b4a7a5b9 100644
--- a/lib/gollum/public/gollum/javascript/editor/langs/asciidoc.js
+++ b/lib/gollum/public/gollum/javascript/editor/langs/asciidoc.js
@@ -113,7 +113,34 @@ var AsciiDoc = {
}
});
}
- }
+ },
+
+ 'function-critic-accept' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ },
+
+ 'function-critic-reject' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ }
+
};
diff --git a/lib/gollum/public/gollum/javascript/editor/langs/creole.js b/lib/gollum/public/gollum/javascript/editor/langs/creole.js
index b32e95b6..90c4cd0e 100644
--- a/lib/gollum/public/gollum/javascript/editor/langs/creole.js
+++ b/lib/gollum/public/gollum/javascript/editor/langs/creole.js
@@ -96,7 +96,33 @@ var Creole = {
}
});
}
- }
+ },
+ 'function-critic-accept' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ },
+
+ 'function-critic-reject' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ }
+
};
diff --git a/lib/gollum/public/gollum/javascript/editor/langs/markdown.js b/lib/gollum/public/gollum/javascript/editor/langs/markdown.js
index b1f917eb..5b2cb55a 100644
--- a/lib/gollum/public/gollum/javascript/editor/langs/markdown.js
+++ b/lib/gollum/public/gollum/javascript/editor/langs/markdown.js
@@ -139,7 +139,33 @@ var MarkDown = {
}
});
}
- }
+ },
+
+ 'function-critic-accept' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ },
+
+ 'function-critic-reject' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ }
};
diff --git a/lib/gollum/public/gollum/javascript/editor/langs/org.js b/lib/gollum/public/gollum/javascript/editor/langs/org.js
index 072cf388..f6a0c5e2 100644
--- a/lib/gollum/public/gollum/javascript/editor/langs/org.js
+++ b/lib/gollum/public/gollum/javascript/editor/langs/org.js
@@ -105,7 +105,34 @@ var OrgMode = {
}
});
}
- }
+ },
+
+ 'function-critic-accept' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ },
+
+ 'function-critic-reject' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ }
+
};
diff --git a/lib/gollum/public/gollum/javascript/editor/langs/pod.js b/lib/gollum/public/gollum/javascript/editor/langs/pod.js
index 1cb7957c..89125bb3 100644
--- a/lib/gollum/public/gollum/javascript/editor/langs/pod.js
+++ b/lib/gollum/public/gollum/javascript/editor/langs/pod.js
@@ -63,7 +63,34 @@ var Pod = {
}
});
}
- }
+ },
+
+ 'function-critic-accept' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ },
+
+ 'function-critic-reject' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ }
+
};
diff --git a/lib/gollum/public/gollum/javascript/editor/langs/rdoc.js b/lib/gollum/public/gollum/javascript/editor/langs/rdoc.js
index f0df80b8..e0f5fe1f 100644
--- a/lib/gollum/public/gollum/javascript/editor/langs/rdoc.js
+++ b/lib/gollum/public/gollum/javascript/editor/langs/rdoc.js
@@ -65,7 +65,34 @@ var RDoc = {
'function-h3' : {
search: /(.+)([\n]?)/gi,
replace: "=== $1$2"
- }
+ },
+
+ 'function-critic-accept' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ },
+
+ 'function-critic-reject' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ }
+
};
diff --git a/lib/gollum/public/gollum/javascript/editor/langs/textile.js b/lib/gollum/public/gollum/javascript/editor/langs/textile.js
index 4e27433d..999ce2f4 100644
--- a/lib/gollum/public/gollum/javascript/editor/langs/textile.js
+++ b/lib/gollum/public/gollum/javascript/editor/langs/textile.js
@@ -102,7 +102,34 @@ var Textile = {
}
});
}
- }
+ },
+
+ 'function-critic-accept' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$2").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ },
+
+ 'function-critic-reject' : {
+ exec: function( txt, selText, $field) {
+ var toReplace = selText.
+ replace(/\{\+\+(.*?)\+\+[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "").
+ replace(/\{--(.*?)--[ \t]*(\[(.*?)\])?[ \t]*\}/gm, "$1").
+ replace(/\{~~(.*?)~>(.*?)~~\}/gm, "$1").
+ replace(/\{\=\=(.*?)[ \t]*(\[(.*?)\])?[ \t]*\=\=\}{>>(.*?)<<\}/gm, "$1").
+ replace(/\{>>(.*?)<<\}/gm, "")
+ $.GollumEditor.replaceSelection( toReplace );
+ }
+
+ }
+
};
diff --git a/lib/gollum/public/gollum/javascript/gollum.js.erb b/lib/gollum/public/gollum/javascript/gollum.js.erb
index 9cf5fc89..4d17c20a 100755
--- a/lib/gollum/public/gollum/javascript/gollum.js.erb
+++ b/lib/gollum/public/gollum/javascript/gollum.js.erb
@@ -390,6 +390,14 @@ $(document).ready(function() {
$.GollumEditor({ NewFile: true, MarkupType: default_markup });
}
+ // CriticMarkup
+ if(criticMarkup == 'true') {
+ $('#wiki-content').addClass('criticmarkup');
+ $('ins.break').unwrap();
+ $('span.critic.comment').wrap('');
+ $('span.critic.comment').filter(function() {return $(this).text()!="";}).before('‡');
+ }
+
if( $('#wiki-history').length ){
var lookup = {};
$('img.identicon').each(function(index, element){
diff --git a/lib/gollum/public/gollum/stylesheets/app.scss b/lib/gollum/public/gollum/stylesheets/app.scss
index b650ae9f..78c716d1 100644
--- a/lib/gollum/public/gollum/stylesheets/app.scss
+++ b/lib/gollum/public/gollum/stylesheets/app.scss
@@ -1,4 +1,5 @@
//= require gollum
//= require editor
//= require dialog
+//= require criticmarkup
//= require template
\ No newline at end of file
diff --git a/lib/gollum/public/gollum/stylesheets/criticmarkup.scss b/lib/gollum/public/gollum/stylesheets/criticmarkup.scss
new file mode 100644
index 00000000..d376554e
--- /dev/null
+++ b/lib/gollum/public/gollum/stylesheets/criticmarkup.scss
@@ -0,0 +1,42 @@
+.criticmarkup mark {
+ background-color: #fffd38;
+ text-decoration: none;
+}
+
+.criticmarkup del {
+ background-color: #f6a9a9;
+ text-decoration: line-through;
+}
+.criticmarkup ins {
+ background-color: #a9f6a9;
+ text-decoration: none;
+}
+.criticmarkup ins.break {
+ display: block;
+ line-height: 2px;
+ padding: 0 !important;
+ margin: 0 !important;
+}
+.criticmarkup ins.break span {
+ line-height: 1.5em;
+}
+.criticmarkup .popover {
+ background-color: #fffd38;
+ color: #000;
+}
+.criticmarkup .critic.comment {
+ display: none;
+}
+
+.criticmarkup .popover:hover span.critic.comment {
+ display: block;
+ position: absolute;
+ width: 200px;
+ left: 30%;
+ font-size: 0.8em;
+ color: #ccc;
+ background-color: #333;
+ z-index: 10;
+ padding: 0.5em 1em;
+ border-radius: 0.5em;
+}
\ No newline at end of file
diff --git a/lib/gollum/public/gollum/stylesheets/editor.scss b/lib/gollum/public/gollum/stylesheets/editor.scss
index 0b543732..6a6ffe19 100644
--- a/lib/gollum/public/gollum/stylesheets/editor.scss
+++ b/lib/gollum/public/gollum/stylesheets/editor.scss
@@ -367,8 +367,8 @@ a#function-h2 { @include editor-button(9); }
a#function-h3 { @include editor-button(10); }
a#function-link { @include editor-button(11); }
a#function-image { @include editor-button(12); }
-a#function-plus { @include editor-button(13); }
-a#function-minus { @include editor-button(14); }
+a#function-critic-accept { @include editor-button(13); }
+a#function-critic-reject { @include editor-button(14); }
a#function-help { @include editor-button(15); }
a#function-search { @include editor-button(16); }
diff --git a/lib/gollum/templates/editor.mustache b/lib/gollum/templates/editor.mustache
index 7b3eead6..fbb4e0e7 100644
--- a/lib/gollum/templates/editor.mustache
+++ b/lib/gollum/templates/editor.mustache
@@ -49,6 +49,12 @@
Link
Image
+ {{#critic_markup}}
+
+ Accept Selected CriticMarkup
+
+ Reject Selected CriticMarkup
+ {{/critic_markup}}
Help
diff --git a/lib/gollum/templates/layout.mustache b/lib/gollum/templates/layout.mustache
index fca9fa18..d517772f 100644
--- a/lib/gollum/templates/layout.mustache
+++ b/lib/gollum/templates/layout.mustache
@@ -15,6 +15,7 @@
{{#sprockets_javascript_tag}}app{{/sprockets_javascript_tag}}
{{#use_identicon}}
diff --git a/lib/gollum/views/edit.rb b/lib/gollum/views/edit.rb
index 59b5a504..8c67fe51 100755
--- a/lib/gollum/views/edit.rb
+++ b/lib/gollum/views/edit.rb
@@ -60,6 +60,7 @@ module Precious
true
end
+
def allow_uploads
@allow_uploads
end
diff --git a/lib/gollum/views/layout.rb b/lib/gollum/views/layout.rb
index 60a6b0d1..efa2c80b 100644
--- a/lib/gollum/views/layout.rb
+++ b/lib/gollum/views/layout.rb
@@ -44,6 +44,10 @@ module Precious
@js
end
+ def critic_markup
+ @critic_markup
+ end
+
def per_page_uploads
@per_page_uploads
end