sibu 1.0.0 → 1.0.1

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: e6eb3cad54639de1385e45c0465b10aabeb58612
4
- data.tar.gz: 456b3d03e871ddf4d74efec50ac7439361843591
3
+ metadata.gz: 6916799ff35b88c15850f4911c93517a43e8ba1f
4
+ data.tar.gz: ef515f1129ed26fdf3f156794e79ac402a37011d
5
5
  SHA512:
6
- metadata.gz: 6ac41267562d922d72f7b6d61fc70a9adf039b53b6f2b23fdb611e7630667545831a1fb7d337aa65fdde806d32612cc0f32261b8147d26332966f4e4d1749c19
7
- data.tar.gz: c8bd6917787c516117e671d09ebe3a57c4fd402f28dfbe2b6065260cc57d54c561b0016b478e71ce33dd6bb56764a049bec7492e507a0debb2934407f03c9632
6
+ metadata.gz: 471eee1cd3b1388651e1771f65396748f48a5e59826552fda85588373cbd2e8df68fa6d0b0a99f6c33f43b0291cba853dd36ded178aa3ec6f2dadd510d968095
7
+ data.tar.gz: 913ed58b8942eb16f66b492536e7466927835ff9be32523335c3ec13dc3a1898d0f81aeeedbfda4eb6e38e41ef7a6491f698b5dccc1e334fb12fc160e255faf9
data/README.md CHANGED
@@ -1,9 +1,13 @@
1
- # Sibu - A site builder engine for Ruby on Rails
2
- This is an engine for Ruby on Rails that enables creation of static
3
- websites in a simple & wysiwyg way.
1
+ # Sibu
2
+ Sibu is an engine to build websites. It focuses on :
3
+ - Maintaining a simple data model, so it can be exported & imported in many formats
4
+ - Increasing the productivity of web developers by using a Domain Specific Language for page edition
5
+ - Providing non-technical users with a simple and accessible site administration interface
4
6
 
5
7
  ## Usage
6
- How to use my plugin.
8
+ Sibu is currently implemented as a Ruby on Rails engine. Therefore its setup requires a host Ruby on Rails application, that can be created via :
9
+
10
+ `rails new my_app`
7
11
 
8
12
  ## Installation
9
13
  Add this line to your application's Gemfile:
@@ -22,6 +26,79 @@ Or install it yourself as:
22
26
  $ gem install sibu
23
27
  ```
24
28
 
29
+ Once the installation is complete, make sure that you copy the database migrations to your application :
30
+ ```bash
31
+ rake sibu:install:migrations
32
+ ```
33
+
34
+ And finally run the migrations to update your database model :
35
+ ```bash
36
+ rake db:migrate
37
+ ```
38
+
39
+ ## Configuration
40
+ Configuration is provided via the `sibu` key of the Rails application configuration. Typically, this would be done in a `sibu.rb` file in the `config/initializers` folder of your Rails application.
41
+ The example below lists the configuration options available :
42
+ ```ruby
43
+ Rails.application.config.sibu = {
44
+
45
+ # Title metatag of the admin interface
46
+ title: 'My website administration',
47
+
48
+ # Stylesheet to use to style the admin interface
49
+ stylesheet: 'my_user_css',
50
+
51
+ # Javascript to include in the admin interface
52
+ javascript: 'my_user_js',
53
+
54
+ # Path to the admin interface header partial
55
+ top_panel: 'shared/user/top_panel',
56
+
57
+ # Path to the main content edition partial - must include a yield to delegate content display to the Sibu engine
58
+ content_panel: 'shared/user/content_panel',
59
+
60
+ # Path to the admin interface footer partial
61
+ bottom_panel: 'shared/user/bottom_panel',
62
+
63
+ # Name of the method that will be used to authenticate admin users - this method must be available to Sibu controllers
64
+ auth_filter: :authenticate_user!,
65
+
66
+ # Name of the method that will retrieve the current user - this method must be available to Sibu controllers
67
+ current_user: 'current_user',
68
+
69
+ # A flag to indicate that the Sibu instance should offer a separate environment for each user
70
+ multi_user: true,
71
+
72
+ # A proc to identify super-admin users in a multi-users setup (optional)
73
+ admin_filter: Proc.new {|usr| usr.is_admin},
74
+
75
+ # When active, users will be able to override the colors and fonts of the sites templates (optional)
76
+ custom_styles: true,
77
+
78
+ # Lists of colors and fonts available for sites templates customization - Only used when custom_styles is set to true (optional)
79
+ primary_colors: ['#23527c', '#00B1BF', '#BECD00'],
80
+ secondary_colors: ['#E2007A', '#aaaaa1', '#be6432'],
81
+ primary_fonts: ['Intro', 'Lato', 'SourceSansPro'],
82
+ secondary_fonts: ['Aleo', 'Bodoni', 'Cinzel'],
83
+
84
+ # The domain name that will host the admin interface (should be different from the website domain name)
85
+ host: 'localhost',
86
+
87
+ # A partial for 404 error pages
88
+ not_found: 'shared/templates/not_found',
89
+
90
+ # Dimensions of the images to use in the website - Uploaded images will be automatically resized in the provided formats
91
+ images: {large: 1600, medium: 800, small: 320},
92
+
93
+ # Versions available for the created websites
94
+ versions: [['Français', 'fr'], ['Anglais', 'en']],
95
+
96
+ # A proc to override the default ordering of the sections when editing content (optional)
97
+ sections_ordering: Proc.new {|sections| sections.sort_by {|s| SECTIONS_TABS.index(s['category'])}}
98
+ }
99
+ ```
100
+
101
+
25
102
  ## Improvements
26
103
  - Use a specific controller & helper for site display
27
104
  - Move page templates to SiteTemplate model
@@ -35,29 +35,53 @@ module Sibu
35
35
  end
36
36
  end
37
37
 
38
- [:h1, :h2, :h3, :h4, :h5, :h6, :span].each do |t|
39
- define_method(t) do |elt, html_opts = {}, &block|
40
- defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "text" => Sibu::DEFAULT_TEXT}
38
+ [:h1, :h2, :h3, :h4, :h5, :h6, :span, :p, :li].each do |t|
39
+ define_method(t) do |elt, opts = {}, &block|
40
+ t_id = elt.is_a?(Hash) ? elt["id"] : elt
41
+ defaults = {"id" => t_id, "text" => (t == :p ? Sibu::DEFAULT_PARAGRAPH : Sibu::DEFAULT_TEXT)}
41
42
  content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
42
- html_opts.merge!({data: {id: elt_id(elt), type: "text"}}) if action_name != 'show'
43
+ html_opts = {"id" => t_id}.merge(opts.except(:repeat, :children).stringify_keys)
44
+ @sb_section = (@sb_section || []) + [t_id]
45
+ if action_name != 'show'
46
+ html_opts.merge!({
47
+ "data-id" => @sb_section[1..-1].join('|'),
48
+ "data-type" => (t == :p ? "paragraph" : "text"),
49
+ "data-repeat" => opts.delete(:repeat),
50
+ "data-children" => opts.delete(:children)
51
+ })
52
+ end
43
53
  if block
44
- @sb_section = (@sb_section || []) + [elt_id(elt)]
45
- html_output = content_tag(t, capture(content, nested_elements(elt), &block), html_opts)
46
- @sb_section -= [elt_id(elt)]
47
- html_output
54
+ if t == :p
55
+ html_output = content_tag(:div, content_tag(t, capture(content, nested_elements(elt), &block)), html_opts)
56
+ else
57
+ html_output = content_tag(t, capture(content, nested_elements(t_id), &block), html_opts)
58
+ end
48
59
  else
49
- content_tag(t, raw(content["text"]).html_safe, html_opts)
60
+ if t == :p
61
+ html_output = content_tag(:div, content_tag(t, raw(content["text"]).html_safe, html_opts), html_opts)
62
+ else
63
+ html_output = content_tag(t, raw(content["text"]).html_safe, html_opts)
64
+ end
50
65
  end
66
+ @sb_section -= [t_id]
67
+ html_output
51
68
  end
52
69
  end
53
70
 
54
- [:div, :section, :article, :aside, :header, :footer, :nav, :main, :ul].each do |t|
55
- define_method(t) do |elt, html_opts = {}, &block|
71
+ [:div, :section, :article, :aside, :header, :footer, :nav, :main, :ul, :ol, :wrapper].each do |t|
72
+ define_method(t) do |elt, opts = {}, &block|
56
73
  t_id = elt.is_a?(Hash) ? elt["id"] : elt
57
74
  @sb_section = (@sb_section || []) + [t_id]
58
- html_opts = {"id" => t_id}.merge(html_opts)
59
- html_opts.merge!(@sb_section.length == 1 ? {"data-sb-id" => t_id, "data-sb-entity" => @sb_entity == @site ? 'site' : 'page'} : {"data-id" => elt_id(elt), "data-type" => "group", "data-repeat" => false, "data-children" => false}) if action_name != 'show'
60
- html_output = content_tag(t, capture(current_elt(elt), nested_elements(t_id), &block), html_opts)
75
+ html_opts = {"id" => t_id}.merge(opts.except(:repeat, :children).stringify_keys)
76
+ if action_name != 'show'
77
+ html_opts.merge!({
78
+ "data-id" => @sb_section[1..-1].join('|'),
79
+ "data-type" => "group",
80
+ "data-repeat" => opts.delete(:repeat),
81
+ "data-children" => opts.delete(:children)
82
+ })
83
+ end
84
+ html_output = t == :wrapper ? capture(current_elt(elt), nested_elements(t_id), &block) : content_tag(t, capture(current_elt(elt), nested_elements(t_id), &block), html_opts)
61
85
  @sb_section -= [t_id]
62
86
  html_output
63
87
  end
@@ -88,14 +112,6 @@ module Sibu
88
112
  items.blank? ? [{"id" => "el#{Time.current.to_i}"}] : items
89
113
  end
90
114
 
91
- def p(elt, opts = {})
92
- repeat = opts.delete(:repeat)
93
- defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "text" => Sibu::DEFAULT_PARAGRAPH}
94
- content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
95
- opts.merge!({data: {id: elt_id(elt), repeat: repeat, type: "paragraph"}}) if action_name != 'show'
96
- content_tag(:div, content_tag(:p, raw(content["text"]).html_safe), opts)
97
- end
98
-
99
115
  def img(elt, opts = {})
100
116
  wrapper = opts.delete(:wrapper)
101
117
  repeat = opts.delete(:repeat)
@@ -212,7 +212,7 @@
212
212
  function initInnerOverlays(section) {
213
213
  var editables = section.querySelectorAll("[data-type]");
214
214
  for (var i = 0; i < editables.length; i++) {
215
- if (editables[i].getAttribute("data-type") !== 'group' || editables[i].getAttribute("data-repeat") !== 'false' || editables[i].getAttribute("data-children") !== 'false') {
215
+ if (editables[i].getAttribute("data-type") !== 'group' || editables[i].getAttribute("data-repeat") === 'true' || editables[i].getAttribute("data-children") === 'true') {
216
216
  editables[i].addEventListener("mouseenter", function(evt) {
217
217
  evt.stopPropagation();
218
218
  evt.currentTarget.classList.add("sb-editable");
@@ -233,27 +233,29 @@
233
233
  }
234
234
 
235
235
  function initOverlays() {
236
- var container = document.querySelector("#edit_overlays"), sections = document.querySelectorAll("[data-sb-id]");
237
- container.innerHTML = "";
236
+ setTimeout(function() {
237
+ var container = document.querySelector("#edit_overlays"), sections = document.querySelectorAll("[data-sb-id]");
238
+ container.innerHTML = "";
238
239
 
239
- for (var i = 0; i < sections.length; i++) {
240
- var sectionBox = sections[i].getBoundingClientRect();
241
- var yOffset = sectionBox.top - document.querySelector(".sibu_content_panel").getBoundingClientRect().top;
242
- var width = sections[i].offsetWidth, height = (sections[i].offsetHeight === 0 ? childrenHeight(sections[i]) : sections[i].offsetHeight);
243
- var overlay = document.createElement("div");
244
- overlay.setAttribute("data-sb-overlay", sections[i].getAttribute("data-sb-id"));
245
- overlay.innerHTML = "Modifier";
246
- container.appendChild(overlay);
247
- overlay.style.top = yOffset + "px";
248
- overlay.style.left = sectionBox.left + "px";
249
- overlay.style.width = width + "px";
250
- overlay.style.height = height + "px";
251
- overlay.addEventListener("click", (function(section, offsetLeft, offsetTop, editWidth, editHeight) {
252
- return function(evt) {
253
- setEditMode(section, evt.currentTarget, offsetLeft, offsetTop, editWidth, editHeight);
254
- };
255
- })(sections[i], sectionBox.left, yOffset, width, height));
256
- }
240
+ for (var i = 0; i < sections.length; i++) {
241
+ var sectionBox = sections[i].getBoundingClientRect();
242
+ var yOffset = sectionBox.top - document.querySelector(".sibu_content_panel").getBoundingClientRect().top;
243
+ var width = sections[i].offsetWidth, height = (sections[i].offsetHeight === 0 ? childrenHeight(sections[i]) : sections[i].offsetHeight);
244
+ var overlay = document.createElement("div");
245
+ overlay.setAttribute("data-sb-overlay", sections[i].getAttribute("data-sb-id"));
246
+ overlay.innerHTML = "Modifier";
247
+ container.appendChild(overlay);
248
+ overlay.style.top = yOffset + "px";
249
+ overlay.style.left = sectionBox.left + "px";
250
+ overlay.style.width = width + "px";
251
+ overlay.style.height = height + "px";
252
+ overlay.addEventListener("click", (function(section, offsetLeft, offsetTop, editWidth, editHeight) {
253
+ return function(evt) {
254
+ setEditMode(section, evt.currentTarget, offsetLeft, offsetTop, editWidth, editHeight);
255
+ };
256
+ })(sections[i], sectionBox.left, yOffset, width, height));
257
+ }
258
+ }, 800);
257
259
  }
258
260
 
259
261
  function childrenHeight(parentElt) {
data/lib/sibu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sibu
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sibu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Baptiste Vilain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-27 00:00:00.000000000 Z
11
+ date: 2020-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails