sibu 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/sibu/sibu.css +64 -1
- data/app/controllers/sibu/images_controller.rb +47 -0
- data/app/controllers/sibu/pages_controller.rb +7 -4
- data/app/controllers/sibu/sites_controller.rb +1 -1
- data/app/helpers/sibu/images_helper.rb +4 -0
- data/app/helpers/sibu/pages_helper.rb +55 -20
- data/app/models/concerns/sibu/image_uploader.rb +26 -2
- data/app/models/concerns/sibu/sections_concern.rb +11 -9
- data/app/models/sibu/image.rb +2 -0
- data/app/models/sibu/site.rb +10 -7
- data/app/models/sibu/site_template.rb +2 -0
- data/app/views/layouts/sibu/edit_content.html.erb +98 -45
- data/app/views/sibu/images/_form.html.erb +11 -0
- data/app/views/sibu/images/edit.html.erb +2 -0
- data/app/views/sibu/images/index.html.erb +10 -0
- data/app/views/sibu/images/new.html.erb +9 -0
- data/app/views/sibu/images/show.html.erb +2 -0
- data/app/views/sibu/pages/_link_edit_panel.html.erb +22 -0
- data/app/views/sibu/pages/_media_edit_panel.html.erb +25 -0
- data/app/views/sibu/pages/{_edit_panel.html.erb → _text_edit_panel.html.erb} +3 -3
- data/app/views/sibu/pages/edit_element.js.erb +16 -3
- data/app/views/sibu/pages/update_element.js.erb +9 -1
- data/config/initializers/shrine.rb +2 -2
- data/config/routes.rb +2 -0
- data/db/migrate/20180208082317_rename_images_user_id_to_site_id.rb +5 -0
- data/db/migrate/20180208125024_rename_image_data_column.rb +5 -0
- data/db/migrate/20180210181644_add_defaults_to_site_templates.rb +6 -0
- data/lib/sibu/engine.rb +1 -0
- data/lib/sibu/version.rb +1 -1
- metadata +43 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d01668ddff9c00c0ff68dcd8334ccab00b95a24
|
4
|
+
data.tar.gz: 1e78b2109e6a725646fe51c0e20e02630118d29f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fe91b0963e43c828f0011536d81e165fadb46f774948b372f0f7d68c41ee1a5b4e0a86531f7e3300a8ae47de2166c803d0ee850c24f8ea4c5bca63b0d26a6b4
|
7
|
+
data.tar.gz: 4256d29e8642ce55a1577580fa013726f7326d9deb227bb042b492b9762a907e85db707423443caf452858c96dc9d809a635047ec0a930fcf9dbe3a2cf70ed3f
|
@@ -3,8 +3,70 @@
|
|
3
3
|
*= require_self
|
4
4
|
*/
|
5
5
|
|
6
|
-
|
6
|
+
.sibu_content_panel {
|
7
|
+
position: relative
|
8
|
+
}
|
9
|
+
|
10
|
+
sb-edit {
|
11
|
+
position: relative;
|
12
|
+
}
|
13
|
+
|
14
|
+
sb-edit div.sb-overlay {
|
15
|
+
position: absolute;
|
16
|
+
z-index: 999;
|
17
|
+
opacity: 0;
|
18
|
+
background-color: rgba(0, 0, 0, 0.5);
|
19
|
+
cursor: pointer;
|
20
|
+
top: 0;
|
21
|
+
left: 0;
|
22
|
+
}
|
23
|
+
|
24
|
+
sb-edit div.sb-overlay a {
|
25
|
+
display: inline-block;
|
26
|
+
width: 100%;
|
27
|
+
height: 100%;
|
28
|
+
}
|
29
|
+
|
30
|
+
sb-edit .sb-editable {
|
7
31
|
cursor: pointer;
|
32
|
+
outline: dashed rgba(94, 219, 255, 0.8) 2px;
|
33
|
+
outline-offset: -3px;
|
34
|
+
}
|
35
|
+
|
36
|
+
#edit_mode_overlay {
|
37
|
+
display: none;
|
38
|
+
}
|
39
|
+
|
40
|
+
#edit_mode_overlay > div {
|
41
|
+
position: absolute;
|
42
|
+
z-index: 999;
|
43
|
+
}
|
44
|
+
|
45
|
+
#edit_mode_overlay .overlay_top,
|
46
|
+
#edit_mode_overlay .overlay_bottom,
|
47
|
+
#edit_mode_overlay .overlay_left,
|
48
|
+
#edit_mode_overlay .overlay_right {
|
49
|
+
background-color: rgba(94, 219, 255, 0.5);
|
50
|
+
}
|
51
|
+
|
52
|
+
#edit_mode_overlay > .overlay_top {
|
53
|
+
top: 0;
|
54
|
+
left: 0;
|
55
|
+
width: 100%;
|
56
|
+
}
|
57
|
+
|
58
|
+
#edit_mode_overlay > .overlay_bottom {
|
59
|
+
bottom: 0;
|
60
|
+
left: 0;
|
61
|
+
width: 100%;
|
62
|
+
}
|
63
|
+
|
64
|
+
#edit_mode_overlay > .overlay_left {
|
65
|
+
left: 0;
|
66
|
+
}
|
67
|
+
|
68
|
+
#edit_mode_overlay > .overlay_right {
|
69
|
+
right: 0;
|
8
70
|
}
|
9
71
|
|
10
72
|
#edit_panel {
|
@@ -14,6 +76,7 @@ sb-edit .sb-edit-active {
|
|
14
76
|
width: 100%;
|
15
77
|
display: none;
|
16
78
|
z-index: 1000;
|
79
|
+
background-color: white;
|
17
80
|
}
|
18
81
|
|
19
82
|
.trix-button-group--block-tools {
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require_dependency "sibu/application_controller"
|
2
|
+
|
3
|
+
module Sibu
|
4
|
+
class ImagesController < ApplicationController
|
5
|
+
before_action :set_site, only: [:index, :new]
|
6
|
+
|
7
|
+
def index
|
8
|
+
@images = Sibu::Image.where(site_id: params[:site_id])
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
@image = Sibu::Image.new(site_id: @site.id)
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
@image = Sibu::Image.new(image_params)
|
17
|
+
if @image.save
|
18
|
+
redirect_to site_images_url(@image.site_id), notice: "L'image a bien été téléchargée."
|
19
|
+
else
|
20
|
+
flash.now[:alert] = "Une erreur s'est produite lors du téléchargement de l'image."
|
21
|
+
render :new
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def show
|
26
|
+
end
|
27
|
+
|
28
|
+
def edit
|
29
|
+
end
|
30
|
+
|
31
|
+
def updateé
|
32
|
+
end
|
33
|
+
|
34
|
+
def destroy
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def set_site
|
40
|
+
@site = Sibu::Site.find(params[:site_id])
|
41
|
+
end
|
42
|
+
|
43
|
+
def image_params
|
44
|
+
params.require(:image).permit!
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -16,7 +16,7 @@ module Sibu
|
|
16
16
|
@site = Sibu::Site.find_by_domain(request.domain)
|
17
17
|
if @site
|
18
18
|
@page = @site.page(params[:path])
|
19
|
-
@links = @site.
|
19
|
+
@links = @site.pages_path_by_id
|
20
20
|
view_template = @page ? 'show' : @site.not_found
|
21
21
|
else
|
22
22
|
view_template = Rails.application.config.sibu[:not_found]
|
@@ -24,7 +24,7 @@ module Sibu
|
|
24
24
|
else
|
25
25
|
@site = Sibu::Site.find(params[:site_id])
|
26
26
|
@page = Sibu::Page.find(params[:id])
|
27
|
-
@links = @site.
|
27
|
+
@links = @site.pages_path_by_id
|
28
28
|
view_template = 'show'
|
29
29
|
end
|
30
30
|
|
@@ -38,7 +38,7 @@ module Sibu
|
|
38
38
|
def create
|
39
39
|
@page = Sibu::Page.new(page_params)
|
40
40
|
if @page.save
|
41
|
-
redirect_to site_pages_url(@page.site_id), "La page a bien été créée."
|
41
|
+
redirect_to site_pages_url(@page.site_id), notice: "La page a bien été créée."
|
42
42
|
else
|
43
43
|
flash.now[:alert] = "Une erreur s'est produite lors de la création de la page."
|
44
44
|
render :new
|
@@ -63,11 +63,14 @@ module Sibu
|
|
63
63
|
def edit_content
|
64
64
|
@page = Sibu::Page.find(params[:page_id])
|
65
65
|
@site = Sibu::Site.includes(:pages).find(@page.site_id) if @page
|
66
|
-
@links = @site.
|
66
|
+
@links = @site.pages_path_by_id if @site
|
67
67
|
render :edit_content, layout: 'sibu/edit_content'
|
68
68
|
end
|
69
69
|
|
70
70
|
def edit_element
|
71
|
+
@content_type = params[:content_type]
|
72
|
+
@links = @site.pages_path_by_id if @site
|
73
|
+
@element = @entity.element(@section_id, @element_id)
|
71
74
|
end
|
72
75
|
|
73
76
|
def update_element
|
@@ -20,7 +20,7 @@ module Sibu
|
|
20
20
|
|
21
21
|
def create
|
22
22
|
@site = Sibu::Site.new(site_params)
|
23
|
-
if @site.save_and_init
|
23
|
+
if @site.save_and_init
|
24
24
|
redirect_to sites_url, notice: "Le site a bien été créé."
|
25
25
|
else
|
26
26
|
flash.now[:alert] = "Une erreur s'est produite lors de la création du site."
|
@@ -18,9 +18,10 @@ module Sibu
|
|
18
18
|
end
|
19
19
|
|
20
20
|
[:h1, :h2, :h3, :h4, :h5, :h6, :p, :span, :div].each do |t|
|
21
|
-
define_method(t) do |
|
22
|
-
|
23
|
-
|
21
|
+
define_method(t) do |elt, html_opts = {}|
|
22
|
+
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt,"text" => "Texte à modifier"}
|
23
|
+
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
24
|
+
html_opts.merge!({class: "sb-#{t} #{html_opts[:class]}", data: {id: elt.is_a?(Hash) ? elt["id"] : elt}}) if action_name != 'show'
|
24
25
|
content_tag(t, raw(content["text"]).html_safe, html_opts)
|
25
26
|
end
|
26
27
|
end
|
@@ -29,20 +30,36 @@ module Sibu
|
|
29
30
|
self
|
30
31
|
end
|
31
32
|
|
32
|
-
def
|
33
|
-
@sb_entity.section(
|
33
|
+
def select_element(id)
|
34
|
+
@sb_entity.section(*@sb_section).select {|elt| elt["id"] == id}.first
|
34
35
|
end
|
35
36
|
|
36
|
-
def site_section(id, &block)
|
37
|
+
def site_section(id, sub_id = nil, &block)
|
37
38
|
@sb_entity = @site
|
38
|
-
@sb_section = id
|
39
|
-
|
39
|
+
@sb_section = sub_id ? [id, sub_id] : id
|
40
|
+
if block_given?
|
41
|
+
"<sb-edit data-id='#{id}' data-entity='site'>#{capture(self, &block)}</sb-edit>".html_safe
|
42
|
+
else
|
43
|
+
self
|
44
|
+
end
|
40
45
|
end
|
41
46
|
|
42
|
-
def section(id, &block)
|
47
|
+
def section(id, sub_id = nil, &block)
|
43
48
|
@sb_entity = @page
|
44
|
-
@sb_section = id
|
45
|
-
"<sb-edit data-id='#{id}'>#{capture(self, &block)}</sb-edit>".html_safe
|
49
|
+
@sb_section = sub_id ? [id, sub_id] : id
|
50
|
+
"<sb-edit data-id='#{id}' data-entity='page'>#{capture(self, &block)}</sb-edit>".html_safe
|
51
|
+
end
|
52
|
+
|
53
|
+
def site_sections(id)
|
54
|
+
@site.section(id).map {|s| s["id"]}
|
55
|
+
end
|
56
|
+
|
57
|
+
def sections(id)
|
58
|
+
@page.section(id).map {|s| s["id"]}
|
59
|
+
end
|
60
|
+
|
61
|
+
def elements(id = nil)
|
62
|
+
id ? select_element(id)["elements"] : @sb_entity.section(*@sb_section)
|
46
63
|
end
|
47
64
|
|
48
65
|
def each
|
@@ -58,14 +75,24 @@ module Sibu
|
|
58
75
|
end
|
59
76
|
end
|
60
77
|
|
61
|
-
def img(
|
62
|
-
|
63
|
-
|
64
|
-
|
78
|
+
def img(elt, html_opts = {})
|
79
|
+
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "src" => "/default.jpg"}
|
80
|
+
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
81
|
+
html_opts.merge!({class: "sb-img #{html_opts[:class]}", data: {id: elt.is_a?(Hash) ? elt["id"] : elt}}) if action_name != 'show'
|
82
|
+
content_tag(:img, nil, content.except("id").merge(html_opts))
|
83
|
+
end
|
84
|
+
|
85
|
+
def bg_img(elt, html_opts = {})
|
86
|
+
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "src" => "/default.jpg"}
|
87
|
+
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
88
|
+
html_opts.merge!({class: "sb-img #{html_opts[:class]}", data: {id: elt.is_a?(Hash) ? elt["id"] : elt}}) if action_name != 'show'
|
89
|
+
content_tag(:div, content_tag(:img, nil, content.except("id")), html_opts)
|
65
90
|
end
|
66
91
|
|
67
|
-
def link(
|
68
|
-
|
92
|
+
def link(elt, html_opts = {}, &block)
|
93
|
+
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "value" => "", "text" => "Nouveau lien"}
|
94
|
+
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
95
|
+
html_opts.merge!({class: "sb-link #{html_opts[:class]}", data: {id: elt.is_a?(Hash) ? elt["id"] : elt}}) if action_name != 'show'
|
69
96
|
val = content["value"] || ""
|
70
97
|
if val.to_s.include?('http')
|
71
98
|
href = val
|
@@ -79,10 +106,18 @@ module Sibu
|
|
79
106
|
end
|
80
107
|
end
|
81
108
|
|
82
|
-
def form_label(
|
83
|
-
|
84
|
-
|
109
|
+
def form_label(elt, html_opts = {}, &block)
|
110
|
+
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "text" => "Texte à modifier"}
|
111
|
+
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
112
|
+
html_opts.merge!({class: "sb-label #{html_opts[:class]}", data: {id: elt.is_a?(Hash) ? elt["id"] : elt}}) if action_name != 'show'
|
85
113
|
content_tag(:label, raw(content["text"]).html_safe, html_opts)
|
86
114
|
end
|
115
|
+
|
116
|
+
def interactive_map(elt, html_opts = {}, &block)
|
117
|
+
defaults = {"data-lat" => "45.68854", "data-lng" => "5.91587", "data-title" => "Titre marqueur"}
|
118
|
+
content = elt.is_a?(Hash) ? defaults.merge(elt) : (select_element(elt) || {"id" => elt}).merge(defaults)
|
119
|
+
html_opts.merge!({class: "sb-map #{html_opts[:class]}", data: {id: elt.is_a?(Hash) ? elt["id"] : elt}}) if action_name != 'show'
|
120
|
+
content_tag(:div, nil, content.merge(html_opts))
|
121
|
+
end
|
87
122
|
end
|
88
123
|
end
|
@@ -1,3 +1,27 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require "image_processing/mini_magick"
|
2
|
+
|
3
|
+
class Sibu::ImageUploader < Shrine
|
4
|
+
include ImageProcessing::MiniMagick
|
5
|
+
plugin :processing
|
6
|
+
plugin :versions
|
7
|
+
plugin :delete_raw
|
8
|
+
|
9
|
+
process(:store) do |io, context|
|
10
|
+
original = io.download
|
11
|
+
images_config = Rails.application.config.sibu[:images]
|
12
|
+
|
13
|
+
large = resize_to_limit!(original, images_config[:large], images_config[:large]) { |cmd| cmd.auto_orient }
|
14
|
+
medium = resize_to_limit(large, images_config[:medium], images_config[:medium])
|
15
|
+
small = resize_to_limit(medium, images_config[:small], images_config[:small])
|
16
|
+
|
17
|
+
{original: io, large: large, medium: medium, small: small}
|
18
|
+
end
|
19
|
+
|
20
|
+
def generate_location(io, context)
|
21
|
+
site_id = context[:record].site_id
|
22
|
+
style = context[:version] != :original ? "resized" : "originals"
|
23
|
+
name = super
|
24
|
+
|
25
|
+
[site_id, style, name].compact.join("/")
|
26
|
+
end
|
3
27
|
end
|
@@ -2,22 +2,24 @@ module Sibu
|
|
2
2
|
module SectionsConcern
|
3
3
|
include ActiveSupport::Concern
|
4
4
|
|
5
|
-
def section(
|
5
|
+
def section(*ids)
|
6
6
|
# elts = nil
|
7
|
-
|
7
|
+
if ids.length == 1
|
8
8
|
s = nil
|
9
9
|
if sections.blank?
|
10
10
|
self.sections = {}
|
11
11
|
else
|
12
|
-
s = sections[
|
12
|
+
s = sections[ids[0]]
|
13
13
|
end
|
14
14
|
if s.nil?
|
15
15
|
s = []
|
16
|
-
self.sections[
|
16
|
+
self.sections[ids[0]] = s
|
17
17
|
save
|
18
18
|
end
|
19
19
|
s
|
20
|
-
|
20
|
+
elsif ids.length == 2
|
21
|
+
subsection(*ids)
|
22
|
+
end
|
21
23
|
# s = section(ids[0])
|
22
24
|
# sub = s.select {|elt| elt["id"] == ids[1]}
|
23
25
|
# unless sub
|
@@ -32,13 +34,13 @@ module Sibu
|
|
32
34
|
|
33
35
|
def subsection(id, subid)
|
34
36
|
s = section(id)
|
35
|
-
sub = s.select {|elt| elt["id"] ==
|
37
|
+
sub = s.select {|elt| elt["id"] == subid}.first
|
36
38
|
unless sub
|
37
|
-
sub = {"id" =>
|
38
|
-
self.sections[
|
39
|
+
sub = {"id" => subid, "elements" => []}
|
40
|
+
self.sections[id] << sub
|
39
41
|
save
|
40
42
|
end
|
41
|
-
|
43
|
+
sub["elements"]
|
42
44
|
end
|
43
45
|
|
44
46
|
def element(section_id, element_id)
|
data/app/models/sibu/image.rb
CHANGED
data/app/models/sibu/site.rb
CHANGED
@@ -4,6 +4,7 @@ module Sibu
|
|
4
4
|
|
5
5
|
belongs_to :site_template, :class_name => 'Sibu::SiteTemplate'
|
6
6
|
has_many :pages, :class_name => 'Sibu::Page', dependent: :destroy
|
7
|
+
has_many :images, :class_name => 'Sibu::Image', dependent: :destroy
|
7
8
|
|
8
9
|
validates_presence_of :name, :site_template
|
9
10
|
|
@@ -23,16 +24,18 @@ module Sibu
|
|
23
24
|
pages.where(id: page_id).first
|
24
25
|
end
|
25
26
|
|
26
|
-
def save_and_init
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
def save_and_init
|
28
|
+
if valid?
|
29
|
+
self.sections = site_template.sections
|
30
|
+
site_template.pages.each do |p|
|
31
|
+
self.pages << Sibu::Page.new(p)
|
32
|
+
end
|
31
33
|
end
|
34
|
+
save!
|
32
35
|
end
|
33
36
|
|
34
|
-
def
|
35
|
-
Hash[pages.collect {|p| [p.id, p.path]}]
|
37
|
+
def pages_path_by_id
|
38
|
+
Hash[pages.collect {|p| [p.id.to_s, p.path]}]
|
36
39
|
end
|
37
40
|
|
38
41
|
def init_pages(source)
|
@@ -15,71 +15,124 @@
|
|
15
15
|
<body>
|
16
16
|
<% [:top_panel, :side_panel, :content_panel, :bottom_panel].each do |panel| %>
|
17
17
|
<% unless conf[panel].blank? %>
|
18
|
-
<div class="<%=
|
18
|
+
<div class="<%= panel == :content_panel ? 'sibu_content_panel' : 'sibu_panel' %>">
|
19
19
|
<%= render conf[panel] %>
|
20
20
|
</div>
|
21
21
|
<% end %>
|
22
22
|
<% end %>
|
23
23
|
<div id="edit_panel" class="sibu_view"></div>
|
24
|
+
<div id="edit_mode_overlay">
|
25
|
+
<div class="overlay_top"></div>
|
26
|
+
<div class="overlay_right"></div>
|
27
|
+
<div class="overlay_left"></div>
|
28
|
+
<div class="overlay_bottom"></div>
|
29
|
+
<div class="edit_mode_actions">
|
30
|
+
<button onclick="cancelEditMode()">Fermer</button>
|
31
|
+
</div>
|
32
|
+
</div>
|
24
33
|
|
25
34
|
<script>
|
35
|
+
const TEXT_TAGS = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'span'];
|
36
|
+
const IMG_TAGS = ['img'];
|
37
|
+
const LINK_TAGS = ['a'];
|
38
|
+
|
26
39
|
$(function () {
|
27
40
|
initOverlays();
|
28
41
|
});
|
29
42
|
|
30
|
-
function
|
31
|
-
|
43
|
+
function setEditMode(elt) {
|
44
|
+
var offset = elt.offset();
|
45
|
+
var width = elt.width(), height = elt.height();
|
46
|
+
var overlay = $("#edit_mode_overlay");
|
47
|
+
overlay.find(".overlay_top").css("height", offset.top);
|
48
|
+
overlay.find(".overlay_bottom").css("top", offset.top + height);
|
49
|
+
overlay.find(".overlay_left").css({"height": height, "width": offset.left, "top": offset.top});
|
50
|
+
overlay.find(".overlay_right").css({"height": height, "left": offset.left + width, "top": offset.top});
|
51
|
+
overlay.find(".edit_mode_actions").css({"top": (offset.top <= 40 ? (offset.top + height) : (offset.top - 40)), left: offset.left, width: width});
|
52
|
+
overlay.show();
|
53
|
+
initInnerOverlays(elt);
|
54
|
+
elt.remove();
|
55
|
+
}
|
56
|
+
|
57
|
+
function cancelEditMode() {
|
58
|
+
$("#edit_mode_overlay").hide();
|
59
|
+
cancelEdit();
|
60
|
+
initOverlays();
|
61
|
+
}
|
62
|
+
|
63
|
+
function cancelEdit() {
|
64
|
+
$("#edit_panel").slideUp("fast");
|
65
|
+
}
|
66
|
+
|
67
|
+
function editContent(eltId, sectionId, entity, contentType) {
|
68
|
+
$.ajax({
|
69
|
+
url: "<%= edit_element_site_page_path(@site.id, @page.id) %>",
|
70
|
+
method: "GET",
|
71
|
+
data: {
|
72
|
+
element_id: eltId,
|
73
|
+
section_id: sectionId,
|
74
|
+
entity: entity,
|
75
|
+
content_type: contentType
|
76
|
+
}
|
77
|
+
})
|
78
|
+
}
|
32
79
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
80
|
+
function initInnerOverlays(elt) {
|
81
|
+
var editables = elt.parents("sb-edit").first().find("[class*='sb-']");
|
82
|
+
editables.off();
|
83
|
+
editables.hover(function() {
|
84
|
+
$(this).addClass("sb-editable");
|
85
|
+
}, function() {
|
86
|
+
$(this).removeClass("sb-editable");
|
87
|
+
});
|
88
|
+
editables.click(function(evt) {
|
89
|
+
evt.preventDefault();
|
90
|
+
var elt = $(this), tag = elt.prop("tagName").toLowerCase();
|
38
91
|
var section = elt.parents("sb-edit").first();
|
39
92
|
var eltId = elt.data("id"), sectionId = section.data("id"), entity = section.data("entity");
|
40
|
-
|
41
|
-
|
42
|
-
|
93
|
+
if (TEXT_TAGS.indexOf(tag) !== -1) {
|
94
|
+
editContent(eltId, sectionId, entity, 'text');
|
95
|
+
} else if (IMG_TAGS.indexOf(tag) !== -1 || elt.hasClass('sb-img')) {
|
96
|
+
editContent(eltId, sectionId, entity, 'media');
|
97
|
+
} else if (LINK_TAGS.indexOf(tag) !== -1) {
|
98
|
+
editContent(eltId, sectionId, entity, 'link');
|
99
|
+
} else {
|
100
|
+
console.log('Sibu - Unsupported tag type : ' + tag);
|
101
|
+
}
|
102
|
+
})
|
103
|
+
}
|
43
104
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
}
|
105
|
+
function initOverlays() {
|
106
|
+
$("div.sb-overlay").remove();
|
107
|
+
$("sb-edit").each(function() {
|
108
|
+
var elt = $(this);
|
109
|
+
elt.prepend("<div class='sb-overlay'><a>Modifier</a></div>");
|
110
|
+
var overlay = elt.find(".sb-overlay");
|
111
|
+
var dimensions = overlayDimensions(overlay, elt);
|
112
|
+
overlay.width(dimensions.width);
|
113
|
+
overlay.height(dimensions.height);
|
54
114
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
bindMouseEnter(element, overlay, elementId, sectionId, entity);
|
115
|
+
elt.hover(function() {
|
116
|
+
overlay.css("opacity", 1);
|
117
|
+
}, function() {
|
118
|
+
overlay.css("opacity", 0);
|
60
119
|
});
|
61
|
-
}
|
62
120
|
|
63
|
-
|
64
|
-
|
65
|
-
'style="box-sizing: content-box; display: ' + display + '; padding: ' + padding + '; margin: ' + margin + ';"' +
|
66
|
-
'viewBox="0 0 ' + width + ' ' + height + '" width="' + width + 'px" height="' + height + 'px">' +
|
67
|
-
'<rect width="' + width + '" height="' + height + '" x="0" y="0" fill="#dedede"/>' +
|
68
|
-
'</svg>';
|
69
|
-
}
|
70
|
-
|
71
|
-
function editContent(eltId, sectionId, entity) {
|
72
|
-
$.ajax({
|
73
|
-
url: "<%= edit_element_site_page_path(@site.id, @page.id) %>",
|
74
|
-
method: "GET",
|
75
|
-
data: {
|
76
|
-
element_id: eltId,
|
77
|
-
section_id: sectionId,
|
78
|
-
entity: entity
|
79
|
-
}
|
121
|
+
overlay.click(function() {
|
122
|
+
setEditMode($(this));
|
80
123
|
})
|
81
|
-
}
|
124
|
+
});
|
125
|
+
}
|
82
126
|
|
127
|
+
function overlayDimensions(overlay, element) {
|
128
|
+
var children = element.find("> *:not(.sb-overlay)");
|
129
|
+
var width = - +children.first().css("margin-left").replace("px", ""), height = - +children.first().css("margin-top").replace("px", "");
|
130
|
+
var maxWidth = element.parent().outerWidth(true), maxHeight = element.parent().outerHeight(true);
|
131
|
+
element.find("> *:not(.sb-overlay)").each(function() {
|
132
|
+
width = width + $(this).outerWidth(true);
|
133
|
+
height = height + $(this).outerHeight(true);
|
134
|
+
});
|
135
|
+
return {width: Math.min(width, maxWidth), height: Math.min(height, maxHeight)};
|
83
136
|
}
|
84
137
|
</script>
|
85
138
|
<%= yield :scripts %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= form_for([@site, @image]) do |f| %>
|
2
|
+
<div class="sibu_field">
|
3
|
+
<%= f.hidden_field :file, value: @image.cached_file_data %>
|
4
|
+
<%= f.file_field :file %>
|
5
|
+
</div>
|
6
|
+
<%= f.hidden_field :site_id %>
|
7
|
+
<div class="sibu_actions">
|
8
|
+
<%= f.submit 'Valider' %>
|
9
|
+
<%= link_to 'Annuler', :back %>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div id="pages" class="sibu_view">
|
2
|
+
<div class="actions">
|
3
|
+
<%= link_to 'Télécharger une image', new_site_image_path(@site.id) %> | <%= link_to 'Retour', :back %>
|
4
|
+
</div>
|
5
|
+
<h2>Images du site "<%= @site.name %>"</h2>
|
6
|
+
<% @images.each do |image| %>
|
7
|
+
<div class="sibu_image"><%= image_tag image.file_url(:small) %></div>
|
8
|
+
<% end %>
|
9
|
+
</div>
|
10
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<h2>Modifier le lien</h2>
|
2
|
+
<div id="edit_msg"></div>
|
3
|
+
<div class="sibu_form">
|
4
|
+
<%= form_tag(update_element_site_page_path(@site.id, @page.id), method: :patch, remote: true) do |f| %>
|
5
|
+
<div class="sibu_field">
|
6
|
+
<%= label_tag 'element[text]', 'Libellé' %>
|
7
|
+
<%= text_field_tag 'element[text]', @element["text"] %>
|
8
|
+
</div>
|
9
|
+
<div class="sibu_field">
|
10
|
+
<%= label_tag 'element[value]', 'Lien' %>
|
11
|
+
<%= select_tag 'element[value]', options_from_collection_for_select(@site.pages, :id, :name, @element["value"]),
|
12
|
+
{prompt: 'Sélectionnez une page'} %>
|
13
|
+
</div>
|
14
|
+
<%= hidden_field_tag 'element[id]', @element["id"] %>
|
15
|
+
<%= hidden_field_tag :section_id, @section_id %>
|
16
|
+
<%= hidden_field_tag :entity, @entity_type %>
|
17
|
+
<div class="sibu_actions">
|
18
|
+
<%= submit_tag 'Valider' %>
|
19
|
+
<%= link_to 'Annuler', '#', onclick: 'cancelEdit(); return false;' %>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
22
|
+
</div>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<h2>Modifier l'image</h2>
|
2
|
+
<div id="edit_msg"></div>
|
3
|
+
<div class="sibu_form">
|
4
|
+
<%= form_tag(update_element_site_page_path(@site.id, @page.id), method: :patch, remote: true) do |f| %>
|
5
|
+
<div class="sibu_select_images">
|
6
|
+
<% @site.images.each do |image| %>
|
7
|
+
<div class="sibu_image">
|
8
|
+
<%= image_tag image.file_url(:small) %>
|
9
|
+
</div>
|
10
|
+
<% end %>
|
11
|
+
</div>
|
12
|
+
<div class="sibu_field">
|
13
|
+
<%= label_tag 'element[alt]', 'Texte alternatif' %>
|
14
|
+
<%= text_field_tag 'element[alt]', @element["alt"] %>
|
15
|
+
</div>
|
16
|
+
<%= hidden_field_tag 'element[id]', @element["id"] %>
|
17
|
+
<%= hidden_field_tag 'element[src]', @element["src"] %>
|
18
|
+
<%= hidden_field_tag :section_id, @section_id %>
|
19
|
+
<%= hidden_field_tag :entity, @entity_type %>
|
20
|
+
<div class="sibu_actions">
|
21
|
+
<%= submit_tag 'Valider' %>
|
22
|
+
<%= link_to 'Annuler', '#', onclick: '$("#edit_panel").slideUp("fast"); return false;' %>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
</div>
|
@@ -1,14 +1,14 @@
|
|
1
|
-
<h2>Modifier
|
1
|
+
<h2>Modifier le texte</h2>
|
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
5
|
<%= trix_editor_tag 'element[text]', '', input: 'element_text' %>
|
6
|
-
<%= hidden_field_tag 'element[id]', @
|
6
|
+
<%= hidden_field_tag 'element[id]', @element["id"] %>
|
7
7
|
<%= hidden_field_tag :section_id, @section_id %>
|
8
8
|
<%= hidden_field_tag :entity, @entity_type %>
|
9
9
|
<div class="sibu_actions">
|
10
10
|
<%= submit_tag 'Valider' %>
|
11
|
-
<%= link_to 'Annuler', '#', onclick: '
|
11
|
+
<%= link_to 'Annuler', '#', onclick: 'cancelEdit(); return false;' %>
|
12
12
|
</div>
|
13
13
|
<% end %>
|
14
14
|
</div>
|
@@ -1,5 +1,18 @@
|
|
1
1
|
var editPanel = $("#edit_panel");
|
2
|
-
editPanel.html("
|
3
|
-
|
4
|
-
|
2
|
+
editPanel.html("");
|
3
|
+
<% if @content_type == 'text' %>
|
4
|
+
<% text_value = @element["text"] || 'Texte à modifier' %>
|
5
|
+
editPanel.html("<%= j(render 'text_edit_panel') %>");
|
6
|
+
var editorElt = editPanel.find("trix-editor")[0];
|
7
|
+
editorElt.editor.loadHTML("<%= raw(text_value.gsub("\n", "<br/>")) %>");
|
8
|
+
<% elsif @content_type == 'media' %>
|
9
|
+
editPanel.html("<%= j(render 'media_edit_panel') %>");
|
10
|
+
editPanel.find(".sibu_image img").click(function() {
|
11
|
+
$("#element_src").val($(this).attr("src"));
|
12
|
+
});
|
13
|
+
<% elsif @content_type == 'link' %>
|
14
|
+
editPanel.html("<%= j(render 'link_edit_panel') %>");
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
|
5
18
|
editPanel.slideDown("fast");
|
@@ -2,5 +2,13 @@
|
|
2
2
|
$("#edit_panel #edit_msg").html("<p class='sibu_alert'>Une erreur s'est produite lors de l'enregistrement.</p>");
|
3
3
|
<% else %>
|
4
4
|
$("#edit_panel").slideUp();
|
5
|
-
$("sb-edit[data-id='<%= @section_id %>']").find("[data-id='<%= @updated["id"] %>']")
|
5
|
+
var updatedElt = $("sb-edit[data-id='<%= @section_id %>']").find("[data-id='<%= @updated["id"] %>']");
|
6
|
+
<% if @updated["text"] %>
|
7
|
+
updatedElt.html("<%= j(raw @updated["text"]) %>");
|
8
|
+
<% end %>
|
9
|
+
<% unless @updated.except("id", "text").blank? %>
|
10
|
+
<% @updated.except("id", "text").each_pair do |attr, val| %>
|
11
|
+
updatedElt.attr("<%= attr %>", "<%= val %>");
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
6
14
|
<% end %>
|
@@ -2,8 +2,8 @@ require "shrine"
|
|
2
2
|
require "shrine/storage/file_system"
|
3
3
|
|
4
4
|
Shrine.storages = {
|
5
|
-
cache: Shrine::Storage::FileSystem.new("public", prefix: "uploads/cache"),
|
6
|
-
store: Shrine::Storage::FileSystem.new("public", prefix: "uploads/store"),
|
5
|
+
cache: Shrine::Storage::FileSystem.new("public", prefix: "uploads/cache"),
|
6
|
+
store: Shrine::Storage::FileSystem.new("public", prefix: "uploads/store"),
|
7
7
|
}
|
8
8
|
|
9
9
|
Shrine.plugin :activerecord
|
data/config/routes.rb
CHANGED
data/lib/sibu/engine.rb
CHANGED
data/lib/sibu/version.rb
CHANGED
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: 0.1.
|
4
|
+
version: 0.1.6
|
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: 2018-02-
|
11
|
+
date: 2018-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: image_processing
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.4'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mini_magick
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.3'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.3'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: jquery-rails
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,9 +123,11 @@ files:
|
|
95
123
|
- app/assets/javascripts/sibu/sibu.js.erb
|
96
124
|
- app/assets/stylesheets/sibu/sibu.css
|
97
125
|
- app/controllers/sibu/application_controller.rb
|
126
|
+
- app/controllers/sibu/images_controller.rb
|
98
127
|
- app/controllers/sibu/pages_controller.rb
|
99
128
|
- app/controllers/sibu/sites_controller.rb
|
100
129
|
- app/helpers/sibu/application_helper.rb
|
130
|
+
- app/helpers/sibu/images_helper.rb
|
101
131
|
- app/helpers/sibu/pages_helper.rb
|
102
132
|
- app/helpers/sibu/sites_helper.rb
|
103
133
|
- app/jobs/sibu/application_job.rb
|
@@ -112,8 +142,15 @@ files:
|
|
112
142
|
- app/views/layouts/sibu/application.html.erb
|
113
143
|
- app/views/layouts/sibu/edit_content.html.erb
|
114
144
|
- app/views/layouts/sibu/site.html.erb
|
115
|
-
- app/views/sibu/
|
145
|
+
- app/views/sibu/images/_form.html.erb
|
146
|
+
- app/views/sibu/images/edit.html.erb
|
147
|
+
- app/views/sibu/images/index.html.erb
|
148
|
+
- app/views/sibu/images/new.html.erb
|
149
|
+
- app/views/sibu/images/show.html.erb
|
116
150
|
- app/views/sibu/pages/_form.html.erb
|
151
|
+
- app/views/sibu/pages/_link_edit_panel.html.erb
|
152
|
+
- app/views/sibu/pages/_media_edit_panel.html.erb
|
153
|
+
- app/views/sibu/pages/_text_edit_panel.html.erb
|
117
154
|
- app/views/sibu/pages/destroy.html.erb
|
118
155
|
- app/views/sibu/pages/edit.html.erb
|
119
156
|
- app/views/sibu/pages/edit_content.html.erb
|
@@ -140,6 +177,9 @@ files:
|
|
140
177
|
- db/migrate/20180126114522_rename_url_to_path_in_pages.rb
|
141
178
|
- db/migrate/20180126114628_add_domain_to_sites.rb
|
142
179
|
- db/migrate/20180127211533_create_sibu_images.rb
|
180
|
+
- db/migrate/20180208082317_rename_images_user_id_to_site_id.rb
|
181
|
+
- db/migrate/20180208125024_rename_image_data_column.rb
|
182
|
+
- db/migrate/20180210181644_add_defaults_to_site_templates.rb
|
143
183
|
- lib/sibu.rb
|
144
184
|
- lib/sibu/engine.rb
|
145
185
|
- lib/sibu/version.rb
|