smithycms 0.6.3 → 0.6.4

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: fc00eaebe1ef8d662fd4dbaae75f25ab02127b0b
4
- data.tar.gz: 5cf96f60b15a40ecb5c383582e4d48e5fb02b7bc
3
+ metadata.gz: aadc29031beec8515e3d69eb3f75db5790617e71
4
+ data.tar.gz: 656013c9a4e9ffd3cdd3452d9284e87b00ebc727
5
5
  SHA512:
6
- metadata.gz: 04a08fea2940abbd1c6e1a99772e26a76a99158c3e4fad9512f2c940215bf97263a501e6775fec00e285c9b2c6cac1fc89483f1c1fa9cba23a8754ea4a96c187
7
- data.tar.gz: ad030d0871a974a5adbe400ce16ca5bed5815d2648756b7596286ddfeb47a4460ce4540f36cce9916848e3a4e733ebd17da39ba67489bc9e854d90e79229e967
6
+ metadata.gz: eea557bbd85a451c81753bcde2c9a9da07d6eea16be5f660c58bea628f55ac94fd156a07f8dfc3adb4bce6e9403bdb1c366d46fe27b521b700bd6aa51635ff4f
7
+ data.tar.gz: 1029c52c582830bd96aecb665526b9e206b52ffe6772816930433c157ce815328bfb8a19ca47ec13b0b95b2453897a97ddd3ccd5b54ac30257b1e746ad2c701c
@@ -2,13 +2,15 @@ window.ace_edit = (id, template_type, name) ->
2
2
  name = 'template_content' if !name
3
3
  textarea_id = name + '-' + id
4
4
  editor_id = name + '_editor-' + id
5
- $('#'+editor_id).show()
6
- editor = ace.edit(editor_id)
7
- $textarea = $('#'+textarea_id)
5
+ $editor = $("##{editor_id}")
6
+ $textarea = $("##{textarea_id}")
7
+ $editor.show();
8
8
  $textarea.hide()
9
- create_ace_toolbar(editor, $textarea.attr('data-assets-url'), $textarea.attr('data-pages-url'))
9
+ editor = ace.edit(editor_id)
10
+ create_ace_toolbar(editor, $editor.attr('data-assets-url'), $editor.attr('data-pages-url'))
10
11
  session = editor.getSession()
11
12
  session.setMode("ace/mode/" + template_type)
13
+ editor.renderer.setShowGutter(false) if template_type == 'markdown'
12
14
  session.setValue($textarea.val())
13
15
  session.setTabSize(2)
14
16
  session.setUseSoftTabs(true)
@@ -144,4 +146,9 @@ edit_selection = (editor, command) ->
144
146
  session.insert({ row: current_row, column: 0 }, '### ')
145
147
  when 'h4'
146
148
  session.insert({ row: current_row, column: 0 }, '#### ')
147
- editor.focus()
149
+ editor.focus()
150
+
151
+ $ ->
152
+ $('.ace_editor').each ->
153
+ return unless $(this).data('id') && $(this).data('type') && $(this).data('name')
154
+ ace_edit($(this).data('id'), $(this).data('type'), $(this).data('name'))
@@ -9,14 +9,14 @@
9
9
  * compiled file, but it's generally better to create a new file per style scope.
10
10
  *
11
11
  *= require_self
12
- *= depend_on smithy/bootstrap_and_overrides.css.scss
13
- *= depend_on smithy/assets.css.scss
14
- *= depend_on smithy/content_blocks.css.scss
15
- *= depend_on smithy/layout.css.scss
16
- *= depend_on smithy/forms.css.scss
17
- *= depend_on smithy/guides.css.scss
18
- *= depend_on smithy/pages.css.scss
19
- *= depend_on smithy/templates.css.scss
12
+ *= depend_on smithy/bootstrap_and_overrides.scss
13
+ *= depend_on smithy/assets.scss
14
+ *= depend_on smithy/content_blocks.scss
15
+ *= depend_on smithy/layout.scss
16
+ *= depend_on smithy/forms.scss
17
+ *= depend_on smithy/guides.scss
18
+ *= depend_on smithy/pages.scss
19
+ *= depend_on smithy/templates.scss
20
20
  */
21
21
 
22
22
  @import 'bootstrap_and_overrides';
@@ -15,16 +15,7 @@ module Smithy
15
15
  end
16
16
 
17
17
  def render_markdown_input(fieldname, editor_name, form_builder)
18
- content_for(:javascript) do
19
- javascript_tag do
20
- raw("var editor = ace_edit('#{form_builder.object.id || 'new'}', 'markdown', '#{editor_name}');\n") +
21
- raw("editor.renderer.setShowGutter(false);")
22
- end
23
- end
24
- hint = "Use markdown syntax for formatting. You can also use HTML directly. <a href=\"#{guide_path('markdown')}\" data-toggle=\"remote-load\" data-target=\"#content-guide\">See our markdown syntax reference</a>".html_safe
25
- form_builder.input(fieldname, :as => :text, :input_html => { :class => "span12", :id => "#{editor_name}-#{form_builder.object.id || 'new'}" }, :hint => hint) +
26
- content_tag(:div, nil, :id => "#{editor_name}_editor-#{form_builder.object.id || 'new'}", :class => "#{editor_name}_editor ace_editor") +
27
- content_tag(:div, nil, :id => 'content-guide')
18
+ form_builder.input fieldname, as: 'markdown'
28
19
  end
29
20
 
30
21
  private
@@ -0,0 +1,33 @@
1
+ require 'formtastic-bootstrap/inputs/text_input'
2
+ class MarkdownInput < FormtasticBootstrap::Inputs::TextInput
3
+ def to_html
4
+ self.options[:hint] = markdown_hint if self.options[:hint].blank?
5
+ bootstrap_wrapping do
6
+ builder.text_area(method, form_control_input_html_options) +
7
+ builder.template.content_tag(:div, nil, id: editor_id, class: 'ace_editor', data: { id: id, type: :markdown, name: dom_id, assets_url: builder.template.selector_modal_assets_path, pages_url: builder.template.selector_modal_pages_path }) +
8
+ builder.template.content_tag(:div, nil, id: 'content-guide')
9
+ end
10
+ end
11
+
12
+ def id
13
+ builder.object.id || 'new'
14
+ end
15
+
16
+ def textarea_id
17
+ "#{dom_id}-#{id}"
18
+ end
19
+
20
+ def editor_id
21
+ "#{dom_id}_editor-#{id}"
22
+ end
23
+
24
+ def input_html_options
25
+ {
26
+ class: "col-md-12",
27
+ }.merge(super).merge(id: textarea_id)
28
+ end
29
+
30
+ def markdown_hint
31
+ "Use markdown syntax for formatting. You can also use HTML directly. <a href=\"#{builder.template.guide_path('markdown')}\" data-toggle=\"remote-load\" data-target=\"#content-guide\">See our markdown syntax reference</a>".html_safe
32
+ end
33
+ end
@@ -63,7 +63,7 @@ module Smithy
63
63
  assets = assets.page(page).per(per_page)
64
64
  # TODO: need to check for regex flag
65
65
  if params[:search][:value].present?
66
- assets = assets.where("name like :search or content_type like :search", search: "%#{params[:search][:value]}%")
66
+ assets = assets.where("LOWER(name) LIKE LOWER(:search) or LOWER(content_type) LIKE LOWER(:search)", search: "%#{params[:search][:value]}%")
67
67
  end
68
68
  assets
69
69
  end
@@ -89,4 +89,4 @@ module Smithy
89
89
  params[:order][:"0"][:dir] == "desc" ? "desc" : "asc"
90
90
  end
91
91
  end
92
- end
92
+ end
@@ -1,12 +1,3 @@
1
1
  <%= f.inputs do %>
2
- <%= f.input :content, :as => :text, :input_html => { :class => "col-md-12", :id => "template_content-#{f.object.id || 'new'}", data: { assets_url: selector_modal_assets_path, pages_url: selector_modal_pages_path } }, :hint => "Use markdown syntax for formatting. You can also use HTML directly. <a href=\"#{guide_path('markdown')}\" data-toggle=\"remote-load\" data-target=\"#content-guide\">See our markdown syntax reference</a>".html_safe %>
3
- <div id="template_content_editor-<%= f.object.id || 'new' %>" class="template_content_editor"></div>
4
- <div id="content-guide"></div>
5
- <% end %>
6
-
7
- <% content_for :javascript do %>
8
- <%= javascript_tag do %>
9
- var editor = ace_edit('<%= f.object.id || 'new' %>', 'markdown', '');
10
- editor.renderer.setShowGutter(false);
11
- <% end %>
2
+ <%= f.input :content, as: :markdown %>
12
3
  <% end %>
@@ -6,16 +6,7 @@
6
6
  <%= f.input :link_url %>
7
7
  <% end %>
8
8
  <%= f.inputs "Content (optional)" do %>
9
- <%= f.input :content, :as => :text, :input_html => { :class => "col-md-12", :id => "image_content-#{f.object.id || 'new'}" }, :hint => "Use markdown syntax for formatting. You can also use HTML directly. <a href=\"#{guide_path('markdown')}\" data-toggle=\"remote-load\" data-target=\"#content-guide\">See our markdown syntax reference</a>".html_safe %>
10
- <div id="image_content_editor-<%= f.object.id || 'new' %>" class="ace_editor"></div>
11
- <div id="content-guide"></div>
12
- <% end %>
13
-
14
- <% content_for :javascript do %>
15
- <%= javascript_tag do %>
16
- var editor = ace_edit('<%= f.object.id || 'new' %>', 'markdown');
17
- editor.renderer.setShowGutter(false);
18
- <% end %>
9
+ <%= f.input :content, as: :markdown %>
19
10
  <% end %>
20
11
 
21
12
  <%= f.inputs "Image Sizing (optional)" do %>
@@ -7,16 +7,6 @@ Rails.application.routes.prepend do
7
7
  mount Refile.app, at: Refile.mount_point, as: :refile_app
8
8
  end
9
9
 
10
- # aws = {
11
- # access_key_id: 'AKIAJTMAZVFVSBOL6AKQ',
12
- # secret_access_key: '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',
13
- # region: 'us-west-2',
14
- # bucket: 'testsmithy',
15
- # }
16
-
17
- # Refile.cache = Refile::S3.new(prefix: "cache", **aws)
18
- # Refile.store = Refile::S3.new(prefix: "store", **aws)
19
-
20
10
  if ENV['AWS_ACCESS_KEY_ID'].present? && ENV['AWS_SECRET_ACCESS_KEY'].present? && ENV['AWS_S3_BUCKET'].present?
21
11
  aws = {
22
12
  access_key_id: ENV['AWS_ACCESS_KEY_ID'],
@@ -3,7 +3,7 @@ class MigrateDragonflyImages < ActiveRecord::Migration
3
3
  if Refile.store.is_a? Refile::S3
4
4
  prefix = Refile.store.instance_variable_get(:@prefix)
5
5
  bucket = Refile.store.instance_variable_get(:@bucket)
6
- Smithy::Asset.where('file_id LIKE ?', 'uploads/%').each do |asset|
6
+ Smithy::Asset.where('file_id LIKE ? OR file_id ~ ?', 'uploads/%', '\d{4}\/\d{2}\/\d{2}\/').each do |asset|
7
7
  new_file_id = asset.file_id.gsub(/([^a-z0-9]|(uploads\/)|(assets\/))/i, '')
8
8
  s3_object = bucket.object(asset.file_id)
9
9
  new_s3_object = bucket.object([*prefix, new_file_id].join('/'))
@@ -25,4 +25,4 @@ class MigrateDragonflyImages < ActiveRecord::Migration
25
25
  asset.update_column(:file_content_type, asset.content_type)
26
26
  end
27
27
  end
28
- end
28
+ end
data/lib/smithy/engine.rb CHANGED
@@ -9,7 +9,8 @@ module Smithy
9
9
  end
10
10
  end
11
11
 
12
- config.autoload_paths += %W(#{config.root}/lib)
12
+ # app/inputs for formtastic
13
+ config.autoload_paths += %W(#{config.root}/lib #{config.root}/app/inputs)
13
14
 
14
15
  config.to_prepare do
15
16
  # include the Smithy helpers in the host application
@@ -1,3 +1,3 @@
1
1
  module Smithy
2
- VERSION = "0.6.3"
2
+ VERSION = "0.6.4"
3
3
  end
data/lib/smithy.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "smithy/engine"
1
+ require 'smithy/engine'
2
2
  # libraries
3
3
  require 'smithy/dependencies'
4
4
  # config
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smithycms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Glen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-03 00:00:00.000000000 Z
11
+ date: 2016-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -134,28 +134,28 @@ dependencies:
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: 2.3.1
137
+ version: 3.1.3
138
138
  type: :runtime
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: 2.3.1
144
+ version: 3.1.3
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: formtastic-bootstrap
147
147
  requirement: !ruby/object:Gem::Requirement
148
148
  requirements:
149
149
  - - "~>"
150
150
  - !ruby/object:Gem::Version
151
- version: 3.0.0
151
+ version: 3.1.1
152
152
  type: :runtime
153
153
  prerelease: false
154
154
  version_requirements: !ruby/object:Gem::Requirement
155
155
  requirements:
156
156
  - - "~>"
157
157
  - !ruby/object:Gem::Version
158
- version: 3.0.0
158
+ version: 3.1.1
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: friendly_id
161
161
  requirement: !ruby/object:Gem::Requirement
@@ -750,6 +750,7 @@ files:
750
750
  - app/helpers/smithy/pages_helper.rb
751
751
  - app/helpers/smithy/settings_helper.rb
752
752
  - app/helpers/smithy/templates_helper.rb
753
+ - app/inputs/markdown_input.rb
753
754
  - app/models/smithy/asset.rb
754
755
  - app/models/smithy/asset_source.rb
755
756
  - app/models/smithy/assets_datatable.rb
@@ -857,7 +858,6 @@ files:
857
858
  - db/migrate/20150420145923_update_to_refile.rb
858
859
  - db/migrate/20150427185319_migrate_dragonfly_images.rb
859
860
  - db/migrate/20160122152402_create_smithy_asset_sources.rb
860
- - db/migrate/20160127160513_look_for_direct_asset_links.rb
861
861
  - lib/smithy.rb
862
862
  - lib/smithy/asset_link.rb
863
863
  - lib/smithy/content_blocks.rb
@@ -1,13 +0,0 @@
1
- class LookForDirectAssetLinks < ActiveRecord::Migration
2
- def change
3
- Smithy::Content.where("content LIKE '%s3.amazonaws.com%' OR content LIKE '%/uploads/assets/%'").each do |content|
4
- content.page_contents.each do |page_content|
5
- say "[WARNING] Direct Link found in the Page: #{page_content.page.title} - #{page_content.page.url}"
6
- say "Content Block(s): #{page_content.label}", true
7
- say content.content.scan(/(?:[^\s]*s3\.amazonaws\.com|\/uploads\/assets)[^\s]*/).join('/n'), true
8
- say "You can find the new asset url on the smithy/assets page", true
9
- end
10
- end
11
- end
12
- end
13
-