burp_cms 1.3.8 → 1.3.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 69640b78009a3ef7f7ce44e6200c2d1e22b88fd5
4
+ data.tar.gz: 362bf1d918fcf70b7463e0a59a7d441ecbead81d
5
+ SHA512:
6
+ metadata.gz: 7bb555fbcfc93e2e20736a38177d625b03d944158e2a2265960f4821f3b6b1713066c6c2916831f685a14a41a8442d64ea6cc6acc0228b8615b5159e73b9a9c0
7
+ data.tar.gz: cb0fc29aa1944da612f0cb92042394965ebe23dc3c7f516d3bbee6baebf57b73361596ec07218aa28f1af97024e0ae25f8e492d0e95eb8d9a9d634dc0701b1e6
data/Rakefile CHANGED
@@ -19,7 +19,7 @@ require 'burp/version'
19
19
  Jeweler::Tasks.new do |gem|
20
20
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
21
21
  gem.name = "burp_cms"
22
- # gem.homepage = "http://github.com/bjornblomqvist/burp"
22
+ gem.homepage = "http://github.com/bjornblomqvist/burp"
23
23
  gem.license = "LGPL3"
24
24
  gem.summary = %Q{ A CMS that tryes hard to not get in your way! }
25
25
  gem.description = %Q{ A CMS that tryes hard to not get in your way! }
@@ -1,5 +1,5 @@
1
1
  /*global
2
- marked MD5
2
+ marked
3
3
  */
4
4
  (function($) {
5
5
 
@@ -17,7 +17,6 @@
17
17
 
18
18
  function ContentDecorator(element, options) {
19
19
  this.element = $(element);
20
- this.parking = $('<div style="display: none;"></div>');
21
20
 
22
21
  if (typeof(options) === 'object') {
23
22
  this.onUpdate = options['update'];
@@ -166,6 +165,7 @@
166
165
  }
167
166
 
168
167
  $("#gallery").removeClass('delete-active');
168
+ $(document).trigger("image-drop-done.burp");
169
169
  }
170
170
  });
171
171
 
@@ -283,10 +283,14 @@
283
283
  }
284
284
  });
285
285
 
286
- $(this.element).park('.movable');
287
286
  this.element.html("");
288
287
  this.element.append(tempElement.children());
289
- $(this.element).unpark();
288
+
289
+ initializeMovable(this, this.element.find('img'), function(element, positionClass) {
290
+ $(element).removeClass('left center right');
291
+ $(element).addClass(positionClass);
292
+ return element;
293
+ });
290
294
  },
291
295
 
292
296
  makeDroppable: function(elements, createCallback) {
@@ -0,0 +1,106 @@
1
+
2
+ function getAfterPadding(element,padding) {
3
+ var next = $(element).get(0).nextSibling;
4
+ if(!next) {
5
+ padding = "";
6
+ } else if(next.nodeType === 3) {
7
+ if(next.data.match(/^(\t| )*\n(\t| )*\n/)) {
8
+ padding = "";
9
+ } else if(next.data.match(/^(\t| )*\n/) && padding.length > 1) {
10
+ padding = "\n";
11
+ }
12
+ }
13
+ return padding;
14
+ }
15
+
16
+ function getBeforePadding(element,padding) {
17
+ var previous = $(element).get(0).previousSibling;
18
+ if(!previous) {
19
+ padding = "";
20
+ } else if(previous.nodeType === 3) {
21
+ if(previous.data.match(/\n(\t| )*\n(\t| )*$/)) {
22
+ padding = "";
23
+ } else if(previous.data.match(/\n(\t| )*$/) && padding.length > 1) {
24
+ padding = "\n";
25
+ }
26
+ }
27
+ return padding;
28
+ }
29
+
30
+ function Html2Markdown(value) {
31
+ var dom = $("<div id=\"root\"></div>");
32
+ dom.append(value);
33
+
34
+ dom.find("> hr").each(function() {
35
+ $(this).replaceWith("---");
36
+ });
37
+
38
+ dom.find("em > strong").each(function() {
39
+ $(this).replaceWith("**"+$(this).html()+"**");
40
+ });
41
+
42
+ dom.find("> p > em, > em, > ul > li > em").each(function() {
43
+ $(this).replaceWith("_"+$(this).html()+"_");
44
+ });
45
+
46
+
47
+
48
+ dom.find("> strong, > p > strong, > ul > li > strong").each(function() {
49
+ $(this).replaceWith("**"+$(this).html()+"**");
50
+ });
51
+
52
+ dom.find("> p, blockquote > p").each(function() {
53
+ if($(this).get(0).attributes.length === 0) {
54
+ $(this).replaceWith(getBeforePadding(this,"\n\n")+$(this).html()+getAfterPadding(this,"\n\n"));
55
+ }
56
+ });
57
+
58
+ dom.find("ul").each(function() {
59
+ $(this).find('li').each(function() {
60
+ $(this).replaceWith("- "+$(this).html()+getAfterPadding(this,"\n"));
61
+ });
62
+ $(this).replaceWith(getBeforePadding(this,"\n\n")+$(this).html());
63
+ });
64
+
65
+ dom.find("ol").each(function() {
66
+ $(this).find('li').each(function(index,value) {
67
+ $(this).replaceWith((index+1)+". "+$(this).html()+getAfterPadding(this,"\n"));
68
+ });
69
+ $(this).replaceWith(getBeforePadding(this,"\n\n")+$(this).html());
70
+ });
71
+
72
+ dom.find('blockquote').each(function() {
73
+ $(this).replaceWith("> "+$.trim($(this).html()).replace(/\n{2,20}/g,"\n\n").replace(/\n/g,'\n> ').replace(/> \n/g,">\n"));
74
+ });
75
+
76
+ $.each(["h1",'h2','h3','h4','h5'],function(index,value) {
77
+
78
+ var hashes = "";
79
+ var i = 0;
80
+ for(; i <= index;i++) {
81
+ hashes += "#";
82
+ }
83
+
84
+ dom.find("> "+value).each(function() {
85
+
86
+ if($(this).get(0).attributes.length === 0) {
87
+ $(this).find("> strong").each(function() {
88
+ $(this).replaceWith("**"+$(this).html()+"**");
89
+ });
90
+
91
+ $(this).find("> em").each(function() {
92
+ $(this).replaceWith("_"+$(this).html()+"_");
93
+ });
94
+
95
+ var newLine = "\n\n";
96
+ if($(this).next().length === 0) {
97
+ newLine = "";
98
+ }
99
+
100
+ $(this).replaceWith(getBeforePadding(this,"\n\n")+hashes+" "+$.trim($(this).html()) + newLine);
101
+ }
102
+ });
103
+ });
104
+
105
+ return dom.html().replace(/^&gt;/mg,'>').replace(/^&lt;/mg,'<').replace(/\n{2,20}/g,"\n\n");
106
+ }
@@ -1,5 +1,5 @@
1
1
  /*global
2
- snippets CodeMirror ContentDecorator qq
2
+ snippets CodeMirror ContentDecorator qq Html2Markdown
3
3
  */
4
4
 
5
5
  $(function() {
@@ -51,36 +51,37 @@ $(function() {
51
51
  }
52
52
  }
53
53
 
54
+ function loadHTML() {
55
+
56
+ var element = snippets().snippets[snippetName].elements().clone();
57
+ element.find('.markdown').each(function() {
58
+ $(this).removeClass('markdown');
59
+ if($(this).attr('class') === "") {
60
+ $(this).removeAttr('class');
61
+ }
62
+ });
63
+
64
+ element.find('script[type="text/dont-run-javascript"]').each(function() {
65
+ $(this).attr("type",'text/javascript');
66
+ });
67
+
68
+ element.find('img.movable').each(function() {
69
+ $(this).removeClass('movable ui-draggable ui-droppable');
70
+ });
71
+
72
+ editor.setValue(Html2Markdown(element.children()));
73
+ }
74
+
54
75
  function loadSnippet() {
55
76
  var path = window.burp_path || window.location.pathname;
56
77
  if(path === "/") {
57
78
  path = "/$root";
58
79
  }
59
-
60
- $.ajax("/burp/pages/"+path,{
61
- cache:false,
62
- dataType:'json',
63
- success:function(data) {
64
- if(data === null) {
65
- // No page yet so our code needs a bit help
66
- data = {};
67
- }
68
-
69
- // We default to the html
70
- var value = originalHtml;
71
- if(data.misc && data.misc.markdown && data.misc.markdown[snippetName]) {
72
- value = data.misc.markdown[snippetName];
73
- } else if(data.snippets[snippetName]) {
74
- value = data.snippets[snippetName];
75
- }
76
-
77
- originalValue = value;
78
- editor.setValue(value);
79
- editor.clearHistory();
80
-
81
- update(editor.getValue());
82
- }
83
- });
80
+
81
+ loadHTML();
82
+ editor.clearHistory();
83
+ update(editor.getValue());
84
+ originalValue = editor.getValue();
84
85
  }
85
86
 
86
87
  function loadFiles() {
@@ -176,8 +177,15 @@ $(function() {
176
177
  $.adminDock.title('');
177
178
  $.adminDock.footer.addButton({ icon: 'picture', text: "Pictures", showModule: $('#gallery') });
178
179
  $.adminDock.footer.addButton({ icon: 'edit', text: "Edit text", showModule: $('#myContentEditor'), show: function() {
180
+ loadHTML();
179
181
  editor.refresh();
180
182
  } });
183
+
184
+
185
+ $(document).on('image-drop-done.burp', function() {
186
+ loadHTML();
187
+ editor.refresh();
188
+ });
181
189
 
182
190
  var snippet_names = [];
183
191
  $.each(snippets().snippets,function(name,snippet) {
@@ -255,8 +263,6 @@ $(function() {
255
263
  data = data || {snippets:{}};
256
264
 
257
265
  data.snippets[snippetName] = contentDecorator.getHtml();
258
- data.misc = data.misc || {markdown:{}};
259
- data.misc.markdown[snippetName] = contentDecorator.getMarkdown();
260
266
 
261
267
  $.ajax("/burp/pages/"+path,{
262
268
  type:"post",
@@ -4,9 +4,8 @@
4
4
  //= require jquery.ui.droppable
5
5
  //= require ../gritter/gritter.js
6
6
  //= require ../../javascripts/burp/lib/fileupload.js
7
- //= require ./editing/js/md5.js
8
7
  //= require ./editing/js/marked.js
9
- //= require ./editing/js/stay.js
8
+ //= require ./editing/js/jquery.html2markdown.js
10
9
  //= require ./editing/js/admin-dock.js
11
10
  //= require ./editing/js/content-decorator.js
12
11
  //= require ./editing/dep/CodeMirror-2.3/lib/codemirror.js
@@ -77,7 +77,6 @@ module Burp
77
77
 
78
78
  @page.title = params[:page][:title] if params[:page][:title]
79
79
  @page.path = params[:page][:path] if params[:page][:path]
80
- @page.misc = params[:page][:misc] if params[:page][:misc]
81
80
 
82
81
  if params[:page][:snippets]
83
82
  @page.snippets = {}
@@ -8,7 +8,7 @@ module Burp
8
8
  include ActiveModel::Conversion
9
9
  extend ActiveModel::Naming
10
10
 
11
- attr_accessor :path, :title, :snippets, :misc
11
+ attr_accessor :path, :title, :snippets
12
12
 
13
13
  validates_presence_of :path, :message => "You must enter a path"
14
14
  validates :path, :format => { :with => /^\//, :message => "Must start with a slash" }
@@ -49,7 +49,7 @@ module Burp
49
49
 
50
50
  page_data = File.exist?("#{on_disk_path}/page.json") ? JSON.parse(File.read("#{on_disk_path}/page.json")) : {}
51
51
 
52
- PageModel.new(:snippets => data,:title => page_data['title'],:misc => page_data['misc'],:path => path, :original_path => path)
52
+ PageModel.new(:snippets => data,:title => page_data['title'], :path => path, :original_path => path)
53
53
  else
54
54
  nil
55
55
  end
@@ -110,7 +110,7 @@ module Burp
110
110
  def save_metadata
111
111
 
112
112
  File.open("#{on_disk_path}/page.json","w:utf-8") do |file|
113
- file.write(JSON.pretty_generate({:title => title,:misc => misc}))
113
+ file.write(JSON.pretty_generate({:title => title}))
114
114
  end
115
115
 
116
116
  end
data/config/cucumber.yml CHANGED
@@ -3,10 +3,10 @@ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
3
  rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
4
  std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --color --tags ~@wip"
5
5
  %>
6
- default: --drb --port 4012 <%= std_opts %> features --guess -r ./features
7
- pretty: --drb --color --port 4012 features --guess -r ./features
8
- wip: --drb --port 4012 --color --tags @wip --wip features --guess -r ./features
6
+ default: --port 4012 <%= std_opts %> features --guess -r ./features
7
+ pretty: --color --port 4012 features --guess -r ./features
8
+ wip: --port 4012 --color --tags @wip --wip features --guess -r ./features
9
9
  rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip --guess -r ./features
10
- autotest: --color --drb --port 4012 --format pretty --guess -r ./features
11
- autotest-all: --color --format pretty --tags @auto --drb --port 4012 --guess -r ./features
12
- current: --drb --port 4012 --tags @current --guess -r ./features --format pretty --strict
10
+ autotest: --color --port 4012 --format pretty --guess -r ./features
11
+ autotest-all: --color --format pretty --tags @auto --port 4012 --guess -r ./features
12
+ current: --port 4012 --tags @current --guess -r ./features --format pretty --strict
data/lib/burp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Burp
2
- VERSION = "1.3.8"
2
+ VERSION = "1.3.9"
3
3
  end