scribble_cms 0.90 → 0.91

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/ext/tinymce.min.js +9 -8
  3. data/app/assets/javascripts/scribbler.js.coffee.erb +50 -0
  4. data/app/assets/stylesheets/scribbler.css.erb +0 -0
  5. data/app/assets/stylesheets/scribbler_layout.css.erb +0 -0
  6. data/app/controller/scribbler_pictures_controller.rb +0 -0
  7. data/app/helpers/scribbler_admin_helper.rb +0 -0
  8. data/app/helpers/scribbler_content_helper.rb +11 -6
  9. data/app/models/scribbler_container.rb +15 -7
  10. data/app/models/scribbler_group.rb +1 -1
  11. data/app/models/scribbler_image.rb +0 -0
  12. data/app/models/scribbler_link.rb +0 -0
  13. data/app/models/scribbler_text.rb +0 -0
  14. data/app/models/scribbler_var.rb +0 -0
  15. data/app/views/admin/_scribbler_group_form.html.erb +0 -0
  16. data/app/views/scribbler_admin/_scribbler_assets.html.erb +0 -0
  17. data/app/views/scribbler_admin/_scribbler_layout.html.erb +0 -0
  18. data/app/views/scribbler_admin/_scribbler_sidebar.html.erb +0 -0
  19. data/app/views/scribbler_admin/container_edit.html.erb +0 -0
  20. data/app/views/scribbler_admin/group_edit.html.erb +0 -0
  21. data/app/views/scribbler_admin/image_cropper.html.erb +0 -0
  22. data/app/views/scribbler_admin/index.html.erb +0 -0
  23. data/app/views/scribbler_admin/search.html.erb +0 -0
  24. data/app/views/scribbler_content/forms/_image.html.erb +0 -0
  25. data/app/views/scribbler_content/forms/_link.html.erb +0 -0
  26. data/app/views/scribbler_content/forms/_row.html.erb +0 -0
  27. data/app/views/scribbler_content/forms/_text.html.erb +0 -0
  28. data/config/locales/scribbler_defaults.de.yml +0 -0
  29. data/config/routes.rb +0 -0
  30. data/config/scribble_cms.rb +0 -0
  31. data/db/migrate/001_create_scribblers.rb +0 -0
  32. data/db/migrate/002_add_description_to_scribbler_containers.rb +0 -0
  33. data/db/migrate/003_add_names_to_database.rb +18 -0
  34. data/db/migrate/004_add_locale_to_image.rb +6 -0
  35. data/lib/admin/scribbler_groups.rb.template +0 -0
  36. data/lib/scribble_cms.rb +27 -1
  37. data/lib/scribble_cms/engine.rb +0 -0
  38. data/lib/scribble_cms/scribbler_content_creator.rb +0 -0
  39. data/lib/scribble_cms/scribbler_controller_plugin.rb +3 -3
  40. data/lib/scribble_cms/scribbler_element_setup.rb +11 -13
  41. data/lib/tasks/scribbler.rake +4 -1
  42. metadata +11 -9
  43. data/app/assets/javascripts/scribbler.js +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b52f719c1d5435827f95215313e5f4ccafe4ff18
4
- data.tar.gz: d42303b14c769f0721648d59de3ae1b61fbe7418
3
+ metadata.gz: e0e6637e736753b83c6765682834efd36d6f7f68
4
+ data.tar.gz: 7d127aed8ab97e3eb2db56da390518b702f20af9
5
5
  SHA512:
6
- metadata.gz: 1eb5cbe14e2c82fedc89e98c49ceb502d0e616d783fbfddc351acaa7b89f78025107069a3b0ead18130b61a1b031900343d5bfd0d48d8775d9e8af6d863d69d8
7
- data.tar.gz: 77a035a8d80d0d1b51759ccc9b85627162abfbf18051fe82102c81b92bccbb8b96864e2a618c41ef2e2c7d8fe11a177491b63d4a4a8556edb7cc2c9fb1743e10
6
+ metadata.gz: bcdac4f8961d90314b6f1e76800a9454ea329d06716643e43ecaa65a6b275ec03ddc3f6f9ce8d926e7d8f6b8db86db2c5e10c2a5c576a2e0c9fdce7872d9ab9f
7
+ data.tar.gz: 0bd3515eb4f655bc2a91d2034b190ca0abcb856b5a8648ca7c1acd71c81c514a361111a600d003b34173872456099a60f8dd8f59d13f7f94b0e97915a7f583e6
@@ -28137,14 +28137,15 @@
28137
28137
  return a.getParam("max_height", 65535)
28138
28138
  },
28139
28139
  r = function(b) {
28140
- var c = b.settings,
28141
- d = c.skin,
28142
- e = c.skin_url;
28143
- if (d !== !1) {
28144
- var f = d ? d : "lightgray";
28145
- e = e ? b.documentBaseURI.toAbsolute(e) : a.baseURL + "/skins/" + f
28146
- }
28147
- return e
28140
+ //var c = b.settings,
28141
+ // d = c.skin,
28142
+ // e = c.skin_url;
28143
+ //if (d !== !1) {
28144
+ // var f = d ? d : "lightgray";
28145
+ // e = e ? b.documentBaseURI.toAbsolute(e) : a.baseURL + "/skins/" + f
28146
+ //}
28147
+ //return e
28148
+ return null
28148
28149
  },
28149
28150
  s = function(a) {
28150
28151
  return a.settings.skin === !1
@@ -0,0 +1,50 @@
1
+ window.initScribblerTinyMce = ->
2
+ tinymce.remove("textarea")
3
+ $('textarea').not('.plain').not(".mini-editor").tinymce
4
+ <% ScribbleCms::TinyMceCustomConfig.settings.base.to_h.each do |key, value| %>
5
+ <% if value.is_a?(String) %>
6
+ <%= key %>: "<%= value %>"
7
+ <% else %>
8
+ <%= key %>: <%= value %>
9
+ <% end %>
10
+ <% end %>
11
+
12
+ plugins: "autolink code colorpicker hr image link lists paste table textcolor autoresize"
13
+ toolbar: "undo redo | styleselect | bold italic | link unlink image | alignleft aligncenter alignright alignjustify | bullist numlist table | forecolor fontsizeselect | removeformat code"
14
+
15
+ <% settings_for_full = ScribbleCms::TinyMceCustomConfig.settings.default.to_h.merge(ScribbleCms::TinyMceCustomConfig.settings.full.to_h) %>
16
+ <% settings_for_full.each do |key, value| %>
17
+ <% if value.is_a?(String) %>
18
+ <%= key %>: "<%= value %>"
19
+ <% else %>
20
+ <%= key %>: <%= value %>
21
+ <% end %>
22
+ <% end %>
23
+
24
+
25
+ $('textarea.mini-editor').tinymce
26
+ <% ScribbleCms::TinyMceCustomConfig.settings.base.to_h.each do |key, value| %>
27
+ <% if value.is_a?(String) %>
28
+ <%= key %>: "<%= value %>"
29
+ <% else %>
30
+ <%= key %>: <%= value %>
31
+ <% end %>
32
+ <% end %>
33
+
34
+ plugins: "autolink link lists paste autoresize"
35
+ toolbar: "bold italic | link unlink | bullist numlist | removeformat code"
36
+
37
+ <% settings_for_mini = ScribbleCms::TinyMceCustomConfig.settings.default.to_h.merge(ScribbleCms::TinyMceCustomConfig.settings.mini.to_h) %>
38
+ <% settings_for_mini.each do |key, value| %>
39
+ <% if value.is_a?(String) %>
40
+ <%= key %>: "<%= value %>"
41
+ <% else %>
42
+ <%= key %>: <%= value %>
43
+ <% end %>
44
+ <% end %>
45
+
46
+ $(document).ready ->
47
+ window.initScribblerTinyMce()
48
+
49
+ $(document).ajaxComplete ->
50
+ window.initScribblerTinyMce()
File without changes
File without changes
File without changes
File without changes
@@ -8,9 +8,9 @@ module ScribblerContentHelper
8
8
  yield(container)
9
9
  end
10
10
 
11
- def scribbler_group(container, group, &block)
11
+ def scribbler_group(container, group, options = {}, &block)
12
12
  scribbler_container(container) do |c|
13
- c.scribbler_group(group) do |g|
13
+ c.scribbler_group(group, options) do |g|
14
14
  yield(g)
15
15
  end
16
16
  end
@@ -23,14 +23,19 @@ module ScribblerContentHelper
23
23
 
24
24
  if options[:i18n]
25
25
  group = "#{group}-#{I18n.locale}"
26
+ options[:locale] = I18n.locale
27
+ options[:localized] = true
28
+ else
29
+ options[:locale] = nil
30
+ options[:localized] = false
26
31
  end
27
-
28
- scribbler_group(container.to_s, group.to_s) do |g|
32
+
33
+ scribbler_group(container.to_s, group.to_s, options.slice(:locale, :localized, :default)) do |g|
29
34
  v = g.send(type.to_s, name.to_s, options)
30
35
  if v.blank? && options[:default]
31
- options[:default]
36
+ options[:default].try(:html_safe) || options[:default]
32
37
  else
33
- return v
38
+ return v.try(:html_safe) || v
34
39
  end
35
40
  end
36
41
  end
@@ -18,7 +18,6 @@ class ScribblerContainer < ActiveRecord::Base
18
18
  validates_uniqueness_of :name, :on => :create, :message => "must be unique"
19
19
 
20
20
  #=== Callbacks
21
- before_create { self.description = self.name }
22
21
 
23
22
 
24
23
  # => END
@@ -27,16 +26,25 @@ class ScribblerContainer < ActiveRecord::Base
27
26
  self.groups.sort_by {|g| g.human_name.to_s }
28
27
  end
29
28
 
30
- def scribbler_group(name, &block)
31
- yield(self.get_group(name))
29
+ def scribbler_group(name, options = {}, &block)
30
+ yield(self.get_group(name, options))
32
31
  end
33
32
 
34
- def get_group(name)
35
- ScribblerGroup.where(:name => name, :container_id => self.id).first || ScribblerGroup.create(:name => name, :container_id => self.id)
33
+ def get_group(name, options = {})
34
+ data = {:name => name, :container_id => self.id}.merge(options.except(:default))
35
+ ScribblerGroup.find_or_create_by(data)
36
36
  end
37
37
 
38
- def description
39
- I18n.t(self.name, :scope => "scribbler.container_names", :default => self.name.humanize)
38
+ def description(l = I18n.locale)
39
+ d = self.try("name_#{l}")
40
+ if d.blank?
41
+ d = self.try(I18n.default_locale)
42
+ end
43
+ if d.blank?
44
+ return I18n.t(self.name, :scope => "scribbler.container_names", :default => self.name.humanize)
45
+ else
46
+ return d
47
+ end
40
48
  end
41
49
 
42
50
 
@@ -157,7 +157,7 @@ class ScribblerGroup < ActiveRecord::Base
157
157
  end
158
158
 
159
159
  def human_name
160
- I18n.t(self.name, :scope => "scribbler.group_names", :default => self.name.humanize) rescue self.name
160
+ self.human_name_de.presence || (I18n.t(self.name, :scope => "scribbler.group_names", :default => self.name.humanize) rescue self.name)
161
161
  end
162
162
 
163
163
  def container_description
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/config/routes.rb CHANGED
File without changes
File without changes
File without changes
@@ -0,0 +1,18 @@
1
+ class AddNamesToDatabase < ActiveRecord::Migration
2
+ def change
3
+ add_column :scribbler_containers, :human_name_de, :string
4
+ add_column :scribbler_containers, :human_name_en, :string
5
+ add_column :scribbler_containers, :description_de, :text
6
+ add_column :scribbler_containers, :description_en, :text
7
+
8
+ remove_column :scribbler_containers, :description
9
+
10
+ add_column :scribbler_groups, :human_name_de, :string
11
+ add_column :scribbler_groups, :human_name_en, :string
12
+ add_column :scribbler_groups, :localized, :boolean, :default => false
13
+ add_column :scribbler_groups, :locale, :string
14
+
15
+ add_column :scribbler_texts, :human_name_de, :string
16
+ add_column :scribbler_texts, :human_name_en, :string
17
+ end
18
+ end
@@ -0,0 +1,6 @@
1
+ class AddLocaleToImage < ActiveRecord::Migration
2
+ def change
3
+ add_column :scribbler_images, :locale, :string
4
+ add_column :scribbler_images, :localized, :boolean, default: false
5
+ end
6
+ end
File without changes
data/lib/scribble_cms.rb CHANGED
@@ -18,6 +18,32 @@ module ScribbleCms
18
18
  def self.css_files
19
19
  ['ext/tinymce.skin.css', 'ext/tinymce.content.min.css']
20
20
  end
21
+
22
+ module TinyMceCustomConfig
23
+ mattr_accessor :settings
24
+ @@settings = OpenStruct.new
25
+
26
+ @@settings.base = {
27
+ mode: 'textareas',
28
+ theme: 'modern',
29
+ skin: false,
30
+ menubar: '',
31
+ elementpath: false,
32
+ statusbar: true,
33
+ valid_elements: '*[*]',
34
+ fontsize_formats: "8px 10px 12px 14px 16px 18px 24pt 36px 48px",
35
+ convert_urls: false
36
+ }
37
+
38
+ # appplies to both full and mini editor
39
+ @@settings.default = OpenStruct.new
40
+
41
+ #applies to full editor only
42
+ @@settings.full = OpenStruct.new
43
+
44
+ # applies to mini editor only
45
+ @@settings.mini = OpenStruct.new
46
+ end
21
47
 
22
48
  end
23
49
 
@@ -30,7 +56,7 @@ String.class_eval do
30
56
  vars.each do |var_name, var_content|
31
57
  r = r.gsub("*#{var_name}*", var_content.to_s)
32
58
  end
33
- return r
59
+ return r.html_safe
34
60
  end
35
61
 
36
62
  end
File without changes
File without changes
@@ -10,8 +10,8 @@ module ScribbleCms
10
10
  def scribbler_cms_controller(options = {})
11
11
 
12
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)
13
+ self.send :before_action, :get_container, :only => %w(container_edit container_update container_add_item)
14
+ self.send :before_action, :get_group, :only => %w(group_edit group_update group_destroy)
15
15
  self.cattr_accessor :hide_scribbler_edit_status
16
16
 
17
17
  self.hide_scribbler_edit_status = (options[:hide_scribbler_edit_status] == true)
@@ -63,7 +63,7 @@ module ScribbleCms
63
63
  def group_update
64
64
  @group.process_group_data(params.require(:scribbler_group).permit!)
65
65
  flash[:notice] = "Änderungen wurden gespeichert"
66
- redirect_to :back
66
+ redirect_to :action => "group_edit", id: @group.id
67
67
  end
68
68
 
69
69
  def group_destroy
@@ -4,7 +4,6 @@ module ScribbleCms
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
- base.send(:before_save, :check_uniqueness)
8
7
  base.send(:smart_search, :on => [
9
8
  {:field_name => :human_name, :boost => 0.7}, {:field_name => "group.human_name", :boost => 0.5}, {:field_name => :searchable_content, :boost => 1}
10
9
  ],
@@ -14,11 +13,6 @@ module ScribbleCms
14
13
  end
15
14
 
16
15
 
17
- def check_uniqueness
18
- items = self.class.where(:name => self.name, :group_id => self.group_id, :released => self.released)
19
- items.empty? || items.size == 1
20
- end
21
-
22
16
  def element_type
23
17
  if self.is_a?(ScribblerLink)
24
18
  return :link
@@ -47,13 +41,17 @@ module ScribbleCms
47
41
  end
48
42
 
49
43
  def human_name
50
- s = "scribbler.element_names.#{self.group.name}.#{self.name}"
51
-
52
- if I18n.exists?(s)
53
- I18n.t(s)
54
- else
55
- I18n.t(self.name, scope: "scribbler.element_names_default")
56
- end
44
+ if self[:"human_name_#{I18n.locale}"].present?
45
+ self[:"human_name_#{I18n.locale}"]
46
+ else
47
+ s = "scribbler.element_names.#{self.group.name}.#{self.name}"
48
+
49
+ if I18n.exists?(s)
50
+ I18n.t(s)
51
+ else
52
+ I18n.t(self.name, scope: "scribbler.element_names_default")
53
+ end
54
+ end
57
55
  end
58
56
 
59
57
  def hint
@@ -4,7 +4,10 @@ namespace :scribbler do
4
4
  task :export_scribbler_data => :environment do
5
5
  config = ActiveRecord::Base.connection_config
6
6
  tables = ActiveRecord::Base.connection.tables.grep(/scribbler_/)
7
- `mysqldump -h#{config[:host]} -u#{config[:username]} --password='#{config[:password]}' #{config[:database]} #{tables.join(' ')} > '#{Rails.root}/tmp/scribbler_#{Time.now.to_i}.sql'`
7
+ out_path = "#{Rails.root}/tmp/scribbler_#{Time.now.to_i}.sql"
8
+ `mysqldump -h#{config[:host]} -u#{config[:username]} --password='#{config[:password]}' #{config[:database]} #{tables.join(' ')} > '#{out_path}'`
9
+ puts "scribbler data exported:"
10
+ puts out_path
8
11
  end
9
12
 
10
13
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scribble_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.90'
4
+ version: '0.91'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Eck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-13 00:00:00.000000000 Z
11
+ date: 2018-10-29 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.2.6
19
+ version: 0.2.9
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.2.6
26
+ version: 0.2.9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dragonfly
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 0.0.91
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 0.0.91
55
55
  description: Easy-to-use tool for placing user-editable content in your pages
56
56
  email:
57
57
  - florian.eck@el-digital.de
@@ -72,7 +72,7 @@ files:
72
72
  - app/assets/javascripts/ext/jquery.Jcrop.min.js
73
73
  - app/assets/javascripts/ext/jquery.tinymce.min.js
74
74
  - app/assets/javascripts/ext/tinymce.min.js
75
- - app/assets/javascripts/scribbler.js
75
+ - app/assets/javascripts/scribbler.js.coffee.erb
76
76
  - app/assets/stylesheets/ext/jquery.Jcrop.css
77
77
  - app/assets/stylesheets/ext/tinymce.content.min.css
78
78
  - app/assets/stylesheets/ext/tinymce.skin.scss
@@ -105,6 +105,8 @@ files:
105
105
  - config/scribble_cms.rb
106
106
  - db/migrate/001_create_scribblers.rb
107
107
  - db/migrate/002_add_description_to_scribbler_containers.rb
108
+ - db/migrate/003_add_names_to_database.rb
109
+ - db/migrate/004_add_locale_to_image.rb
108
110
  - lib/admin/scribbler_groups.rb.template
109
111
  - lib/scribble_cms.rb
110
112
  - lib/scribble_cms/engine.rb
@@ -1,38 +0,0 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
3
-
4
- window.initScribblerTinyMce = function(){
5
- tinymce.remove("textarea")
6
- $('textarea').not('.plain').not(".mini-editor").tinymce({
7
- mode: 'textareas',
8
- theme: 'modern',
9
- plugins: "autolink code colorpicker hr image link lists paste table textcolor autoresize",
10
- menubar: '',
11
- toolbar: "undo redo | styleselect | bold italic | link unlink image | alignleft aligncenter alignright | bullist numlist table | textcolor fontsizeselect | code",
12
- valid_elements : '*[*]',
13
- elementpath: false,
14
- statusbar: true,
15
- fontsize_formats: "8px 10px 12px 14px 16px 18px 24pt 36px 48px",
16
- convert_urls: false
17
- });
18
-
19
- $('textarea.mini-editor').tinymce({
20
- mode: 'textareas',
21
- theme: 'modern',
22
- plugins: "autolink link lists paste textcolor autoresize",
23
- menubar: '',
24
- toolbar: "bold italic | link unlink | bullist numlist | code",
25
- valid_elements : '*[*]',
26
- elementpath: false,
27
- statusbar: true,
28
- fontsize_formats: "8px 10px 12px 14px 16px 18px 24pt 36px 48px"
29
- });
30
- }
31
-
32
- $(document).ready(function() {
33
- window.initScribblerTinyMce()
34
- });
35
-
36
- $(document).ajaxComplete(function() {
37
- window.initScribblerTinyMce()
38
- });