sibu 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb873b6f367548cd1ed892380324aa91d7170dc7
4
- data.tar.gz: 5fbde8f8df4299691bdb54029a052d511c449c06
3
+ metadata.gz: c0759366a72fa83ad3e5c5ed0288d0c9f2f3c180
4
+ data.tar.gz: d0d7497a1224778cbc8fc771d5e4ee864fab877f
5
5
  SHA512:
6
- metadata.gz: e87bd8dc5a6049765a16d27d790d0679079aea0eda72b393fb8ee36b1d04082c1857f0acd50c7a09285d719e22b998ac94b64d3acd360e7f641dc15bcbc00cc8
7
- data.tar.gz: 25ff74d7128e60d1943da3b3681243f28b81130820012ba324527fec958b432a4fbe58d4ff5ff306c378417575586e930641555c7f95be6bbd7a84cc742a610b
6
+ metadata.gz: ae3b4f04caf0fe037407dd5a37093373a0490c67e0f4c46e4b570a8fc7cb23551fd6d91d9e9a7737af1875ae4ddbac40bac1ba93105ad29fbaf84367790277b4
7
+ data.tar.gz: b7151b91df5c7ab7c04da668776175c5bc34ab03f7ab0fd486826b0ca9f9a0ec9be2c11914737e52a39855021d445abcb22eace1b831d56a6601e180e92f7d5c
@@ -1,4 +1,6 @@
1
1
  //= require jquery
2
2
  //= require jquery_ujs
3
- //= require tinymce-jquery
3
+ //= require trix
4
4
  //= require_self
5
+
6
+ Trix.config.blockAttributes.default.tagName = "div"
@@ -0,0 +1,21 @@
1
+ /*
2
+ *= require trix
3
+ *= require_self
4
+ */
5
+
6
+ sb-edit .sb-edit-active {
7
+ cursor: pointer;
8
+ }
9
+
10
+ #edit_panel {
11
+ position: fixed;
12
+ left: 0;
13
+ bottom: 0;
14
+ width: 100%;
15
+ display: none;
16
+ z-index: 1000;
17
+ }
18
+
19
+ .trix-button-group--block-tools {
20
+ display: none !important;
21
+ }
@@ -1,6 +1,8 @@
1
1
  module Sibu
2
2
  module PagesHelper
3
3
  include Sibu::Engine.routes.url_helpers
4
+ include TrixEditorHelper
5
+
4
6
 
5
7
  def link_path(page_id)
6
8
  p = @site.page_by_id(page_id)
@@ -34,13 +36,13 @@ module Sibu
34
36
  def site_section(id, &block)
35
37
  @sb_entity = @site
36
38
  @sb_section = id
37
- capture(self, &block)
39
+ "<sb-edit data-id='#{id}'>#{capture(self, &block)}</sb-edit>".html_safe
38
40
  end
39
41
 
40
42
  def section(id, &block)
41
43
  @sb_entity = @page
42
44
  @sb_section = id
43
- capture(self, &block)
45
+ "<sb-edit data-id='#{id}'>#{capture(self, &block)}</sb-edit>".html_safe
44
46
  end
45
47
 
46
48
  def each
@@ -42,15 +42,15 @@ module Sibu
42
42
  end
43
43
 
44
44
  def element(section_id, element_id)
45
- elt = section(section_id)[element_id]
45
+ elt = section(section_id).select {|e| e["id"] == element_id}.first
46
46
  elt || {}
47
47
  end
48
48
 
49
49
  def update_section(*ids, value)
50
50
  end
51
51
 
52
- # Note : only 2 levels supported for now
53
52
  def update_element(section_id, value)
53
+ sanitize_value(value)
54
54
  if self.sections[section_id].any? {|elt| elt["id"] == value["id"]}
55
55
  self.sections[section_id].map! {|elt| elt["id"] == value["id"] ? value : elt}
56
56
  else
@@ -58,5 +58,11 @@ module Sibu
58
58
  end
59
59
  value if save
60
60
  end
61
+
62
+ def sanitize_value(value)
63
+ unless value["text"].blank?
64
+ value["text"].gsub!(/<\/?(div|p|ul|li)>/, '')
65
+ end
66
+ end
61
67
  end
62
68
  end
@@ -12,7 +12,7 @@ module Sibu
12
12
  end
13
13
 
14
14
  def not_found
15
- "#{site_template.path}/not_found"
15
+ "shared/#{site_template.path}/not_found"
16
16
  end
17
17
 
18
18
  def page(path)
@@ -3,8 +3,8 @@
3
3
  <head>
4
4
  <title><%= conf[:title] %></title>
5
5
  <%= stylesheet_link_tag conf[:stylesheet], media: 'all' %>
6
- <%= javascript_include_tag conf[:javascript] %>
7
6
  <%= stylesheet_link_tag 'sibu/sibu', media: 'all' %>
7
+ <%= javascript_include_tag conf[:javascript] %>
8
8
  <%= javascript_include_tag 'sibu/sibu' %>
9
9
  <% if @site %>
10
10
  <%= stylesheet_link_tag @site.site_template.path, media: "all" %>
@@ -2,9 +2,7 @@
2
2
  <div id="edit_msg"></div>
3
3
  <div class="sibu_form">
4
4
  <%= form_tag(update_element_site_page_path(@site.id, @page.id), method: :patch, remote: true) do |f| %>
5
- <div class="sibu_field">
6
- <%= text_area_tag 'element[text]', '', class: 'tinymce' %>
7
- </div>
5
+ <%= trix_editor_tag 'element[text]', '', input: 'element_text' %>
8
6
  <%= hidden_field_tag 'element[id]', @element_id %>
9
7
  <%= hidden_field_tag :section_id, @section_id %>
10
8
  <%= hidden_field_tag :entity, @entity_type %>
@@ -1,12 +1,5 @@
1
1
  var editPanel = $("#edit_panel");
2
2
  editPanel.html("<%= j(render 'edit_panel') %>");
3
- editPanel.find("#element_text").val("<%= j(raw @entity.element(@section_id, @element_id)["text"]) %>");
3
+ var editorElt = editPanel.find("trix-editor")[0];
4
+ editorElt.editor.loadHTML("<%= raw(@entity.element(@section_id, @element_id)["text"].gsub("\n", "<br/>")) %>");
4
5
  editPanel.slideDown("fast");
5
- tinyMCE.remove();
6
- tinyMCE.init({
7
- selector: 'textarea.tinymce',
8
- branding: false,
9
- menubar: false,
10
- toolbar: 'bold italic underline alignleft aligncenter alignright alignjustify',
11
- forced_root_block : false
12
- });
data/lib/sibu/engine.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'tinymce-rails'
1
+ require 'trix'
2
2
 
3
3
  module Sibu
4
4
  class Engine < ::Rails::Engine
data/lib/sibu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sibu
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
data/lib/sibu.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require "sibu/engine"
2
2
 
3
3
  module Sibu
4
- # Your code goes here...
5
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sibu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Baptiste Vilain
@@ -58,42 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 4.3.1
61
+ version: '4.3'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 4.3.1
68
+ version: '4.3'
69
69
  - !ruby/object:Gem::Dependency
70
- name: tinymce-rails
70
+ name: trix
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 4.7.6
75
+ version: '0.11'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 4.7.6
83
- - !ruby/object:Gem::Dependency
84
- name: tinymce-rails-langs
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
82
+ version: '0.11'
97
83
  description: Sibu is an engine for Ruby on Rails that enables creation of static websites
98
84
  in a simple & wysiwyg way.
99
85
  email:
@@ -107,7 +93,7 @@ files:
107
93
  - Rakefile
108
94
  - app/assets/config/sibu_manifest.js
109
95
  - app/assets/javascripts/sibu/sibu.js.erb
110
- - app/assets/stylesheets/sibu/sibu.scss.erb
96
+ - app/assets/stylesheets/sibu/sibu.css
111
97
  - app/controllers/sibu/application_controller.rb
112
98
  - app/controllers/sibu/pages_controller.rb
113
99
  - app/controllers/sibu/sites_controller.rb
@@ -1,14 +0,0 @@
1
- sb-edit {
2
- .sb-edit-active {
3
- cursor: pointer;
4
- }
5
- }
6
-
7
- #edit_panel {
8
- position: fixed;
9
- left: 0;
10
- bottom: 0;
11
- width: 100%;
12
- display: none;
13
- z-index: 1000;
14
- }