scribble_cms 0.0.14a → 0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controller/scribbler_pictures_controller.rb +20 -0
- data/app/helpers/scribbler_admin_helper.rb +11 -0
- data/app/helpers/scribbler_content_helper.rb +14 -15
- data/app/models/scribbler_container.rb +7 -0
- data/app/models/scribbler_group.rb +42 -11
- data/app/models/scribbler_image.rb +18 -18
- data/app/models/scribbler_var.rb +44 -0
- data/app/views/scribbler_admin/_scribbler_layout.html.erb +8 -4
- data/app/views/scribbler_admin/_scribbler_sidebar.html.erb +12 -7
- data/app/views/scribbler_admin/group_edit.html.erb +32 -33
- data/app/views/scribbler_admin/index.html.erb +2 -1
- data/app/views/scribbler_admin/search.html.erb +20 -0
- data/app/views/scribbler_content/forms/_image.html.erb +7 -15
- data/app/views/scribbler_content/forms/_row.html.erb +0 -1
- data/app/views/scribbler_content/forms/_text.html.erb +1 -2
- data/config/routes.rb +2 -11
- data/db/migrate/20140313012637_create_scribblers.rb +11 -2
- data/lib/scribble_cms/engine.rb +16 -2
- data/lib/scribble_cms/scribbler_controller_plugin.rb +115 -0
- data/lib/scribble_cms/scribbler_element_setup.rb +41 -11
- data/lib/scribble_cms.rb +24 -3
- metadata +30 -14
- data/app/controllers/scribbler_admin_controller.rb +0 -77
- data/lib/paperclip_processors/cropper.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e706ebc8a03c8b726759571b427213eb4d8ea32
|
4
|
+
data.tar.gz: 10483fa6ec2cfe7828d673a247c9debc595120fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af9d8f97bcc4552ec0daa73ae054266b1108c53cba23465388e78ef0ac127a8c1fbbc078f4b39abbc2510b625378aa94cbc2be56c9f5b949b0c7995daf8ad4b2
|
7
|
+
data.tar.gz: 406fec9bc5750bb74ab314d1d379fb65641b00cb77c902e8d47987f8f3e6917afb27f001c4bbba409181a0a1367ec7f75b385b7c6fb48db7f5c75592420f5447
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class ScribblerPicturesController < ApplicationController
|
2
|
+
|
3
|
+
skip_before_filter :main_app_default_before_filter
|
4
|
+
|
5
|
+
def show
|
6
|
+
img = ScribblerImage.find_by_image_name("#{params[:name]}.#{params[:format]}")
|
7
|
+
|
8
|
+
if img
|
9
|
+
begin
|
10
|
+
send_file(img.image.path, :disposition => 'inline', :status => 200)
|
11
|
+
rescue Dragonfly::Job::Fetch::NotFound
|
12
|
+
render :text => nil, :status => 404
|
13
|
+
end
|
14
|
+
else
|
15
|
+
render :text => nil
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -1,2 +1,13 @@
|
|
1
1
|
module ScribblerAdminHelper
|
2
|
+
|
3
|
+
# Form
|
4
|
+
def scribbler_form_element(element,form)
|
5
|
+
render :partial => "/scribbler_content/forms/#{element.element_type}", :locals => {:element => element, :f => form}
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
def scribbler_layout(&block)
|
10
|
+
render :partial => "/scribbler_admin/scribbler_layout", :locals => {:content => capture(&block)}
|
11
|
+
end
|
12
|
+
|
2
13
|
end
|
@@ -5,31 +5,30 @@ module ScribblerContentHelper
|
|
5
5
|
q = {:name => container_name, :scaleable => (options[:scaleable].nil? ? false : options[:scaleable]), :element_id => (options[:element] ? options[:element].id : nil)}
|
6
6
|
container = ScribblerContainer.where(:name => container_name).first || ScribblerContainer.create(q)
|
7
7
|
container.update_attributes(:scaleable => options[:scaleable]) if options[:scaleable] && container.scaleable != options[:scaleable]
|
8
|
-
|
8
|
+
yield(container)
|
9
9
|
end
|
10
10
|
|
11
11
|
def scribbler_group(container, group, &block)
|
12
12
|
scribbler_container(container) do |c|
|
13
13
|
c.scribbler_group(group) do |g|
|
14
|
-
|
14
|
+
yield(g)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def scribbler_element(container, group, type, name)
|
20
|
-
|
21
|
-
|
19
|
+
def scribbler_element(container, group, type, name, options = {}, &block)
|
20
|
+
if block_given?
|
21
|
+
options[:default] = capture(&block).html_safe.strip.force_encoding("UTF-8")
|
22
|
+
end
|
23
|
+
|
24
|
+
scribbler_group(container.to_s, group.to_s) do |g|
|
25
|
+
v = g.send(type.to_s, name.to_s, options)
|
26
|
+
if v.blank? && options[:default]
|
27
|
+
options[:default]
|
28
|
+
else
|
29
|
+
return v
|
30
|
+
end
|
22
31
|
end
|
23
32
|
end
|
24
33
|
|
25
|
-
# Form
|
26
|
-
def scribbler_form_element(element,form)
|
27
|
-
render :partial => "/scribbler_content/forms/#{element.element_type}", :locals => {:element => element, :f => form}
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
def scribbler_layout(&block)
|
32
|
-
render :partial => "/scribbler_admin/scribbler_layout", :locals => {:content => capture(&block)}
|
33
|
-
end
|
34
|
-
|
35
34
|
end
|
@@ -23,6 +23,10 @@ class ScribblerContainer < ActiveRecord::Base
|
|
23
23
|
|
24
24
|
|
25
25
|
# => END
|
26
|
+
|
27
|
+
def ordered_groups
|
28
|
+
self.groups.sort_by {|g| g.human_name.to_s }
|
29
|
+
end
|
26
30
|
|
27
31
|
def scribbler_group(name, &block)
|
28
32
|
yield(self.get_group(name))
|
@@ -32,6 +36,9 @@ class ScribblerContainer < ActiveRecord::Base
|
|
32
36
|
ScribblerGroup.where(:name => name, :container_id => self.id).first || ScribblerGroup.create(:name => name, :container_id => self.id)
|
33
37
|
end
|
34
38
|
|
39
|
+
def description
|
40
|
+
I18n.t(self.name, :scope => "scribbler.container_names", :default => self.name.humanize)
|
41
|
+
end
|
35
42
|
|
36
43
|
|
37
44
|
|
@@ -16,7 +16,8 @@ class ScribblerGroup < ActiveRecord::Base
|
|
16
16
|
ELEMENTS = {:row => ScribblerText,
|
17
17
|
:text => ScribblerText,
|
18
18
|
:link => ScribblerLink,
|
19
|
-
:image => ScribblerImage
|
19
|
+
:image => ScribblerImage,
|
20
|
+
:var => ScribblerVar}
|
20
21
|
|
21
22
|
#== Validation and Callbacks
|
22
23
|
#=== Validation
|
@@ -24,17 +25,24 @@ class ScribblerGroup < ActiveRecord::Base
|
|
24
25
|
|
25
26
|
#=== Callbacks
|
26
27
|
after_destroy :destroy_elements
|
27
|
-
|
28
|
-
|
28
|
+
|
29
29
|
# => END
|
30
30
|
|
31
31
|
# Display data
|
32
|
-
def row(row_name)
|
33
|
-
get_element(:row, row_name)
|
32
|
+
def row(row_name, options = {})
|
33
|
+
e = get_element(:row, row_name)
|
34
|
+
if e.content.blank? && options[:default]
|
35
|
+
e.update_attributes(:content => options[:default])
|
36
|
+
end
|
37
|
+
return e.content.to_s.html_safe
|
34
38
|
end
|
35
39
|
|
36
|
-
def text(text_name)
|
37
|
-
get_element(:text, text_name)
|
40
|
+
def text(text_name, options = {})
|
41
|
+
e = get_element(:text, text_name)
|
42
|
+
if e.content.blank? && options[:default]
|
43
|
+
e.update_attributes(:content => options[:default])
|
44
|
+
end
|
45
|
+
return e.content.to_s.html_safe
|
38
46
|
end
|
39
47
|
|
40
48
|
def link(link_name, options = {})
|
@@ -43,10 +51,29 @@ class ScribblerGroup < ActiveRecord::Base
|
|
43
51
|
ActionController::Base.helpers.link_to(link.title, link.url, options)
|
44
52
|
end
|
45
53
|
|
46
|
-
def image(image_name,
|
47
|
-
get_element(:image, image_name,
|
54
|
+
def image(image_name, options = {})
|
55
|
+
e = get_element(:image, image_name, options)
|
56
|
+
if e.image
|
57
|
+
e.image.url
|
58
|
+
else
|
59
|
+
""
|
60
|
+
end
|
48
61
|
end
|
49
62
|
|
63
|
+
def var(name, options = {})
|
64
|
+
get_element :var, name
|
65
|
+
end
|
66
|
+
|
67
|
+
def clone!(new_name)
|
68
|
+
group = self.class.new(:name => new_name, :container_id => self.container_id)
|
69
|
+
if group.save
|
70
|
+
self.elements.each do |el|
|
71
|
+
el.class.create(el.attributes.except("id").merge(:group_id => group.id))
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
50
77
|
# Helpers
|
51
78
|
def get_element(type, name, options = {:released => true})
|
52
79
|
options[:released] ||= true
|
@@ -77,7 +104,7 @@ class ScribblerGroup < ActiveRecord::Base
|
|
77
104
|
end
|
78
105
|
|
79
106
|
def elements(options = {:released => true})
|
80
|
-
ELEMENTS.values.uniq.map {|c| c.where(:group_id => self.id, :released => options[:released] == true)}.flatten.sort_by {|e| e.
|
107
|
+
ELEMENTS.values.uniq.map {|c| c.where(:group_id => self.id, :released => options[:released] == true)}.flatten.sort_by {|e| e.name}
|
81
108
|
end
|
82
109
|
|
83
110
|
def released_elements
|
@@ -98,7 +125,7 @@ class ScribblerGroup < ActiveRecord::Base
|
|
98
125
|
self.process_data!(data[:released])
|
99
126
|
|
100
127
|
# Update unrealesed data
|
101
|
-
self.process_data!(data[:unreleased])
|
128
|
+
self.process_data!(data[:unreleased]) if data[:unreleased]
|
102
129
|
end
|
103
130
|
|
104
131
|
def process_data!(data)
|
@@ -115,6 +142,10 @@ class ScribblerGroup < ActiveRecord::Base
|
|
115
142
|
end
|
116
143
|
end
|
117
144
|
|
145
|
+
def human_name
|
146
|
+
I18n.t(self.name, :scope => "scribbler.group_names", :default => self.name.humanize) rescue self.name
|
147
|
+
end
|
148
|
+
|
118
149
|
|
119
150
|
|
120
151
|
|
@@ -1,10 +1,25 @@
|
|
1
1
|
class ScribblerImage < ActiveRecord::Base
|
2
2
|
|
3
3
|
#= Configuration
|
4
|
-
|
5
|
-
|
4
|
+
dragonfly_accessor :image, app: :scribbler do
|
5
|
+
after_assign{|i| i.name = sanitize_filename(image.name) }
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
def sanitize_filename(filename)
|
10
|
+
[filename.split(".").first.parameterize, filename.split(".").last].join(".")
|
11
|
+
end
|
12
|
+
|
13
|
+
#validates_presence_of :image
|
14
|
+
validates_size_of :image, maximum: 2.megabytes
|
15
|
+
validates_property :format,
|
16
|
+
of: :image,
|
17
|
+
in: [:gif, :png, :jpg, :jpeg],
|
18
|
+
case_sensitive: false,
|
19
|
+
message: I18n.t("not a valid image")
|
20
|
+
|
21
|
+
|
6
22
|
|
7
|
-
attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
|
8
23
|
#== Associations
|
9
24
|
|
10
25
|
#== Plugins and modules
|
@@ -28,20 +43,5 @@ class ScribblerImage < ActiveRecord::Base
|
|
28
43
|
# => END
|
29
44
|
|
30
45
|
|
31
|
-
def cropping?
|
32
|
-
!crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank?
|
33
|
-
end
|
34
|
-
|
35
|
-
def crop_image
|
36
|
-
self.image.reprocess!
|
37
|
-
crop_x = crop_y = crop_w = crop_h = nil
|
38
|
-
end
|
39
|
-
|
40
|
-
def opt_image_width
|
41
|
-
self.opt_size.split("x").first
|
42
|
-
end
|
43
46
|
|
44
|
-
def opt_image_height
|
45
|
-
self.opt_size.split("x").last
|
46
|
-
end
|
47
47
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class ScribblerVar < ActiveRecord::Base
|
2
|
+
|
3
|
+
#= Configuration
|
4
|
+
#== Associations
|
5
|
+
|
6
|
+
|
7
|
+
#== Plugins and modules
|
8
|
+
#=== PlugIns
|
9
|
+
# => Stuff in Here
|
10
|
+
|
11
|
+
#=== include Modules
|
12
|
+
include ScribbleCms::ScribblerElementSetup
|
13
|
+
|
14
|
+
#== Konstanten
|
15
|
+
VAR_TYPES = {
|
16
|
+
:decimal => ""
|
17
|
+
}
|
18
|
+
|
19
|
+
#== Validation and Callbacks
|
20
|
+
#=== Validation
|
21
|
+
|
22
|
+
|
23
|
+
#=== Callbacks
|
24
|
+
# => Stuff in Here
|
25
|
+
|
26
|
+
|
27
|
+
# => END
|
28
|
+
|
29
|
+
|
30
|
+
def self.get(container_name, group_name, name, type)
|
31
|
+
|
32
|
+
q = {:name => container_name}
|
33
|
+
container = ScribblerContainer.where(:name => container_name).first || ScribblerContainer.create(q)
|
34
|
+
container.scribbler_group(group_name) do |g|
|
35
|
+
return g.var(name, type)
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.set(group, name, value)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
<div id="scribbler-admin-area" class="cf">
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
<% if @containers.empty? %>
|
3
|
+
<span class="metainfo">Es liegen keine Inhalte vor, die bearbeitet werden können</span>
|
4
|
+
<% else %>
|
5
|
+
<div id="scribbler-sidebar">
|
6
|
+
<%= render :partial => "/scribbler_admin/scribbler_sidebar" unless request.xhr? %>
|
7
|
+
</div>
|
8
|
+
<div id="scribbler-edit-area"><%= content %></div>
|
9
|
+
<% end %>
|
6
10
|
</div>
|
@@ -1,11 +1,16 @@
|
|
1
|
-
<ul>
|
1
|
+
<ul data-no-turbolink>
|
2
|
+
<li>
|
3
|
+
<%= form_for :scribbler, :url => alchemy.admin_static_content_search_url, :html => {:method => :get} do |f| %>
|
4
|
+
<%= f.labeled_text_field :query, :label => "Suchbegriff" %>
|
5
|
+
<%= f.submit "Suchen" %>
|
6
|
+
<% end %>
|
7
|
+
</li>
|
2
8
|
<% ScribblerContainer.all.each do |container| %>
|
3
|
-
<li class="scribbler-group">
|
4
|
-
<%=
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
<li><%= link_to group.name, scribbler.url_for({:controller => "/scribbler_admin", :action => "group_edit", :id => group.id}), default_ajax_link(:update => "scribbler-edit-area") %></li>
|
9
|
+
<li class="scribbler-group" data-scribbler-container-id="<%= container.id %>">
|
10
|
+
<%= container.description %><br />
|
11
|
+
<ul class="" data-scribbler-container-id="<%= container.id %>">
|
12
|
+
<% container.ordered_groups.each do |group| %>
|
13
|
+
<li><%= link_to_unless_current group.human_name, {:action => "group_edit", :id => group.id} %></li>
|
9
14
|
<% end %>
|
10
15
|
</ul>
|
11
16
|
</li>
|
@@ -1,46 +1,54 @@
|
|
1
|
+
<% element_ids = [] %>
|
1
2
|
<%= scribbler_layout do %>
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
<% if
|
6
|
-
auf Seite <i>'<%= @group.container.element.page.name %>'</i>
|
7
|
-
<% end %>
|
8
|
-
</p>
|
9
|
-
|
10
|
-
<%= form_for @group, :url => scribbler.url_for({:action => "group_update", :id => @group.id}), :html => {:class => "section", :method => :post} do |f| %>
|
11
|
-
<table style="min-width: 940px;" cellspacing="5">
|
4
|
+
<%= form_for @group, :url => {:action => "group_update", :id => @group.id}, :html => {:class => "section", :method => :post} do |f| %>
|
5
|
+
<table id="scribbler-group-edit-table" cellspacing="5">
|
6
|
+
<% if !controller.hide_scribbler_edit_status %>
|
12
7
|
<tr>
|
13
8
|
<td>
|
14
9
|
<b><%= link_to_function("Aktueller Zustand", "toggleCol('released')") %></b><br />
|
15
10
|
<i>Klicken um Bereich ein- bzw auszublenden</i>
|
16
11
|
</td>
|
12
|
+
|
17
13
|
<td>
|
18
14
|
<b><%= link_to_function("In Bearbeitung", "toggleCol('unreleased')") %></b><br />
|
19
15
|
<i>Klicken um Bereich ein- bzw auszublenden</i>
|
20
16
|
</td>
|
21
17
|
</tr>
|
18
|
+
<% end %>
|
19
|
+
|
22
20
|
<tr>
|
23
21
|
<td id="released" class="">
|
24
22
|
<%= f.fields_for :released do |u| %>
|
25
23
|
<% @group.released_elements.each do |e| %>
|
26
|
-
<div style="
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
24
|
+
<div class="scribbler-element scribbler-<%= e.element_type %>" style="<%= 'background-color: #ffffdc;' if params[:active].to_i == e.id %> padding: 5px;">
|
25
|
+
<h3 class="scribbler-header"><%= e.human_name %></h3>
|
26
|
+
<% unless e.hint.blank? %>
|
27
|
+
<p class="scribbler-element-hint"><%= raw(e.hint) %></p>
|
28
|
+
<% end %>
|
29
|
+
<% element_ids << e.id %>
|
30
|
+
<div style="margin-bottom: 5px;"><%= scribbler_form_element(e,u) %></div>
|
31
|
+
</div>
|
34
32
|
<% end %>
|
35
33
|
<% end %>
|
36
34
|
</td>
|
35
|
+
<% if !controller.hide_scribbler_edit_status %>
|
36
|
+
<td id="unreleased" class="">
|
37
|
+
<%= f.fields_for :unreleased do |u| %>
|
38
|
+
<% @group.unreleased_elements.each do |e| %>
|
39
|
+
<h3 class="scribbler-header"><%= e.human_name %></h3>
|
40
|
+
<div style="margin-bottom: 5px;"><%= scribbler_form_element(e,u) %></div>
|
41
|
+
<% end %>
|
42
|
+
<% end %>
|
43
|
+
</td>
|
44
|
+
<% end %>
|
37
45
|
</tr>
|
38
46
|
</table>
|
39
47
|
|
40
48
|
<%= f.submit "Änderungen speichern" %>
|
41
49
|
|
42
50
|
<% if @group.container.scaleable %>
|
43
|
-
<%= link_to "Dieses Element löschen",
|
51
|
+
<%= link_to "Dieses Element löschen", {:action => "group_destroy", :id => @group.id},
|
44
52
|
:confirm => "Soll dieses Element gelöscht werden? Dies kann nicht rückgängig gemacht werden.", :class => "icon-minus" %>
|
45
53
|
<% end %>
|
46
54
|
|
@@ -48,21 +56,12 @@
|
|
48
56
|
|
49
57
|
<% end %>
|
50
58
|
|
51
|
-
<%= tinymce %>
|
52
|
-
|
53
59
|
<script type="text/javascript">
|
54
|
-
|
55
|
-
|
56
|
-
col = $("#"+name)
|
57
|
-
if(col.hasClass("col-visible")){
|
58
|
-
$("#"+name+" *").hide();
|
59
|
-
col.removeClass("col-visible")
|
60
|
-
}else{
|
61
|
-
$("#"+name+" *").show();
|
62
|
-
col.addClass("col-visible")
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
toggleCol('released')
|
60
|
+
f = "Alchemy.Tinymce.init(<%= element_ids %>)"
|
61
|
+
window.setTimeout(f, 250)
|
67
62
|
</script>
|
68
63
|
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<%= scribbler_layout do %>
|
2
|
+
<h1>Suchergebnisse für '<%= params[:scribbler][:query] %>'</h1>
|
3
|
+
|
4
|
+
<table class="list">
|
5
|
+
<% @items.each do |item| %>
|
6
|
+
<tr>
|
7
|
+
<td>
|
8
|
+
<%= link_to :action => "group_edit", :id => item.group.id, :active => item.id do %>
|
9
|
+
<h2> <b><%= item.human_name %></b> - <%= item.group.human_name %></h2>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
|
13
|
+
<%= item.content.to_s.html_safe %>
|
14
|
+
</td>
|
15
|
+
</tr>
|
16
|
+
<% end %>
|
17
|
+
</table>
|
18
|
+
|
19
|
+
|
20
|
+
<% end %>
|
@@ -1,23 +1,15 @@
|
|
1
1
|
<%= f.fields_for "#{element.element_type}_#{element.id}" do |e| %>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
<%= e.file_field :image %>
|
7
|
-
|
8
|
-
|
9
|
-
<p>Klicken Sie auf das Bild um die Abmessungen anzupassen</p>
|
10
|
-
<%= link_to image_tag(element.image.url(:default), :width => "100%"), {:action => "image_cropper", :id => element.id} %>
|
11
|
-
|
2
|
+
<div class="image-container">
|
3
|
+
<%= image_tag element.image.url if element.image_stored? %>
|
4
|
+
<%= e.label :image, "Bilddatei" %> <div class="input"><%= e.file_field :image %></div>
|
5
|
+
</div>
|
12
6
|
<div style="margin-bottom: 5px;">
|
13
|
-
<%= e.label :copyright, "Copyright"
|
14
|
-
<%= e.text_field :copyright, :value => element.copyright %>
|
7
|
+
<%= e.label :copyright, "Copyright" %> <div class="input"><%= e.text_field :copyright, :value => element.copyright %></div>
|
15
8
|
</div>
|
16
9
|
|
17
10
|
<div style="margin-bottom: 5px;">
|
18
|
-
<%= e.label :alt_text, "ALT-Attribut"
|
19
|
-
|
20
|
-
</div>
|
11
|
+
<%= e.label :alt_text, "ALT-Attribut" %> <div class="input"><%= e.text_field :alt_text, :value => element.alt_text %></div>
|
12
|
+
</div>
|
21
13
|
|
22
14
|
<%= e.hidden_field :type, :value => element.element_type %>
|
23
15
|
<%= e.hidden_field :id, :value => element.id %>
|
@@ -1,5 +1,4 @@
|
|
1
1
|
<%= f.fields_for "#{element.element_type}_#{element.id}" do |e| %>
|
2
|
-
<%= e.label :content, element.name %><br />
|
3
2
|
<%= e.text_field :content, :value => element.content %>
|
4
3
|
<%= e.hidden_field :type, :value => element.element_type %>
|
5
4
|
<%= e.hidden_field :id, :value => element.id %>
|
@@ -1,6 +1,5 @@
|
|
1
1
|
<%= f.fields_for "#{element.element_type}_#{element.id}" do |e| %>
|
2
|
-
<%= e.
|
3
|
-
<%= e.text_area :content, :class => "tinymce", :value => element.content %>
|
2
|
+
<%= e.text_area :content, :class => ScribbleCms.tiny_mce_css, :id => "tinymce_#{element.id}", :value => element.content %>
|
4
3
|
<br />
|
5
4
|
<%= e.hidden_field :type, :value => element.element_type %>
|
6
5
|
<%= e.hidden_field :id, :value => element.id %>
|
data/config/routes.rb
CHANGED
@@ -1,15 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
%w( container_edit container_add_item group_edit group_destroy image_cropper).each do |a|
|
4
|
-
get "/scribbler_admin/#{a}/(:id)", :controller => "scribbler_admin", :action => a
|
5
|
-
end
|
6
|
-
|
7
|
-
get "/scribbler_admin", :controller => "scribbler_admin", :action => "index", :as => :scribbler_admin
|
8
|
-
|
9
|
-
%w(container_update group_update crop_image).each do |a|
|
10
|
-
post "/scribbler_admin/#{a}/(:id)", :controller => "scribbler_admin", :action => a
|
11
|
-
end
|
1
|
+
Scribbler::Engine.routes.draw do
|
12
2
|
|
3
|
+
get "/s/static/pictures/:job/:name.:format" => "scribbler_pictures#show"
|
13
4
|
|
14
5
|
|
15
6
|
end
|
@@ -2,7 +2,6 @@ class CreateScribblers < ActiveRecord::Migration
|
|
2
2
|
def change
|
3
3
|
create_table :scribbler_containers, :force => true do |t|
|
4
4
|
t.string :name
|
5
|
-
t.string :description
|
6
5
|
t.boolean :scaleable, :default => false
|
7
6
|
t.integer :element_id
|
8
7
|
t.timestamps
|
@@ -34,6 +33,15 @@ class CreateScribblers < ActiveRecord::Migration
|
|
34
33
|
t.timestamps
|
35
34
|
end
|
36
35
|
|
36
|
+
create_table :scribbler_vars, :force => true do |t|
|
37
|
+
t.string :name
|
38
|
+
t.text :content
|
39
|
+
t.string :var_type
|
40
|
+
t.integer :group_id
|
41
|
+
t.boolean :released, :default => false
|
42
|
+
t.timestamps
|
43
|
+
end
|
44
|
+
|
37
45
|
create_table :scribbler_images, :force => true do |t|
|
38
46
|
t.string :name
|
39
47
|
t.string :group_id
|
@@ -41,7 +49,8 @@ class CreateScribblers < ActiveRecord::Migration
|
|
41
49
|
t.string :copyright
|
42
50
|
t.string :alt_text
|
43
51
|
t.string :opt_size, :default => "128x128"
|
44
|
-
t.
|
52
|
+
t.string :image_uid
|
53
|
+
t.string :image_name
|
45
54
|
t.timestamps
|
46
55
|
end
|
47
56
|
end
|
data/lib/scribble_cms/engine.rb
CHANGED
@@ -1,6 +1,20 @@
|
|
1
|
-
module
|
1
|
+
module Scribbler
|
2
2
|
class Engine < Rails::Engine
|
3
|
-
|
3
|
+
|
4
|
+
engine_name 'scribbler'
|
5
|
+
|
6
|
+
initializer "dragonfly.scribbler" do
|
7
|
+
|
8
|
+
# Pictures
|
9
|
+
Dragonfly.app(:scribbler).configure do
|
10
|
+
plugin :imagemagick
|
11
|
+
datastore :file, root_path: Rails.root.join('public/system/uploads/scribbler').to_s, store_meta: false
|
12
|
+
url_format "/s/static/pictures/:job/:name.:format"
|
13
|
+
secret Digest::SHA1.hexdigest(Rails.root.to_s)
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
end
|
4
18
|
|
5
19
|
end
|
6
20
|
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
module ScribbleCms
|
2
|
+
module ScribblerControllerPlugin
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
base.extend ClassMethods
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
|
10
|
+
def scribbler_cms_controller(options = {})
|
11
|
+
|
12
|
+
self.send(:include, InstanceMethods)
|
13
|
+
self.send :before_filter, :get_container, :only => %w(container_edit container_update container_add_item)
|
14
|
+
self.send :before_filter, :get_group, :only => %w(group_edit group_update group_destroy)
|
15
|
+
self.cattr_accessor :hide_scribbler_edit_status
|
16
|
+
|
17
|
+
self.hide_scribbler_edit_status = (options[:hide_scribbler_edit_status] == true)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
module InstanceMethods
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
def index
|
29
|
+
@containers = ScribblerContainer.all
|
30
|
+
render "/scribbler_admin/index"
|
31
|
+
end
|
32
|
+
|
33
|
+
# Containers
|
34
|
+
def container_edit
|
35
|
+
render "/scribbler_admin/container_edit"
|
36
|
+
end
|
37
|
+
|
38
|
+
def container_update
|
39
|
+
@container.update_attributes(container_params)
|
40
|
+
flash[:notice] = "Container #{@container.name} was saved"
|
41
|
+
redirect_to :action => "index"
|
42
|
+
end
|
43
|
+
|
44
|
+
def container_add_item
|
45
|
+
@container.get_group("#{@container.id}-#{Time.now.to_i}")
|
46
|
+
flash[:notice] = "Neues Element für #{@container.name} wurde angelegt"
|
47
|
+
redirect_to :back
|
48
|
+
end
|
49
|
+
|
50
|
+
def search
|
51
|
+
@containers = ScribblerContainer.all
|
52
|
+
@items = ScribblerText.find_by_tags(params[:scribbler][:query])
|
53
|
+
render "/scribbler_admin/search"
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
# Groups
|
58
|
+
def group_edit
|
59
|
+
@containers = ScribblerContainer.all
|
60
|
+
render "/scribbler_admin/group_edit"
|
61
|
+
end
|
62
|
+
|
63
|
+
def group_update
|
64
|
+
@group.process_group_data(params.require(:scribbler_group).permit!)
|
65
|
+
flash[:notice] = "Änderungen wurden gespeichert"
|
66
|
+
redirect_to :back
|
67
|
+
end
|
68
|
+
|
69
|
+
def group_destroy
|
70
|
+
@group.destroy
|
71
|
+
flash[:notice] = "Daten wurden gelöscht"
|
72
|
+
redirect_to :action => "index"
|
73
|
+
end
|
74
|
+
|
75
|
+
# images
|
76
|
+
def image_cropper
|
77
|
+
@element = ScribblerImage.find(params[:id])
|
78
|
+
end
|
79
|
+
|
80
|
+
def crop_image
|
81
|
+
@element = ScribblerImage.find(params[:id])
|
82
|
+
@element.update_attributes(image_params)
|
83
|
+
@element.image.reprocess!
|
84
|
+
redirect_to :action => "group_edit", :id => @element.group_id
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def picture
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
# Private - permit parameters
|
94
|
+
private
|
95
|
+
|
96
|
+
def get_container
|
97
|
+
@container = ScribblerContainer.find(params[:id])
|
98
|
+
end
|
99
|
+
|
100
|
+
def get_group
|
101
|
+
@group = ScribblerGroup.find(params[:id])
|
102
|
+
end
|
103
|
+
|
104
|
+
def container_params
|
105
|
+
params.require(:scribbler_container).permit(:description)
|
106
|
+
end
|
107
|
+
|
108
|
+
def image_params
|
109
|
+
params.require(:scribbler_image).permit(:crop_x, :crop_y, :crop_w, :crop_h)
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
@@ -1,29 +1,59 @@
|
|
1
1
|
module ScribbleCms
|
2
2
|
module ScribblerElementSetup
|
3
|
-
|
3
|
+
|
4
4
|
def self.included(base)
|
5
5
|
base.send(:belongs_to, :group, :class_name => "ScribblerGroup", :foreign_key => "group_id", :touch => true)
|
6
6
|
base.send(:validates_presence_of, :group_id)
|
7
7
|
base.send(:before_save, :check_uniqueness)
|
8
|
+
base.send(:smart_search, :on => [
|
9
|
+
{:field_name => :human_name, :boost => 0.7}, {:field_name => "group.human_name", :boost => 0.5}, {:field_name => :searchable_content, :boost => 1}
|
10
|
+
],
|
11
|
+
:conditions => "released = 1"
|
12
|
+
)
|
13
|
+
|
8
14
|
end
|
9
|
-
|
10
|
-
|
15
|
+
|
16
|
+
|
11
17
|
def check_uniqueness
|
12
18
|
items = self.class.where(:name => self.name, :group_id => self.group_id, :released => self.released)
|
13
19
|
items.empty? || items.size == 1
|
14
|
-
end
|
15
|
-
|
20
|
+
end
|
21
|
+
|
16
22
|
def element_type
|
17
23
|
if self.is_a?(ScribblerLink)
|
18
24
|
return :link
|
19
25
|
elsif self.is_a?(ScribblerText) && self.plain
|
20
26
|
return :row
|
21
|
-
elsif self.is_a?(ScribblerText) && !self.plain
|
27
|
+
elsif self.is_a?(ScribblerText) && !self.plain
|
22
28
|
return :text
|
23
|
-
elsif self.is_a?(ScribblerImage)
|
29
|
+
elsif self.is_a?(ScribblerImage)
|
24
30
|
return :image
|
25
|
-
|
26
|
-
|
27
|
-
|
31
|
+
elsif self.is_a?(ScribblerVar)
|
32
|
+
return :var
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def searchable_content
|
37
|
+
case self.element_type
|
38
|
+
when :link
|
39
|
+
return [name, url, title]
|
40
|
+
when :row
|
41
|
+
return content
|
42
|
+
when :text
|
43
|
+
return content
|
44
|
+
when :image
|
45
|
+
when :var
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def human_name
|
50
|
+
I18n.t(self.name, :scope => "scribbler.element_names.#{self.group.name}", :default => self.name.to_s.humanize)
|
51
|
+
end
|
52
|
+
|
53
|
+
def hint
|
54
|
+
h = I18n.t(self.name, :scope => "scribbler.element_hints.#{self.group.name}", :default => "")
|
55
|
+
h.is_a?(Array) ? h.join("") : h
|
56
|
+
end
|
57
|
+
|
28
58
|
end
|
29
|
-
end
|
59
|
+
end
|
data/lib/scribble_cms.rb
CHANGED
@@ -1,5 +1,26 @@
|
|
1
|
+
require "scribble_cms/engine"
|
2
|
+
require 'scribble_cms/scribbler_controller_plugin'
|
3
|
+
require 'scribble_cms/scribbler_element_setup'
|
4
|
+
require 'dragonfly'
|
5
|
+
require "smart_search"
|
6
|
+
|
1
7
|
module ScribbleCms
|
2
|
-
|
8
|
+
mattr_accessor :tiny_mce_css, :tiny_mce_js
|
9
|
+
|
10
|
+
self.tiny_mce_css = "default_tinymce"
|
11
|
+
self.tiny_mce_js = "Alchemy.Tinymce.initAll();"
|
12
|
+
end
|
13
|
+
|
14
|
+
ActionController::Base.send(:include, ScribbleCms::ScribblerControllerPlugin)
|
3
15
|
|
4
|
-
|
5
|
-
|
16
|
+
String.class_eval do
|
17
|
+
|
18
|
+
def replace_scribbler_vars(vars = {})
|
19
|
+
r = self
|
20
|
+
vars.each do |var_name, var_content|
|
21
|
+
r = r.gsub("*#{var_name}*", var_content.to_s)
|
22
|
+
end
|
23
|
+
return r
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
metadata
CHANGED
@@ -1,43 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scribble_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Eck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: friendly_extensions
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: '0.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: '0.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: dragonfly
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: smart_search
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.0.78
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.0.78
|
41
55
|
description: Easy-to-use tool for placing user-editable content in your pages
|
42
56
|
email:
|
43
57
|
- it-support@friends-systems.de
|
@@ -50,7 +64,7 @@ files:
|
|
50
64
|
- app/assets/stylesheets/ext/jquery.Jcrop.css
|
51
65
|
- app/assets/stylesheets/scribbler.css.erb
|
52
66
|
- app/assets/stylesheets/scribbler_layout.css.erb
|
53
|
-
- app/
|
67
|
+
- app/controller/scribbler_pictures_controller.rb
|
54
68
|
- app/helpers/scribbler_admin_helper.rb
|
55
69
|
- app/helpers/scribbler_content_helper.rb
|
56
70
|
- app/models/scribbler_container.rb
|
@@ -58,21 +72,23 @@ files:
|
|
58
72
|
- app/models/scribbler_image.rb
|
59
73
|
- app/models/scribbler_link.rb
|
60
74
|
- app/models/scribbler_text.rb
|
75
|
+
- app/models/scribbler_var.rb
|
61
76
|
- app/views/scribbler_admin/_scribbler_layout.html.erb
|
62
77
|
- app/views/scribbler_admin/_scribbler_sidebar.html.erb
|
63
78
|
- app/views/scribbler_admin/container_edit.html.erb
|
64
79
|
- app/views/scribbler_admin/group_edit.html.erb
|
65
80
|
- app/views/scribbler_admin/image_cropper.html.erb
|
66
81
|
- app/views/scribbler_admin/index.html.erb
|
82
|
+
- app/views/scribbler_admin/search.html.erb
|
67
83
|
- app/views/scribbler_content/forms/_image.html.erb
|
68
84
|
- app/views/scribbler_content/forms/_link.html.erb
|
69
85
|
- app/views/scribbler_content/forms/_row.html.erb
|
70
86
|
- app/views/scribbler_content/forms/_text.html.erb
|
71
87
|
- config/routes.rb
|
72
88
|
- db/migrate/20140313012637_create_scribblers.rb
|
73
|
-
- lib/paperclip_processors/cropper.rb
|
74
89
|
- lib/scribble_cms.rb
|
75
90
|
- lib/scribble_cms/engine.rb
|
91
|
+
- lib/scribble_cms/scribbler_controller_plugin.rb
|
76
92
|
- lib/scribble_cms/scribbler_element_setup.rb
|
77
93
|
homepage: http://www.friends-systems.de
|
78
94
|
licenses: []
|
@@ -88,12 +104,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
104
|
version: '0'
|
89
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
106
|
requirements:
|
91
|
-
- - "
|
107
|
+
- - ">="
|
92
108
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
109
|
+
version: '0'
|
94
110
|
requirements: []
|
95
111
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.4.6
|
97
113
|
signing_key:
|
98
114
|
specification_version: 4
|
99
115
|
summary: Easy-to-use tool for placing user-editable content in your pages
|
@@ -1,77 +0,0 @@
|
|
1
|
-
class ScribblerAdminController < ApplicationController
|
2
|
-
|
3
|
-
before_filter :get_container, :only => %w(container_edit container_update container_add_item )
|
4
|
-
before_filter :get_group, :only => %w(group_edit group_update group_destroy)
|
5
|
-
|
6
|
-
|
7
|
-
def index
|
8
|
-
@containers = ScribblerContainer.all
|
9
|
-
end
|
10
|
-
|
11
|
-
# Containers
|
12
|
-
def container_edit
|
13
|
-
end
|
14
|
-
|
15
|
-
def container_update
|
16
|
-
@container.update_attributes(container_params)
|
17
|
-
flash[:notice] = "Container #{@container.name} was saved"
|
18
|
-
redirect_to :action => "index"
|
19
|
-
end
|
20
|
-
|
21
|
-
def container_add_item
|
22
|
-
@container.get_group("#{@container.id}-#{Time.now.to_i}")
|
23
|
-
flash[:notice] = "Neues Element für #{@container.name} wurde angelegt"
|
24
|
-
redirect_to :back
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
# Groups
|
31
|
-
def group_edit
|
32
|
-
render :layout => false
|
33
|
-
end
|
34
|
-
|
35
|
-
def group_update
|
36
|
-
@group.process_group_data(params[:scribbler_group])
|
37
|
-
flash[:notice] = "Änderungen wurden gespeichert"
|
38
|
-
redirect_to :back
|
39
|
-
end
|
40
|
-
|
41
|
-
def group_destroy
|
42
|
-
@group.destroy
|
43
|
-
flash[:notice] = "Daten wurden gelöscht"
|
44
|
-
redirect_to :action => "index"
|
45
|
-
end
|
46
|
-
|
47
|
-
# images
|
48
|
-
def image_cropper
|
49
|
-
@element = ScribblerImage.find(params[:id])
|
50
|
-
end
|
51
|
-
|
52
|
-
def crop_image
|
53
|
-
@element = ScribblerImage.find(params[:id])
|
54
|
-
@element.update_attributes(image_params)
|
55
|
-
@element.image.reprocess!
|
56
|
-
redirect_to :action => "group_edit", :id => @element.group_id
|
57
|
-
end
|
58
|
-
|
59
|
-
# Private - permit parameters
|
60
|
-
private
|
61
|
-
|
62
|
-
def get_container
|
63
|
-
@container = ScribblerContainer.find(params[:id])
|
64
|
-
end
|
65
|
-
|
66
|
-
def get_group
|
67
|
-
@group = ScribblerGroup.find(params[:id])
|
68
|
-
end
|
69
|
-
|
70
|
-
def container_params
|
71
|
-
params.require(:scribbler_container).permit(:description)
|
72
|
-
end
|
73
|
-
|
74
|
-
def image_params
|
75
|
-
params.require(:scribbler_image).permit(:crop_x, :crop_y, :crop_w, :crop_h)
|
76
|
-
end
|
77
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Paperclip
|
2
|
-
class Cropper < Thumbnail
|
3
|
-
def transformation_command
|
4
|
-
if crop_command
|
5
|
-
crop_command
|
6
|
-
else
|
7
|
-
super
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def crop_command
|
12
|
-
target = @attachment.instance
|
13
|
-
puts "try Croppper"
|
14
|
-
if target.cropping?
|
15
|
-
puts "cropper!"
|
16
|
-
cmd = [" -crop '#{target.crop_w.to_i}x#{target.crop_h.to_i}+#{target.crop_x.to_i}+#{target.crop_y.to_i}'"]
|
17
|
-
cmd << "-auto-orient"
|
18
|
-
cmd << "-resize #{target.opt_image_width}x#{target.opt_image_height}"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|