smithycms 0.4.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/images/smithy/icons/_blank.png +0 -0
  4. data/app/assets/images/smithy/icons/_page.png +0 -0
  5. data/app/assets/images/smithy/icons/doc.png +0 -0
  6. data/app/assets/images/smithy/icons/pdf.png +0 -0
  7. data/app/assets/images/smithy/icons/ppt.png +0 -0
  8. data/app/assets/images/smithy/icons/txt.png +0 -0
  9. data/app/assets/images/smithy/icons/xls.png +0 -0
  10. data/app/assets/images/smithy/icons/xlsx.png +0 -0
  11. data/app/assets/stylesheets/smithy/bootstrap_and_overrides.css.scss +0 -9
  12. data/app/assets/stylesheets/smithy/pages.css.scss +1 -2
  13. data/app/controllers/smithy/pages_controller.rb +3 -3
  14. data/app/helpers/smithy/assets_helper.rb +21 -0
  15. data/app/models/smithy/asset.rb +22 -0
  16. data/app/models/smithy/page.rb +8 -2
  17. data/app/models/smithy/page_content.rb +9 -3
  18. data/app/views/layouts/smithy/shared/_nav.html.erb +11 -12
  19. data/app/views/smithy/assets/_asset.html.erb +7 -1
  20. data/app/views/smithy/assets/_form.html.erb +9 -2
  21. data/app/views/smithy/content_blocks/_content_block.html.erb +1 -1
  22. data/app/views/smithy/content_blocks/_secondary_nav.html.erb +3 -3
  23. data/app/views/smithy/content_pieces/new.html.erb +7 -0
  24. data/app/views/smithy/page_contents/new.html.erb +1 -1
  25. data/app/views/smithy/pages/_container.html.erb +2 -2
  26. data/app/views/smithy/pages/_form.html.erb +4 -2
  27. data/app/views/smithy/pages/_page.html.erb +10 -4
  28. data/app/views/smithy/pages/_page_related.html.erb +2 -2
  29. data/app/views/smithy/pages/_parent.html.erb +3 -3
  30. data/app/views/smithy/pages/_root.html.erb +2 -2
  31. data/app/views/smithy/templates/_secondary_nav.html.erb +1 -1
  32. data/config/initializers/dragonfly.rb +1 -1
  33. data/lib/smithy/liquid/drops/page.rb +2 -2
  34. data/lib/smithy/liquid/filters/uri.rb +15 -0
  35. data/lib/smithy/liquid/rendering.rb +3 -3
  36. data/lib/smithy/liquid/tags/include_file.rb +93 -0
  37. data/lib/smithy/liquid/tags/link.rb +32 -0
  38. data/lib/smithy/liquid/tags/nav.rb +10 -3
  39. data/lib/smithy/liquid.rb +3 -0
  40. data/lib/smithy/version.rb +1 -1
  41. metadata +47 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79918fd91d87d994cd44391609c4f02dea58d75b
4
- data.tar.gz: 4520429f79396782b010ad85a8401635b649001c
3
+ metadata.gz: 46b442d24b777496f47746a02f495814b346f10d
4
+ data.tar.gz: d014278bc16f0b3daae221689e885479e19ed70d
5
5
  SHA512:
6
- metadata.gz: 644afd46f79eee07ebc4de65ad74e19ff7aa06446450d23520e0a5e99363fdb354f57a4014ced7045de2771164f18a83e07469b55596ab27f55c34eeb4b5fdec
7
- data.tar.gz: f8c68c89b49651488a3a85dc5ba8ac18713ec9499267dfa05e23588ee1047496f6939de27c6bf108da02dce7d31aa3a706117a37abc0b08215091a9ff29ff1d8
6
+ metadata.gz: 0ca4425f6d1c9ba4ff1980dc5edf468757c68d8b1641922a740ee5608d77993c98e4983fb27c0d1b187bce79b4aaeb6daacb5166b315bbae02c4b2475d5674ab
7
+ data.tar.gz: d303d9d7a72f098f2d45a0b87851089cf3b055124db87ec38369a518e8e4bd1822ac7380d2f8492188c32cff9f450490477949d4e9e55dd99729c680f8d55435
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Smithy CMS
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/smithycms.png)](http://badge.fury.io/rb/smithycms)
4
- [![Code Climate](https://codeclimate.com/github/sterrym/smithy.png)](https://codeclimate.com/github/sterrym/smithy)
4
+ [![Code Climate](https://codeclimate.com/github/sterrym/smithycms.png)](https://codeclimate.com/github/sterrym/smithycms)
5
5
  [![Build Status](https://travis-ci.org/sterrym/smithycms.png?branch=master)](https://travis-ci.org/sterrym/smithycms)
6
6
  [![Coverage Status](https://coveralls.io/repos/sterrym/smithycms/badge.png)](https://coveralls.io/r/sterrym/smithycms)
7
7
  [![Dependency Status](https://gemnasium.com/sterrym/smithycms.png)](https://gemnasium.com/sterrym/smithycms)
@@ -1,12 +1,3 @@
1
1
  @import "bootstrap";
2
2
  @import "bootstrap-responsive";
3
3
  @import "font-awesome";
4
- .icon-white,
5
- .nav > .active > a > [class^="icon-"],
6
- .nav > .active > a > [class*=" icon-"],
7
- .dropdown-menu > li > a:hover > [class^="icon-"],
8
- .dropdown-menu > li > a:hover > [class*=" icon-"],
9
- .dropdown-menu > .active > a > [class^="icon-"],
10
- .dropdown-menu > .active > a > [class*=" icon-"] {
11
- background-image: none;
12
- }
@@ -7,7 +7,7 @@
7
7
  .back { background:#444; }
8
8
  .back > a { border-top:1px solid #444; }
9
9
  .add-page a { color:#888; text-align:right; padding-right:45px; }
10
-
10
+ .attenuate { color:#666; }
11
11
  }
12
12
 
13
13
  #side .page-list > li {
@@ -32,4 +32,3 @@
32
32
  padding-left:6px;
33
33
  }
34
34
  }
35
-
@@ -72,16 +72,16 @@ module Smithy
72
72
  end
73
73
 
74
74
  def load_page
75
- @page = Page.find(params[:id])
75
+ @page = Page.includes(:contents).find(params[:id])
76
76
  @root = @page if Page.root == @page
77
77
  set_publish
78
78
  end
79
79
 
80
80
  def load_page_from_path
81
81
  if smithy_current_user
82
- @page = Page.friendly.find(page_path)
82
+ @page = Page.includes(:contents).friendly.find(page_path)
83
83
  else
84
- @page = Page.published.friendly.find(page_path)
84
+ @page = Page.includes(:contents).published.friendly.find(page_path)
85
85
  end
86
86
  redirect_to @page.external_link and return false if @page.external_link?
87
87
  end
@@ -5,5 +5,26 @@ module Smithy
5
5
  return unless asset
6
6
  image_tag(asset.file.url(:host => "#{request.protocol}#{request.host_with_port}"), :alt => asset.name)
7
7
  end
8
+
9
+ def file_type_icon(asset)
10
+ case asset.file_type
11
+ when :image
12
+ nil
13
+ when :pdf
14
+ 'smithy/icons/pdf.png'
15
+ when :word
16
+ 'smithy/icons/doc.png'
17
+ when :excel
18
+ 'smithy/icons/xls.png'
19
+ when :powerpoint
20
+ 'smithy/icons/ppt.png'
21
+ when :text
22
+ 'smithy/icons/txt.png'
23
+ when :document
24
+ 'smithy/icons/_page.png'
25
+ when :default
26
+ 'smithy/icons/_blank.png'
27
+ end
28
+ end
8
29
  end
9
30
  end
@@ -24,6 +24,28 @@ module Smithy
24
24
  dragonfly_attachments[:file].to_value
25
25
  end
26
26
 
27
+ def file_type
28
+ ext = File.extname(file.name).sub(/^\./, '')
29
+ case ext
30
+ when 'jpg', 'jpeg', 'gif', 'png'
31
+ :image
32
+ when 'pdf'
33
+ :pdf
34
+ when 'doc', 'docx'
35
+ :word
36
+ when 'xls', 'xlsx'
37
+ :excel
38
+ when 'ppt', 'pps', 'pptx', 'ppsx'
39
+ :powerpoint
40
+ when 'txt'
41
+ :text
42
+ when 'rtf'
43
+ :document
44
+ else
45
+ :default
46
+ end
47
+ end
48
+
27
49
  def to_liquid
28
50
  {
29
51
  'id' => self.id,
@@ -21,6 +21,7 @@ module Smithy
21
21
  scope :published, -> { where('published_at <= ?', Time.now) }
22
22
 
23
23
  attr_accessor :publish
24
+ attr_reader :liquid_context
24
25
 
25
26
  def container?(container_name)
26
27
  containers.where(:name => container_name).count > 0
@@ -44,10 +45,15 @@ module Smithy
44
45
  self.published_at?
45
46
  end
46
47
 
48
+ def render(liquid_context)
49
+ @liquid_context = liquid_context
50
+ self.template.liquid_template.render(liquid_context)
51
+ end
52
+
47
53
  def render_container(container_name)
48
54
  return '' unless container?(container_name)
49
55
  Rails.cache.fetch(self.container_cache_key(container_name)) do
50
- self.contents_for_container_name(container_name).map(&:render).join("\n\n")
56
+ self.contents_for_container_name(container_name).map{|c| c.render(liquid_context) }.join("\n\n")
51
57
  end
52
58
  end
53
59
 
@@ -67,7 +73,7 @@ module Smithy
67
73
  def container_cache_key(container_name)
68
74
  # fetch the most recently adjusted content and add the updated_at timestamp to the cache_key
69
75
  content_last_updated = if self.contents_for_container_name(container_name).count > 0
70
- self.contents_for_container_name(container_name).order(nil).order('created_at DESC').first.updated_at
76
+ self.contents_for_container_name(container_name).order(nil).order('updated_at DESC').first.updated_at
71
77
  else
72
78
  self.updated_at
73
79
  end
@@ -25,14 +25,20 @@ module Smithy
25
25
  return unless attributes.present?
26
26
  klass = content_block_type.safe_constantize || "Smithy::#{content_block_type}".safe_constantize
27
27
  if klass
28
- self.content_block = klass.find_or_initialize_by_id(attributes.delete(:id))
28
+ self.content_block = klass.find_or_initialize_by(id: attributes.delete(:id))
29
29
  self.content_block.attributes = attributes
30
30
  self.content_block
31
31
  end
32
32
  end
33
33
 
34
- def render
35
- content_block_template.liquid_template.render(self.to_liquid)
34
+ def render(liquid_context)
35
+ liquid_context.stack do
36
+ # push the default assigns into a smithy namespace. They'll still be in the
37
+ # scopes as the original values as well, but this ensures they don't get clobbered
38
+ liquid_context.merge('smithy' => liquid_context.scopes.last)
39
+ liquid_context.merge(self.to_liquid)
40
+ content_block_template.liquid_template.render(liquid_context)
41
+ end
36
42
  end
37
43
 
38
44
  def to_liquid
@@ -3,31 +3,30 @@
3
3
  </header>
4
4
  <div id="main-nav" class="navbar navbar-inverse">
5
5
  <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
6
- <span class="icon-bar"></span>
7
- <span class="icon-bar"></span>
8
- <span class="icon-bar"></span>
6
+ <span class="fa fa-bars"></span>
9
7
  </a>
10
8
  <div class="navbar-inner">
11
9
  <div class="container">
12
10
  <div class="nav-collapse clearfix">
13
11
  <%- if smithy_current_user -%>
14
12
  <ul class="nav">
15
- <li><%= link_to "<i class=\"icon-sitemap\"></i> Manage Content".html_safe, pages_path %></li>
16
- <li><%= link_to "<i class=\"icon-file\"></i> Images &amp; Files".html_safe, assets_path %></li>
13
+ <li><%= link_to "<i class=\"fa fa-sitemap\"></i> Manage Content".html_safe, pages_path %></li>
14
+ <li><%= link_to "<i class=\"fa fa-file\"></i> Images &amp; Files".html_safe, assets_path %></li>
17
15
  </ul>
18
16
  <ul class="nav pull-right">
19
- <li><%= link_to "<i class=\"icon-arrow-right\"></i> View Site".html_safe, root_path %></li>
17
+ <li><%= link_to "<i class=\"fa fa-arrow-right\"></i> View Site".html_safe, root_path %></li>
20
18
  <li class="dropdown">
21
- <a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="icon-cogs"></i> Admin<b class="caret"></b></a>
19
+ <a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-cogs"></i> Admin<b class="caret"></b></a>
22
20
  <ul class="dropdown-menu">
23
- <li><%= link_to "<i class=\"icon-book\"></i> Templates".html_safe, templates_path %></li>
24
- <li><%= link_to "<i class=\"icon-list-alt\"></i> Content Blocks".html_safe, content_blocks_path %></li>
25
- <li><%= link_to users_path do %><i class="icon-user"></i> Users<% end %></li>
26
- <li><%= link_to "<i class=\"icon-cog\"></i> Settings".html_safe, settings_path %></li>
21
+ <li><%= link_to "<i class=\"fa fa-book\"></i> Templates".html_safe, templates_path %></li>
22
+ <li><%= link_to "<i class=\"fa fa-list-alt\"></i> Content Blocks".html_safe, content_blocks_path %></li>
23
+ <li><%= link_to users_path do %><i class="fa fa-user"></i> Users<% end %></li>
24
+ <li><%= link_to "<i class=\"fa fa-cog\"></i> Settings".html_safe, settings_path %></li>
25
+ <li><%= link_to "<i class=\"fa fa-refresh\"></i> Site Cache".html_safe, cache_path %></li>
27
26
  </ul>
28
27
  </li>
29
28
  <% if respond_to?(:logout_path) %>
30
- <li><%= link_to "<i class=\"icon-signout\"></i> Logout".html_safe, logout_path, :method => :delete %></li>
29
+ <li><%= link_to "<i class=\"fa fa-signout\"></i> Logout".html_safe, logout_path, :method => :delete %></li>
31
30
  <% end %>
32
31
  </ul>
33
32
  <% end %>
@@ -1,6 +1,12 @@
1
1
  <li>
2
2
  <div class="thumbnail clearfix">
3
- <%= link_to "<img src=\"#{asset.file.thumb("170x114#").url}\" width=\"170\" height=\"114\" alt=\"\">".html_safe, asset.file.url %>
3
+ <%= link_to asset.file.remote_url do %>
4
+ <% if asset.file_type == :image %>
5
+ <%= image_tag asset.file.thumb("170x114#").url, width: 170, height: 114, alt: '' %>
6
+ <% else %>
7
+ <div style="width:170px;height:78px;padding-top:36px;text-align:center;"><%= image_tag file_type_icon(asset), alt: '' %></div>
8
+ <% end %>
9
+ <% end %>
4
10
  <p class="name"><strong><%= asset.name %></strong></p>
5
11
  <div class="pull-right">
6
12
  <%= link_to "Edit", [:edit, asset], class: "btn btn-mini" %>
@@ -4,8 +4,15 @@
4
4
  <%= f.input :file, :as => :file %>
5
5
  <%= f.input :retained_file, :as => :hidden %>
6
6
  <% if @asset.file %>
7
- <div><img src="<%= @asset.file.thumb("300x300").url %>" alt=""></div>
8
- <div><%= link_to @asset.file.remote_url, @asset.file.remote_url %></div>
7
+ <div>
8
+ <%= link_to asset.file.remote_url do %>
9
+ <% if asset.file_type == :image %>
10
+ <img src="<%= @asset.file.thumb("300x300").url %>" alt="">
11
+ <% else %>
12
+ <%= image_tag file_type_icon(asset), alt: '' %>
13
+ <% end %>
14
+ <% end %>
15
+ </div>
9
16
  <% end %>
10
17
  <% end %>
11
18
  <%= f.actions :submit %>
@@ -1 +1 @@
1
- <li<%= raw ' class="active"' if action_name == "edit" && @content_block == content_block %>><%= link_to content_block.name, [:edit, content_block] %></li>
1
+ <li<%= raw ' class="active"' if action_name == "edit" && @content_block == content_block %>><%= link_to content_block.name.titleize, [:edit, content_block] %></li>
@@ -4,9 +4,9 @@
4
4
  <%= render @content_blocks %>
5
5
  </ul>
6
6
 
7
- <!--
8
7
  <div class="btn-group actions pull-right">
9
- <%= link_to "<i class=\"icon-plus\"></i> Add Template <span class=\"caret\"></span>".html_safe, new_template_path, :class => 'dropdown-toggle btn btn-inverse', 'data-toggle' => 'dropdown', 'data-target' => '#', :role => 'button' %>
8
+ <%= link_to [:new, :content_block], :class => 'btn btn-inverse', :role => 'button' do %>
9
+ <i class="fa fa-plus"></i> Add Content Block
10
+ <% end %>
10
11
  </div>
11
- -->
12
12
  <% end %>
@@ -1 +1,8 @@
1
1
  <% content_for :title, "New #{klass_name}" %>
2
+
3
+ <%= semantic_form_for @record do |f| %>
4
+ <%= f.inputs do %>
5
+ <%= f.inputs *accessible_attributes %>
6
+ <% end %>
7
+ <%= f.actions :submit %>
8
+ <% end %>
@@ -18,7 +18,7 @@
18
18
  <tbody>
19
19
  <% @content_blocks.each do |content_block| %>
20
20
  <tr>
21
- <td><button class="btn btn-small page_content_block" type="button" data-content_block="<%= content_block.name %>"><%= content_block.name.capitalize %></button></td>
21
+ <td style="white-space:nowrap"><button class="btn btn-small page_content_block" type="button" data-content_block="<%= content_block.name %>"><%= content_block.name.titleize %></button></td>
22
22
  <td><%= content_block.description %></td>
23
23
  </tr>
24
24
  <% end %>
@@ -4,7 +4,7 @@
4
4
  <% @page.contents.for_container(container.name).each do |page_content| %>
5
5
  <%= content_tag_for :tr, page_content do %>
6
6
  <td>
7
- <i class="icon-reorder handle"></i>
7
+ <i class="fa fa-reorder handle"></i>
8
8
  <%= link_to "edit", edit_page_content_path(@page.id, page_content), class: "btn btn-small btn-primary" %>
9
9
  </td>
10
10
  <td><strong><%= page_content.label %></strong></td>
@@ -13,7 +13,7 @@
13
13
  <td>
14
14
  <div class="pull-right">
15
15
  <%= link_to "preview", preview_page_content_path(@page.id, page_content), class: "btn btn-small", data: { previewtoggle: "modal" } %>
16
- <%= link_to "<i class=\"icon-trash\"></i> delete".html_safe, page_content_path(@page.id, page_content), method: :delete, data: { confirm: "Do you really want to delete this content?" }, class: "btn btn-small btn-danger" %>
16
+ <%= link_to "<i class=\"fa fa-trash\"></i> delete".html_safe, page_content_path(@page.id, page_content), method: :delete, data: { confirm: "Do you really want to delete this content?" }, class: "btn btn-small btn-danger" %>
17
17
  </div>
18
18
  </td>
19
19
  <% end %>
@@ -20,6 +20,7 @@
20
20
  <%= f.input :parent, :include_blank => false, :collection => tree_for_select unless !@page.parent_id? %>
21
21
  <%= f.input :show_in_navigation, :label => "Show page in site navigation" %>
22
22
  <%= f.input :template, :collection => Smithy::Template.templates, :include_blank => false %>
23
+ <%= render :partial => "smithy/pages/page_fields", :locals => { :f => f } if File.exists?(Rails.root.join('app', 'views', 'smithy', 'pages', '_page_fields.html.erb')) %>
23
24
  <% end %>
24
25
  <% if @page.persisted? && @page.external_link.blank? %>
25
26
  <h3>Content</h3>
@@ -29,14 +30,15 @@
29
30
  <%= f.input :external_link, :hint => "This page is currently being redirected to #{link_to @page.external_link, @page.external_link}".html_safe %>
30
31
  <% end %>
31
32
  <% end %>
32
- <h3 data-toggle="collapse" data-target="#page-meta">Meta <i class="icon-caret-down"></i></h3>
33
+ <h3 data-toggle="collapse" data-target="#page-meta">Meta <i class="fa fa-caret-down"></i></h3>
33
34
  <%= content_tag :div, :id => "page-meta", :class => "collapse" do %>
34
35
  <%= f.inputs do %>
35
36
  <%= f.input(:external_link) unless @page.external_link? %>
36
37
  <%= f.input :cache_length, :hint => "In seconds (eg. 600 is 10 minutes)" %>
38
+ <%= render :partial => "smithy/pages/meta_fields", :locals => { :f => f } if File.exists?(Rails.root.join('app', 'views', 'smithy', 'pages', '_meta_fields.html.erb')) %>
37
39
  <% end %>
38
40
  <% end %>
39
- <h3 data-toggle="collapse" data-target="#page-seo">SEO <i class="icon-caret-down"></i></h3>
41
+ <h3 data-toggle="collapse" data-target="#page-seo">SEO <i class="fa fa-caret-down"></i></h3>
40
42
  <%= content_tag :div, :id => "page-seo", :class => "collapse" do %>
41
43
  <%= f.inputs do %>
42
44
  <%= f.input :browser_title %>
@@ -1,6 +1,12 @@
1
+ <%
2
+ icon = nil
3
+ icon ||= 'folder' unless page.leaf?
4
+ icon ||= 'edit' unless page.published?
5
+ icon ||= 'file'
6
+ icon = "#{icon} attenuate" unless page.show_in_navigation?
7
+ -%>
1
8
  <%= content_tag :li, :id => dom_id(page), :class => ["clearfix child", (params[:id].to_i == page.id ? "active" : nil)].compact.join(' ') do %>
2
- <%= link_to "<i class=\"icon-#{ page.leaf? ? (page.published? ? 'file' : 'edit') : 'folder-close'}\"></i><span>#{page.title}</span>".html_safe, edit_page_path(page.id), :class => "edit-page" %>
3
- <%#= raw '<i class="icon-caret-right pull-right"></i>' unless page.leaf? %>
4
- <%= link_to "<i class=\"icon-plus\"></i>".html_safe, new_page_path(:page => {:parent_id => page.id}), :class => "add-page" %>
5
- <i class="icon-reorder handle"></i>
9
+ <%= link_to "<i class=\"fa fa-#{ icon }\"></i><span> #{page.title}</span>".html_safe, edit_page_path(page.id), :class => "edit-page" %>
10
+ <%= link_to "<i class=\"fa fa-plus\"></i>".html_safe, new_page_path(:page => {:parent_id => page.id}), :class => "add-page" %>
11
+ <i class="fa fa-reorder handle"></i>
6
12
  <% end %>
@@ -3,9 +3,9 @@
3
3
  <div class="well well-small">
4
4
  <dl>
5
5
  <dt>Status</dt>
6
- <dd><%= raw @page.published_at? ? '<i class="icon-check"></i>' : '<i class="icon-check-empty"></i>' %> Published</dd>
6
+ <dd><%= raw @page.published_at? ? '<i class="fa fa-check"></i>' : '<i class="fa fa-square"></i>' %> Published</dd>
7
7
  <dt>Navigation</dt>
8
- <dd><%= raw @page.show_in_navigation? ? '<i class="icon-check"></i>' : '<i class="icon-check-empty"></i>' %> Show in Navigation</dd>
8
+ <dd><%= raw @page.show_in_navigation? ? '<i class="fa fa-check"></i>' : '<i class="fa fa-square"></i>' %> Show in Navigation</dd>
9
9
  <dt>Template</dt>
10
10
  <dd><%= @page.template.name %></dd>
11
11
  <dt>Creator</dt>
@@ -1,10 +1,10 @@
1
- <li class="back"><%= link_to "<span class=\"btn btn-mini btn-inverse\"><i class=\"icon-caret-left\"></i> Back to #{@parent.title}</span>".html_safe, edit_page_path(@parent.id) %></li>
1
+ <li class="back"><%= link_to "<span class=\"btn btn-mini btn-inverse\"><i class=\"fa fa-caret-left\"></i> Back to #{@parent.title}</span>".html_safe, edit_page_path(@parent.id) %></li>
2
2
  <%- if !@page.persisted? || @page.leaf? -%>
3
3
  <%= render @parent.children %>
4
4
  <% elsif @page.persisted? %>
5
- <li<%= ' class="active"'.html_safe if params[:id].to_i == @page.id %>><%= link_to "<i class=\"icon-folder-close\"></i> #{@page.title}".html_safe, edit_page_path(@page.id) %></li>
5
+ <li<%= ' class="active"'.html_safe if params[:id].to_i == @page.id %>><%= link_to "<i class=\"fa fa-folder\"></i> #{@page.title}".html_safe, edit_page_path(@page.id) %></li>
6
6
  <%= render @page.children %>
7
7
  <% end %>
8
8
  <% if @page.persisted? %>
9
- <li class="add-page"><%= link_to "<i class=\"icon-plus\"></i> Add Page".html_safe, new_page_path(:page => { :parent_id => @parent.id }) %></li>
9
+ <li class="add-page"><%= link_to "<i class=\"fa fa-plus\"></i> Add Page".html_safe, new_page_path(:page => { :parent_id => @parent.id }) %></li>
10
10
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <%= content_tag :li, :id => dom_id(@root), :class => ['home', "clearfix", (params[:id].to_i == @root.id ? "active" : nil)].join(' ') do %>
2
- <%= link_to "<i class=\"icon-home\"></i> #{@root.title}".html_safe, edit_page_path(@root.id) %>
2
+ <%= link_to "<i class=\"fa fa-home\"></i> #{@root.title}".html_safe, edit_page_path(@root.id) %>
3
3
  <% end %>
4
4
  <%= render @root.children %>
5
- <li class="add-page"><%= link_to "<i class=\"icon-plus\"></i> Add Page".html_safe, new_page_path(:page => { :parent_id => @root.id }) %></li>
5
+ <li class="add-page"><%= link_to "<i class=\"fa fa-plus\"></i> Add Page".html_safe, new_page_path(:page => { :parent_id => @root.id }) %></li>
@@ -11,7 +11,7 @@
11
11
  </ul>
12
12
 
13
13
  <div class="btn-group actions pull-right">
14
- <%= link_to "<i class=\"icon-plus\"></i> Add Template <span class=\"caret\"></span>".html_safe, new_template_path, :class => 'dropdown-toggle btn btn-inverse', 'data-toggle' => 'dropdown', 'data-target' => '#', :role => 'button' %>
14
+ <%= link_to "<i class=\"fa fa-plus\"></i> Add Template <span class=\"caret\"></span>".html_safe, new_template_path, :class => 'dropdown-toggle btn btn-inverse', 'data-toggle' => 'dropdown', 'data-target' => '#', :role => 'button' %>
15
15
  <ul class="dropdown-menu" role="menu">
16
16
  <% Smithy::Template.types.each do |tt| %>
17
17
  <li><%= link_to tt.capitalize, new_template_path(:template => { :template_type => tt }) %></li>
@@ -4,7 +4,7 @@ require 'dragonfly'
4
4
  Dragonfly.app.configure do
5
5
  plugin :imagemagick
6
6
 
7
- protect_from_dos_attacks true
7
+ verify_urls true
8
8
  secret "7fb765cbc9f1d92d5d1a56a43193d34d4f9b54dced3e62cb4e42f25d2500dd0f"
9
9
 
10
10
  convert_command = `which convert`.strip.presence || "/usr/local/bin/convert"
@@ -99,8 +99,8 @@ module Smithy
99
99
 
100
100
  private
101
101
  def generated_browser_titles
102
- titles = _source.self_and_ancestors.map(&:title)
103
- titles.shift unless _source.root? # keep all except the first element unless root
102
+ titles = _source.self_and_ancestors.map(&:title).reverse
103
+ titles.pop unless _source.root? # keep all except the last element unless root
104
104
  titles << site.title if site.title.present?
105
105
  titles
106
106
  end
@@ -0,0 +1,15 @@
1
+ module Smithy
2
+ module Liquid
3
+ module Filters
4
+ module Uri
5
+ def urlescape(input)
6
+ ::CGI::escape(input.to_s)
7
+ end
8
+ def urlunescape(input)
9
+ ::CGI.unescape(input.to_s)
10
+ end
11
+ end
12
+ ::Liquid::Template.register_filter(Uri)
13
+ end
14
+ end
15
+ end
@@ -6,10 +6,10 @@ module Smithy
6
6
 
7
7
  def render_smithy_page
8
8
  if smithy_current_user
9
- output = @page.template.liquid_template.render(liquid_context)
9
+ output = @page.render(liquid_context)
10
10
  else
11
11
  output = Rails.cache.fetch("#{@page.cache_key}-render_smithy_page") do
12
- @page.template.liquid_template.render(liquid_context)
12
+ @page.render(liquid_context)
13
13
  end
14
14
  end
15
15
  render :text => output, :layout => false
@@ -21,7 +21,7 @@ module Smithy
21
21
  end
22
22
 
23
23
  def liquid_context
24
- ::Liquid::Context.new({}, smithy_default_assigns, smithy_default_registers, false)
24
+ ::Liquid::Context.new({}, smithy_default_assigns, smithy_default_registers, !Rails.env.production?)
25
25
  end
26
26
 
27
27
  def smithy_default_assigns
@@ -0,0 +1,93 @@
1
+ module Liquid
2
+
3
+ # IncludeFile allows templates to relate with other templates
4
+ #
5
+ # Simply include another template:
6
+ #
7
+ # {% include_file 'product' %}
8
+ #
9
+ # IncludeFile a template with a local variable:
10
+ #
11
+ # {% include_file 'product' with products[0] %}
12
+ #
13
+ # IncludeFile a template for a collection:
14
+ #
15
+ # {% include_file 'product' for products %}
16
+ #
17
+ class IncludeFile < Tag
18
+ Syntax = /(#{QuotedFragment}+)(\s+(?:with|for)\s+(#{QuotedFragment}+))?/o
19
+
20
+ def initialize(tag_name, markup, tokens)
21
+ if markup =~ Syntax
22
+
23
+ @template_name = $1
24
+ @variable_name = $3
25
+ @attributes = {}
26
+
27
+ markup.scan(TagAttributes) do |key, value|
28
+ @attributes[key] = value
29
+ end
30
+
31
+ else
32
+ raise SyntaxError.new("Error in tag 'include_file' - Valid syntax: include_file '[template]' (with|for) [object|collection]")
33
+ end
34
+
35
+ super
36
+ end
37
+
38
+ def parse(tokens)
39
+ end
40
+
41
+ def render(context)
42
+ partial = load_cached_partial(context)
43
+ variable = context[@variable_name || @template_name[1..-2]]
44
+
45
+ context.stack do
46
+ @attributes.each do |key, value|
47
+ context[key] = context[value]
48
+ end
49
+
50
+ if variable.is_a?(Array)
51
+ variable.collect do |var|
52
+ context[@template_name[1..-2]] = var
53
+ partial.render(context)
54
+ end
55
+ else
56
+ context[@template_name[1..-2]] = variable
57
+ partial.render(context)
58
+ end
59
+ end
60
+ end
61
+
62
+ private
63
+ def load_cached_partial(context)
64
+ cached_partials = context.registers[:cached_partials] || {}
65
+ template_name = context[@template_name]
66
+
67
+ if cached = cached_partials[template_name]
68
+ return cached
69
+ end
70
+ source = read_template_from_file_system(context)
71
+ partial = Liquid::Template.parse(source)
72
+ cached_partials[template_name] = partial
73
+ context.registers[:cached_partials] = cached_partials
74
+ partial
75
+ end
76
+
77
+ def read_template_from_file_system(context)
78
+ file_system = Liquid::Template.file_system
79
+
80
+ # make read_template_file call backwards-compatible.
81
+ case file_system.method(:read_template_file).arity
82
+ when 1
83
+ file_system.read_template_file(context[@template_name])
84
+ when 2
85
+ file_system.read_template_file(context[@template_name], context)
86
+ else
87
+ raise ArgumentError, "file_system.read_template_file expects two parameters: (template_name, context)"
88
+ end
89
+ end
90
+ end
91
+
92
+ Template.register_tag('include_file', IncludeFile)
93
+ end
@@ -0,0 +1,32 @@
1
+ module Smithy
2
+ module Liquid
3
+ module Tags
4
+ class LinkTo < ::Liquid::Block
5
+ SyntaxHelp = "Syntax Error in tag 'link_to' - Valid syntax: link_to [url]"
6
+ Syntax = /(#{::Liquid::QuotedFragment})\s*([=!<>a-z_]+)?\s*(#{::Liquid::QuotedFragment})?/o
7
+
8
+ def initialize(tag_name, markup, tokens)
9
+ @tokens = tokens
10
+ @url = markup.strip
11
+ @url = :back if @url == ':back'
12
+ super
13
+ end
14
+
15
+ def render(context)
16
+ controller = context.registers[:controller]
17
+ context.stack do
18
+ controller.view_context.link_to(@url) do
19
+ render_all(nodes, context)
20
+ end
21
+ end
22
+ end
23
+
24
+ private
25
+ def nodes
26
+ @nodelist.map{|n| n.is_a?(String) ? n.strip : n }
27
+ end
28
+ end
29
+ ::Liquid::Template.register_tag('link_to', Smithy::Liquid::Tags::LinkTo)
30
+ end
31
+ end
32
+ end
@@ -19,6 +19,7 @@ module Smithy
19
19
  @options[:depth] = 100 if @options[:depth] == 0
20
20
  @options[:wrapper] = @options[:wrapper] == "false" ? false : true
21
21
  @options[:include_root] = @options[:include_root] == "true" ? true : false
22
+ @options[:root] = @options[:root_id].present? ? Smithy::Page.find(@options[:root_id]) : Smithy::Page.root
22
23
  else
23
24
  raise ::Liquid::SyntaxError.new("Syntax Error in 'nav' - Valid syntax: nav <site|page|section> <options>")
24
25
  end
@@ -69,18 +70,24 @@ module Smithy
69
70
  def root_node
70
71
  case @source
71
72
  when 'site', 'site-section'
72
- Smithy::Page.root
73
+ @options[:root]
73
74
  when 'page'
74
75
  @page
75
76
  when 'section'
76
- @page == Smithy::Page.root ? @page : @page.self_and_ancestors.second
77
+ @page == @options[:root] ? @page : section_page
77
78
  end
78
79
  end
79
80
 
80
81
  private
82
+ def section_page
83
+ ancestors = @page.self_and_ancestors
84
+ idx = ancestors.index(@options[:root])
85
+ ancestors[idx+1].present? ? ancestors[idx+1] : ancestors.second
86
+ end
87
+
81
88
  def write_child_list_items?(parent, depth)
82
89
  return false unless parent.present? && !parent.leaf?
83
- return true if @source == 'site-section' && @page.self_and_ancestors.include?(parent)
90
+ return true if @source == '`-section' && @page.self_and_ancestors.include?(parent)
84
91
  depth > @options[:depth] ? false : true
85
92
  end
86
93
 
data/lib/smithy/liquid.rb CHANGED
@@ -2,7 +2,10 @@ require 'smithy/liquid/database'
2
2
  require 'smithy/liquid/rendering'
3
3
  require 'smithy/liquid/filters/asset_tag'
4
4
  require 'smithy/liquid/filters/resize'
5
+ require 'smithy/liquid/filters/uri'
5
6
  require 'smithy/liquid/tags/asset'
6
7
  require 'smithy/liquid/tags/csrf'
7
8
  require 'smithy/liquid/tags/html'
9
+ require 'smithy/liquid/tags/include_file'
10
+ require 'smithy/liquid/tags/link'
8
11
  require 'smithy/liquid/tags/nav'
@@ -1,3 +1,3 @@
1
1
  module Smithy
2
- VERSION = "0.4.5"
2
+ VERSION = "0.5.0"
3
3
  end
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.4.5
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Glen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-05 00:00:00.000000000 Z
11
+ date: 2014-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.4
19
+ version: 4.1.6
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: 4.0.4
26
+ version: 4.1.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: jquery-rails
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,56 +44,56 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 3.0.0rc
47
+ version: 3.0.1
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: 3.0.0rc
54
+ version: 3.0.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bootstrap-sass
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 2.3.2.1
61
+ version: 2.3.2.2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 2.3.2.1
68
+ version: 2.3.2.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: dragonfly
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ~>
74
74
  - !ruby/object:Gem::Version
75
- version: 1.0.2
75
+ version: 1.0.7
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
- version: 1.0.2
82
+ version: 1.0.7
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: dragonfly-s3_data_store
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ~>
88
88
  - !ruby/object:Gem::Version
89
- version: 1.0.3
89
+ version: 1.0.4
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
- version: 1.0.3
96
+ version: 1.0.4
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: font-awesome-sass-rails
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -128,56 +128,56 @@ dependencies:
128
128
  requirements:
129
129
  - - ~>
130
130
  - !ruby/object:Gem::Version
131
- version: 2.3.rc
131
+ version: 2.3.1
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ~>
137
137
  - !ruby/object:Gem::Version
138
- version: 2.3.rc
138
+ version: 2.3.1
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: formtastic-bootstrap
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ~>
144
144
  - !ruby/object:Gem::Version
145
- version: '2.1'
145
+ version: 2.1.3
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ~>
151
151
  - !ruby/object:Gem::Version
152
- version: '2.1'
152
+ version: 2.1.3
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: friendly_id
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ~>
158
158
  - !ruby/object:Gem::Version
159
- version: 5.0.3
159
+ version: 5.0.4
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - ~>
165
165
  - !ruby/object:Gem::Version
166
- version: 5.0.3
166
+ version: 5.0.4
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: httparty
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ~>
172
172
  - !ruby/object:Gem::Version
173
- version: 0.13.0
173
+ version: 0.13.1
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - ~>
179
179
  - !ruby/object:Gem::Version
180
- version: 0.13.0
180
+ version: 0.13.1
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: jquery-fileupload-rails
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -212,14 +212,14 @@ dependencies:
212
212
  requirements:
213
213
  - - ~>
214
214
  - !ruby/object:Gem::Version
215
- version: 0.15.1
215
+ version: 0.16.1
216
216
  type: :runtime
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - ~>
221
221
  - !ruby/object:Gem::Version
222
- version: 0.15.1
222
+ version: 0.16.1
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: liquid
225
225
  requirement: !ruby/object:Gem::Requirement
@@ -280,16 +280,16 @@ dependencies:
280
280
  name: capybara
281
281
  requirement: !ruby/object:Gem::Requirement
282
282
  requirements:
283
- - - ~>
283
+ - - '>='
284
284
  - !ruby/object:Gem::Version
285
- version: 2.2.1
285
+ version: '0'
286
286
  type: :development
287
287
  prerelease: false
288
288
  version_requirements: !ruby/object:Gem::Requirement
289
289
  requirements:
290
- - - ~>
290
+ - - '>='
291
291
  - !ruby/object:Gem::Version
292
- version: 2.2.1
292
+ version: '0'
293
293
  - !ruby/object:Gem::Dependency
294
294
  name: coveralls
295
295
  requirement: !ruby/object:Gem::Requirement
@@ -322,16 +322,16 @@ dependencies:
322
322
  name: factory_girl_rails
323
323
  requirement: !ruby/object:Gem::Requirement
324
324
  requirements:
325
- - - ~>
325
+ - - '>='
326
326
  - !ruby/object:Gem::Version
327
- version: 4.4.1
327
+ version: '0'
328
328
  type: :development
329
329
  prerelease: false
330
330
  version_requirements: !ruby/object:Gem::Requirement
331
331
  requirements:
332
- - - ~>
332
+ - - '>='
333
333
  - !ruby/object:Gem::Version
334
- version: 4.4.1
334
+ version: '0'
335
335
  - !ruby/object:Gem::Dependency
336
336
  name: fakeweb
337
337
  requirement: !ruby/object:Gem::Requirement
@@ -378,16 +378,16 @@ dependencies:
378
378
  name: guard
379
379
  requirement: !ruby/object:Gem::Requirement
380
380
  requirements:
381
- - - ~>
381
+ - - '>='
382
382
  - !ruby/object:Gem::Version
383
- version: 2.5.1
383
+ version: '0'
384
384
  type: :development
385
385
  prerelease: false
386
386
  version_requirements: !ruby/object:Gem::Requirement
387
387
  requirements:
388
- - - ~>
388
+ - - '>='
389
389
  - !ruby/object:Gem::Version
390
- version: 2.5.1
390
+ version: '0'
391
391
  - !ruby/object:Gem::Dependency
392
392
  name: guard-livereload
393
393
  requirement: !ruby/object:Gem::Requirement
@@ -492,14 +492,14 @@ dependencies:
492
492
  requirements:
493
493
  - - ~>
494
494
  - !ruby/object:Gem::Version
495
- version: '2.14'
495
+ version: '3.1'
496
496
  type: :development
497
497
  prerelease: false
498
498
  version_requirements: !ruby/object:Gem::Requirement
499
499
  requirements:
500
500
  - - ~>
501
501
  - !ruby/object:Gem::Version
502
- version: '2.14'
502
+ version: '3.1'
503
503
  - !ruby/object:Gem::Dependency
504
504
  name: rb-fsevent
505
505
  requirement: !ruby/object:Gem::Requirement
@@ -582,6 +582,14 @@ files:
582
582
  - MIT-LICENSE
583
583
  - README.md
584
584
  - Rakefile
585
+ - app/assets/images/smithy/icons/_blank.png
586
+ - app/assets/images/smithy/icons/_page.png
587
+ - app/assets/images/smithy/icons/doc.png
588
+ - app/assets/images/smithy/icons/pdf.png
589
+ - app/assets/images/smithy/icons/ppt.png
590
+ - app/assets/images/smithy/icons/txt.png
591
+ - app/assets/images/smithy/icons/xls.png
592
+ - app/assets/images/smithy/icons/xlsx.png
585
593
  - app/assets/images/smithy/logo.png
586
594
  - app/assets/images/smithy/logo2.png
587
595
  - app/assets/javascripts/smithy/application.js
@@ -738,10 +746,13 @@ files:
738
746
  - lib/smithy/liquid/drops/page.rb
739
747
  - lib/smithy/liquid/filters/asset_tag.rb
740
748
  - lib/smithy/liquid/filters/resize.rb
749
+ - lib/smithy/liquid/filters/uri.rb
741
750
  - lib/smithy/liquid/rendering.rb
742
751
  - lib/smithy/liquid/tags/asset.rb
743
752
  - lib/smithy/liquid/tags/csrf.rb
744
753
  - lib/smithy/liquid/tags/html.rb
754
+ - lib/smithy/liquid/tags/include_file.rb
755
+ - lib/smithy/liquid/tags/link.rb
745
756
  - lib/smithy/liquid/tags/nav.rb
746
757
  - lib/smithy/logger.rb
747
758
  - lib/smithy/version.rb