Skip to content

Commit 0a3d1ff

Browse files
committed
Merge branch 'panoramic-integration' of github.com:eclipxe/browsercms into eclipxe-panoramic-integration
2 parents fd93f1f + dc4eeb4 commit 0a3d1ff

File tree

10 files changed

+42
-9
lines changed

10 files changed

+42
-9
lines changed

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ source 'http://rubygems.org'
22

33
# Load this project as a gem.
44
gemspec
5-
5+
gem "panoramic"
66
gem "mysql2"
77

88
gem 'yard', :groups=>[:development, :test]
@@ -41,7 +41,7 @@ group :test do
4141
# Cucumber and dependencies
4242
gem 'capybara'
4343
gem 'database_cleaner'
44-
gem 'cucumber-rails', require: false
44+
gem 'cucumber-rails', :require=> false
4545
gem 'cucumber'
4646
gem 'launchy'
4747
gem 'ruby-prof'

Gemfile.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ PATH
66
bootstrap-sass
77
ckeditor_rails (~> 4.0.1.1)
88
jquery-rails (~> 2.0)
9+
panoramic
910
paperclip (~> 3.0.3)
1011
rails (>= 3.2.5, < 3.3.0)
1112
sass-rails
@@ -124,6 +125,8 @@ GEM
124125
multi_json (1.7.6)
125126
mysql2 (0.3.11)
126127
nokogiri (1.5.9)
128+
panoramic (0.0.4)
129+
rails (>= 3.0.7)
127130
paperclip (3.0.4)
128131
activemodel (>= 3.0.0)
129132
activerecord (>= 3.0.0)
@@ -225,6 +228,7 @@ DEPENDENCIES
225228
minitest-rails
226229
mocha
227230
mysql2
231+
panoramic
228232
poltergeist
229233
rake (~> 0.9.5)
230234
ruby-prof

app/controllers/cms/content_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def render_editing_frame
7272

7373
def render_page
7474
prepare_connectables_for_render
75+
prepend_view_path DynamicView.resolver
7576
respond_with @page, determine_page_layout
7677
end
7778

app/models/cms/dynamic_view.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
module Cms
22
class DynamicView < ActiveRecord::Base
3+
store_templates
4+
35

46
after_save :write_file_to_disk
57
after_destroy :remove_file_from_disk
68

79
include DefaultAccessible
810
# Need to explicitly define these, since during new project creation, these files aren't discoverable.
9-
attr_accessible :name, :body, :format, :handler
11+
attr_accessible :name, :body, :format, :handler, :locale, :path, :partial
1012

1113
scope :with_file_name, lambda { |file_name|
1214
conditions = {:name => nil, :format => nil, :handler => nil}
@@ -29,8 +31,9 @@ def self.inherited(subclass)
2931
is_versioned
3032

3133
before_validation :set_publish_on_save
34+
before_validation :set_defaults, :set_path
3235

33-
validates_presence_of :name, :format, :handler
36+
validates_presence_of :name, :format, :handler, :path, :locale
3437
validates_uniqueness_of :name, :scope => [:format, :handler],
3538
:message => "Must have a unique combination of name, format and handler"
3639

@@ -43,7 +46,7 @@ def self.title
4346
end
4447

4548
def self.new_with_defaults(options={})
46-
new({:format => "html", :handler => "erb", :body => default_body}.merge(options))
49+
new({:format => "html", :handler => "erb", :body => default_body, :locale => I18n.locale}.merge(options))
4750
end
4851

4952
def self.find_by_file_name(file_name)
@@ -107,5 +110,15 @@ def self.resource_collection_name
107110
def self.engine
108111
"cms"
109112
end
113+
114+
def set_path
115+
self.path = self.class.relative_path + '/' + name
116+
end
117+
118+
def set_defaults
119+
self.locale = I18n.locale.to_s unless locale
120+
self.partial = partial?
121+
return true
122+
end
110123
end
111124
end

app/models/cms/page_partial.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,9 @@ def prepend_underscore
2828
end
2929
end
3030

31+
def partial?
32+
true
33+
end
34+
3135
end
3236
end

app/models/cms/page_template.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,9 @@ def self.options
3636
page_templates.map { |f| [display_name(f), f] }.sort.uniq
3737
end
3838

39+
def partial?
40+
false
41+
end
42+
3943
end
4044
end

app/views/cms/dynamic_views/index.html.erb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,16 @@
2424
<table class="data cms-content-table table table-striped table-bordered table-hover">
2525
<thead>
2626
<tr>
27-
<th class="first"></th>
2827
<th><div class="dividers">Name</div></th>
28+
<th><div>Path</div></th>
2929
<th><div>Updated At</div></th>
30-
<th class="last"></th>
3130
</tr>
3231
</thead>
3332
<% @views.each do |view| %>
3433
<tr id="<%= dynamic_view_type.form_name %>_<%= view.id %>">
35-
<td class="first"></td>
3634
<td><div class="dividers" title="<%=h view.file_path %>"><%=h view.display_name %></div></td>
35+
<td><div class="dividers" title="<%=h view.path %>"><%=h view.path %></div></td>
3736
<td><div><%= view.updated_at && view.updated_at.to_s(:date) %></div></td>
38-
<td class="last"></td>
3937
</tr>
4038
<% end %>
4139
</table>

browsercms.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Gem::Specification.new do |s|
3838
s.add_dependency("underscore-rails", "~> 1.4")
3939
s.add_dependency("jquery-rails", "~> 2.0")
4040
s.add_dependency("paperclip", "~> 3.0.3")
41+
s.add_dependency("panoramic")
4142

4243
# Required only for bcms-upgrade
4344
s.add_dependency "term-ansicolor"

db/migrate/20130327184912_browsercms400.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,11 @@ class Browsercms400 < ActiveRecord::Migration
33
def up
44
rename_table :section_nodes, :cms_section_nodes if table_exists?(:section_nodes) && !table_exists?(:section_nodes)
55
add_column :cms_section_nodes, :slug, :string
6+
add_column :cms_dynamic_views, :path, :string
7+
add_column :cms_dynamic_views, :locale, :string
8+
add_column :cms_dynamic_views, :partial, :boolean
9+
add_column :cms_dynamic_view_versions, :path, :string
10+
add_column :cms_dynamic_view_versions, :locale, :string
11+
add_column :cms_dynamic_view_versions, :partial, :boolean
612
end
713
end

lib/browsercms.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@
3131

3232
ActiveRecord::Base.send(:include, Cms::Acts::CmsUser)
3333
require 'cms/responders/content_responder'
34+
35+
require "panoramic"

0 commit comments

Comments
 (0)