Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jose Rilla
committed
Oct 20, 2011
1 parent
53902ef
commit da03d8f
Showing
22 changed files
with
1,421 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.sass-cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
class PagesController < ApplicationController | ||
|
||
# This action is usually accessed with the root path, normally '/' | ||
def home | ||
error_404 unless (@page = Page.where(:link_url => '/').first).present? | ||
end | ||
|
||
# This action can be accessed normally, or as nested pages. | ||
# Assuming a page named "mission" that is a child of "about", | ||
# you can access the pages with the following URLs: | ||
# | ||
# GET /pages/about | ||
# GET /about | ||
# | ||
# GET /pages/mission | ||
# GET /about/mission | ||
# | ||
def show | ||
|
||
@page = Page.find("#{params[:path]}/#{params[:id]}".split('/').last) | ||
|
||
if @page.type == "Facet" | ||
@products = @page.products | ||
@facets = @page.children.empty? ? @page.parent.children : @page.children | ||
#@products.map{ |product| product.facets }.flatten.uniq.reject{ |f| facet_ids.include?(f.id) } | ||
# if @facets.empty? | ||
# @products = Sunspot.search(Product){ with(:facet_ids).all_of [facet_ids.first] }.results | ||
# @facets = @products.map{ |product| product.facets }.flatten.uniq | ||
# end | ||
elsif @page.try(:live?) || (refinery_user? && current_user.authorized_plugins.include?("refinery_pages")) | ||
# if the admin wants this to be a "placeholder" page which goes to its first child, go to that instead. | ||
if @page.skip_to_first_child && (first_live_child = @page.children.order('lft ASC').live.first).present? | ||
redirect_to first_live_child.url and return | ||
elsif @page.link_url.present? | ||
redirect_to @page.link_url and return | ||
end | ||
else | ||
error_404 | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
class Facet < Page | ||
has_and_belongs_to_many :products, :join_table => "facets_products", :foreign_key => "facet_id" | ||
attr_accessible :product_tokens, :set | ||
attr_reader :product_tokens | ||
scope :age, where(:set => 'age') | ||
scope :kind, where(:set => 'kind') | ||
scope :interest, where(:set => 'interest') | ||
def product_tokens=(ids) | ||
self.product_ids = ids.split(",") | ||
end | ||
|
||
def as_json(options={}) | ||
{ :id => self.id, :name => self.title } | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
class Product < Page | ||
has_and_belongs_to_many :facets, :join_table => "facets_products", :foreign_key => "product_id" | ||
attr_accessible :facet_tokens | ||
attr_reader :facet_tokens | ||
def facet_tokens=(ids) | ||
self.facet_ids = ids.split(",") | ||
end | ||
def as_json(options={}) | ||
{ :id => self.id, :name => self.title } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<% content_for :after_javascript_libraries do %> | ||
<%= javascript_include_tag 'jquery.autoresize' %> | ||
<%= javascript_include_tag 'jquery.textchange.min' %> | ||
<%= javascript_include_tag "jquery.tokeninput.js" %> | ||
<%= javascript_include_tag "products-admin" %> | ||
<% end %> | ||
<% content_for :stylesheets do %> | ||
<%= stylesheet_link_tag "token-input" %> | ||
<%= stylesheet_link_tag "catalog" %> | ||
<% end %> | ||
<% url_opts = action_name == 'edit' ? {:url => admin_page_path(@page.id)} : {} %> | ||
<%= form_for [:admin, @page], url_opts.merge({:as => :page}) do |f| %> | ||
<%= render :partial => "/shared/admin/error_messages", | ||
:locals => { | ||
:object => @page, | ||
:include_object_name => true | ||
} %> | ||
<%= render :partial => "locale_picker", | ||
:locals => { | ||
:current_locale => Thread.current[:globalize_locale] | ||
} if ::Refinery.i18n_enabled? %> | ||
|
||
<div class="clearfix"></div> | ||
|
||
<div class="field"> | ||
<%= f.label :title %> | ||
<%= f.text_field :title, :class => "larger widest" %> | ||
</div> | ||
|
||
<%= render :partial => "form_fields_after_title", | ||
:locals => { | ||
:f => f | ||
} %> | ||
|
||
<div class='field'> | ||
<%= render :partial => "form_page_parts", | ||
:locals => { | ||
:f => f | ||
} %> | ||
</div> | ||
|
||
<%= render :partial => "form_advanced_options", | ||
:locals => { | ||
:f => f | ||
} %> | ||
<%= render :partial => "/shared/admin/form_actions", | ||
:locals => { | ||
:f => f, | ||
:continue_editing => true, | ||
:delete_title => t('delete', :scope => 'admin.pages'), | ||
:delete_confirmation => t('message', :scope => 'shared.admin.delete', :title => @page.title) | ||
} %> | ||
<%= render :partial => "form_new_page_parts", | ||
:locals => { | ||
:f => f | ||
} if RefinerySetting.find_or_set(:new_page_parts, false) %> | ||
<% end %> | ||
<% content_for :javascripts do %> | ||
<script> | ||
$(document).ready(function(){ | ||
page_options.init( | ||
<%= RefinerySetting.find_or_set(:new_page_parts, false).to_s %> | ||
, "<%= new_admin_page_part_path %>" | ||
, "<%= admin_page_parts_path %>" | ||
); | ||
}); | ||
</script> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<% if f.object.type == "Facet" and f.object.parent.nil? %> | ||
<%= f.label :set, t('facet_set') %> | ||
<%= f.select :set, options_for_select(RefinerySetting.get(:facet_sets).map{ |set| [t(set), set] }) %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<li class='clearfix record' id="page_<%= page.id -%>"> | ||
<div class='clearfix'> | ||
<% if page.children.present? %> | ||
<span class="icon toggle" title="<%= t('expand_collapse', :scope => 'refinery.admin.pages') %>"></span> | ||
<% else %> | ||
<span class="icon"></span> | ||
<% end %> | ||
<span class='title'> | ||
<%= page.title_with_meta.html_safe %> | ||
<% if ::Refinery.i18n_enabled? and ::Refinery::I18n.frontend_locales.many? and | ||
(locales = page.translations.map(&:locale)).present? %> | ||
<span class='preview'> | ||
<% if page.type=="Facet" && page.set.present? %> | ||
<span class='set'><%= t(page.set) %></span> | ||
<% end %> | ||
<% ([page.translation.try(:locale)] | locales).each do |locale| %> | ||
<%= link_to locale, | ||
edit_admin_page_path(page.id, :switch_locale => locale), | ||
:class => 'locale' %> | ||
<% end %> | ||
</span> | ||
<% end %> | ||
</span> | ||
<span class='actions'> | ||
<%= link_to refinery_icon_tag('application_go.png'), page.url, | ||
:target => "_blank", | ||
:title => t('.view_live_html') %> | ||
<%= link_to refinery_icon_tag('application_edit.png'), edit_admin_page_path(page.id), | ||
:class => 'edit', | ||
:title => t('edit', :scope => 'admin.pages') %> | ||
<%= link_to refinery_icon_tag('delete.png'), eval("admin_#{page.type.present? ? page.type.tableize : 'page'}_path(page.id)"), | ||
:class => "cancel confirm-delete", | ||
:title => t('delete', :scope => 'admin.pages'), | ||
:confirm => t('message', :scope => 'shared.admin.delete', :title => page.title_with_meta.gsub(/\ ?<em>.*<\/em>/, "")), | ||
:remote => true, | ||
:method => :delete if page.deletable? %> | ||
</span> | ||
</div> | ||
<ul class='nested' data-ajax-content="<%= children_admin_page_path(page.id) %>"> | ||
<%#= render :partial => 'page', :collection => page.children %> | ||
</ul> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<% content_for :stylesheets do %> | ||
<%= stylesheet_link_tag "catalog" %> | ||
<% end %> | ||
<section id='records' class='tree'> | ||
<% caching = RefinerySetting.find_or_set(:cache_pages_backend, false) %> | ||
<% cache_if(caching, [Refinery.base_cache_key, "pages_backend", Globalize.locale].join('_')) do %> | ||
<%= render :partial => 'records' %> | ||
<% end %> | ||
</section> | ||
<section id='actions'> | ||
<%= render :partial => 'actions' %> | ||
</section> | ||
<%= render :partial => "/shared/admin/make_sortable", | ||
:locals => {:tree => true} if @pages.many? -%> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div class='wym_skin_refinery page_part architecture' id='page_architecture'> | ||
<div class='wym_area_top'> | ||
</div> | ||
<div class='wym_box field'> | ||
<% if @page.type == "Product" %> | ||
<%= f.label :facet_tokens, t('.facets') %> | ||
<%= f.text_field :facet_tokens, "data-pre" => @page.facets.map(&:as_json).to_json %> | ||
<% elsif @page.type = "Facet" %> | ||
<%= f.label :product_tokens, t('.products') %> | ||
<%= f.text_field :product_tokens, "data-pre" => @page.products.map(&:as_json).to_json %> | ||
<% end %> | ||
</div> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class AddSetToFacets < ActiveRecord::Migration | ||
def self.up | ||
add_column :pages, :set, :string | ||
RefinerySetting.set :facet_sets, ['age', 'kind', 'interest'].to_yaml | ||
end | ||
|
||
def self.down | ||
remove_column :pages, :set | ||
RefinerySetting.delete :facet_sets | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.