refinerycms-categories 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ module Admin
2
+ class CategoriesController < Admin::BaseController
3
+
4
+ crudify :category,
5
+ :conditions => nil,
6
+ :include => [:parent],
7
+ :title_attribute => 'name', :xhr_paging => true
8
+
9
+ after_filter :validate_children
10
+
11
+ def validate_children
12
+
13
+ if Category.last.parent.present?
14
+ if Category.last.parent.products.present?
15
+ flash.now[:notice] = "Please be aware that the '#{Category.last.parent.name}' category has products attached to it. Please re-assign these."
16
+ end
17
+ end
18
+
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,32 @@
1
+ class CategoriesController < ApplicationController
2
+
3
+ before_filter :find_all_categories
4
+ before_filter :find_page
5
+
6
+ def index
7
+ # you can use meta fields from your model instead (e.g. browser_title)
8
+ # by swapping @page for @category in the line below:
9
+ present(@page)
10
+ end
11
+
12
+ def show
13
+ @category = Category.find(params[:id])
14
+
15
+ # redirect_to category_products_path(@category)
16
+
17
+ # you can use meta fields from your model instead (e.g. browser_title)
18
+ # by swapping @page for @category in the line below:
19
+ present(@page)
20
+ end
21
+
22
+ protected
23
+
24
+ def find_all_categories
25
+ @categories = Category.order('position ASC')
26
+ end
27
+
28
+ def find_page
29
+ @page = Page.where(:link_url => "/categories").first
30
+ end
31
+
32
+ end
@@ -0,0 +1,16 @@
1
+ class Category < ActiveRecord::Base
2
+
3
+ acts_as_indexed :fields => [:name]
4
+
5
+ validates :name, :presence => true, :uniqueness => true
6
+
7
+
8
+ belongs_to :parent, :class_name => "Category", :foreign_key => "parent_id"
9
+ has_many :children, :class_name => "Category", :foreign_key => "parent_id"
10
+
11
+ has_and_belongs_to_many :products
12
+
13
+ # Docs for acts_as_nested_set https://github.com/collectiveidea/awesome_nested_set
14
+ acts_as_nested_set :dependent => :destroy # rather than :delete_all
15
+
16
+ end
@@ -0,0 +1,28 @@
1
+ <ul>
2
+ <% if Admin::CategoriesController.searchable? %>
3
+ <li>
4
+ <%= render :partial => "/shared/admin/search",
5
+ :locals => {
6
+ :url => admin_categories_path
7
+ } %>
8
+ </li>
9
+ <% end %>
10
+ <li>
11
+ <%= link_to t('.create_new'), new_admin_category_path,
12
+ :class => "add_icon" %>
13
+ </li>
14
+ <% if !searching? and Admin::CategoriesController.sortable? and Category.count > 1 %>
15
+ <li>
16
+ <%= link_to t('.reorder', :what => "Categories"),
17
+ admin_categories_path,
18
+ :id => "reorder_action",
19
+ :class => "reorder_icon" %>
20
+
21
+ <%= link_to t('.reorder_done', :what => "Categories"),
22
+ admin_categories_path,
23
+ :id => "reorder_action_done",
24
+ :style => "display: none;",
25
+ :class => "reorder_icon" %>
26
+ </li>
27
+ <% end %>
28
+ </ul>
@@ -0,0 +1,2 @@
1
+ <%= will_paginate @categories %>
2
+ <%= render :partial => "sortable_list" %>
@@ -0,0 +1,25 @@
1
+ <li class='clearfix record' id="<%= dom_id(category) -%>">
2
+ <div class='clearfix'>
3
+ <span class='title'>
4
+ <%= category.name %>
5
+ <span class="preview">&nbsp;</span>
6
+ </span>
7
+ <span class='actions'>
8
+ <%= link_to refinery_icon_tag("application_go.png"), category_path(category),
9
+ :title => t('.view_live_html'),
10
+ :target => "_blank" %>
11
+ <%= link_to refinery_icon_tag("application_edit.png"), edit_admin_category_path(category),
12
+ :title => t('.edit') %>
13
+ <%= link_to refinery_icon_tag("delete.png"), admin_category_path(category),
14
+ :class => "cancel confirm-delete",
15
+ :title => t('.delete'),
16
+ :confirm => t('message', :scope => 'shared.admin.delete', :title => category.name),
17
+ :method => :delete %>
18
+ </span>
19
+ </div>
20
+
21
+ <!-- This nested ul added for the tree section -->
22
+ <ul class='nested'>
23
+ <%= render :partial => 'category', :collection => category.children %>
24
+ </ul>
25
+ </li>
@@ -0,0 +1,49 @@
1
+ <%= form_for [:admin, @category] do |f| -%>
2
+ <%= render :partial => "/shared/admin/error_messages", :locals => {
3
+ :object => @category,
4
+ :include_object_name => true
5
+ } %>
6
+
7
+ <div class='field'>
8
+ <%= f.label :name -%>
9
+ <%= f.text_field :name, :class => 'larger widest' -%>
10
+ </div>
11
+
12
+ <div class='field'>
13
+ <%= f.label :parent_id -%>
14
+ <!-- <%#= f.collection_select :parent_id, Category.order(:name), :id, :name, :prompt => "-- Select --" -%> -->
15
+
16
+ <%= f.select :parent_id, nested_set_options(Category, @category) {|i| "#{'-' * i.level} #{i.name}" }, :include_blank => true %>
17
+ </div>
18
+
19
+ <div class='field'>
20
+ <div id='page-tabs' class='clearfix ui-tabs ui-widget ui-widget-content ui-corner-all'>
21
+ <ul id='page_parts'>
22
+ <% [:description].each_with_index do |part, part_index| %>
23
+ <li class='ui-state-default<%= ' ui-state-active' if part_index == 0 %>'>
24
+ <%= link_to part.to_s.titleize, "##{part}" %>
25
+ </li>
26
+ <% end %>
27
+ </ul>
28
+
29
+ <div id='page_part_editors'>
30
+ <% [:description].each do |part| %>
31
+ <div class='page_part' id='<%= part %>'>
32
+ <%= f.text_area part, :rows => 20, :class => 'wymeditor widest' -%>
33
+ </div>
34
+ <% end %>
35
+ </div>
36
+ </div>
37
+ </div>
38
+
39
+ <%= render :partial => "/shared/admin/form_actions",
40
+ :locals => {
41
+ :f => f,
42
+ :continue_editing => false,
43
+ :delete_title => t('delete', :scope => 'admin.categories.category'),
44
+ :delete_confirmation => t('message', :scope => 'shared.admin.delete', :title => @category.name)
45
+ } %>
46
+ <% end -%>
47
+
48
+
49
+
@@ -0,0 +1,18 @@
1
+ <% if searching? %>
2
+ <h2><%= t('results_for', :scope => 'shared.admin.search', :query => params[:search]) %></h2>
3
+ <% end %>
4
+ <% if @categories.any? %>
5
+ <!-- <div class='pagination_container'> -->
6
+ <%= render :partial => 'categories' %>
7
+ <!-- </div> -->
8
+ <% else %>
9
+ <p>
10
+ <% unless searching? %>
11
+ <strong>
12
+ <%= t('.no_items_yet') %>
13
+ </strong>
14
+ <% else %>
15
+ <%= t('no_results', :scope => 'shared.admin.search') %>
16
+ <% end %>
17
+ </p>
18
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <ul id='sortable_list'>
2
+ <!-- <%#= render :partial => 'category', :collection => @categories %> -->
3
+ <%= render :partial => 'category', :collection => @categories.select{|p| p.parent_id.nil?} %>
4
+ </ul>
5
+ <!-- <%#= render :partial => "/shared/admin/sortable_list",
6
+ :locals => {
7
+ :continue_reordering => (local_assigns.keys.include?(:continue_reordering)) ? continue_reordering : true
8
+ } %> -->
9
+ <%= render :partial => "/shared/admin/sortable_list",
10
+ :locals => {:continue_reordering => !!local_assigns[:continue_reordering]} %>
@@ -0,0 +1 @@
1
+ <%= render :partial => "form" %>
@@ -0,0 +1,12 @@
1
+ <section id='records' class='tree'>
2
+ <%= render :partial => 'records' %>
3
+ </section>
4
+ <aside id='actions'>
5
+ <%= render :partial => 'actions' %>
6
+ </aside>
7
+ <!-- <%#= render :partial => '/shared/admin/make_sortable',
8
+ :locals => {
9
+ :tree => false
10
+ } if !searching? and Admin::CategoriesController.sortable? and Category.count > 1 %> -->
11
+ <%= render :partial => "/shared/admin/make_sortable",
12
+ :locals => {:tree => true} if @categories.many? -%>
@@ -0,0 +1 @@
1
+ <%= render :partial => "form" %>
@@ -0,0 +1,11 @@
1
+ <% content_for :body_content_left do %>
2
+ <ul id="categories">
3
+ <% @categories.each do |category| %>
4
+ <li>
5
+ <%= link_to category.name, category_path(category) %>
6
+ </li>
7
+ <% end %>
8
+ </ul>
9
+ <% end %>
10
+
11
+ <%= render :partial => "/shared/content_page" %>
@@ -0,0 +1,33 @@
1
+ <% content_for :body_content_title do %>
2
+ <%= @category.name %>
3
+ <% end %>
4
+
5
+ <% content_for :body_content_left do %>
6
+ <section>
7
+ <h1>Name</h1>
8
+ <p>
9
+ <%=raw @category.name %>
10
+ </p>
11
+ </section>
12
+ <section>
13
+ <h1>Parent</h1>
14
+ <p>
15
+ <%=raw @category.parent %>
16
+ </p>
17
+ </section>
18
+ <% end %>
19
+
20
+ <% content_for :body_content_right do %>
21
+ <aside>
22
+ <h2><%= t('.other') %></h2>
23
+ <ul id="categories">
24
+ <% @categories.each do |category| %>
25
+ <li>
26
+ <%= link_to category.name, category_path(category) %>
27
+ </li>
28
+ <% end %>
29
+ </ul>
30
+ </aside>
31
+ <% end %>
32
+
33
+ <%= render :partial => "/shared/content_page" %>
@@ -0,0 +1,25 @@
1
+ en:
2
+ shared:
3
+ admin:
4
+ image_picker:
5
+ image: image
6
+ plugins:
7
+ categories:
8
+ title: Categories
9
+ admin:
10
+ categories:
11
+ actions:
12
+ create_new: Add New Category
13
+ reorder: Reorder Categories
14
+ reorder_done: Done Reordering Categories
15
+ records:
16
+ title: Categories
17
+ sorry_no_results: Sorry! There are no results found.
18
+ no_items_yet: There are no Categories yet. Click "Add New Category" to add your first category.
19
+ category:
20
+ view_live_html: View this category live <br/><em>(opens in a new window)</em>
21
+ edit: Edit this category
22
+ delete: Remove this category forever
23
+ categories:
24
+ show:
25
+ other: Other Categories
@@ -0,0 +1,25 @@
1
+ fr:
2
+ shared:
3
+ admin:
4
+ image_picker:
5
+ image: image
6
+ plugins:
7
+ categories:
8
+ title: Categories
9
+ admin:
10
+ categories:
11
+ actions:
12
+ create_new: Créer un(e) nouve(au/l/lle) Category
13
+ reorder: Réordonner les Categories
14
+ reorder_done: Fin de réordonnancement des Categories
15
+ records:
16
+ title: Categories
17
+ sorry_no_results: "Désolé ! Aucun résultat."
18
+ no_items_yet: 'Il n''y a actuellement aucun(e) Category. Cliquer sur "Créer un(e) nouve(au/l/lle) Category" pour créer votre premi(er/ère) category.'
19
+ category:
20
+ view_live_html: Voir ce(t/tte) category <br/><em>(Ouvre une nouvelle fenêtre)</em>
21
+ edit: Modifier ce(t/tte) category
22
+ delete: Supprimer définitivement ce(t/tte) category
23
+ categories:
24
+ show:
25
+ other: Autres Categories
@@ -0,0 +1,25 @@
1
+ lolcat:
2
+ shared:
3
+ admin:
4
+ image_picker:
5
+ image: IMAGE
6
+ plugins:
7
+ categories:
8
+ title: Categories
9
+ admin:
10
+ categories:
11
+ actions:
12
+ create_new: CREATE NEW Category
13
+ reorder: REORDR Categories
14
+ reorder_done: DUN REORDERIN Categories
15
+ records:
16
+ title: Categories
17
+ sorry_no_results: SRY! THAR R NO RESULTS FINDZ.
18
+ no_items_yet: THAR R NO Categories YET. CLICK "CREATE NEW Category" 2 ADD UR FURST category.
19
+ category:
20
+ view_live_html: VIEW DIS category LIV <BR/><EM>(OPENS IN NEW WINDOW)</EM>
21
+ edit: EDIT DIS category
22
+ delete: REMOOV DIS category FOREVR
23
+ categories:
24
+ show:
25
+ other: OTHR Categories
@@ -0,0 +1,21 @@
1
+ nb:
2
+ plugins:
3
+ categories:
4
+ title: Categories
5
+ admin:
6
+ categories:
7
+ actions:
8
+ create_new: Lag en ny Category
9
+ reorder: Endre rekkefølgen på Categories
10
+ reorder_done: Ferdig å endre rekkefølgen Categories
11
+ records:
12
+ title: Categories
13
+ sorry_no_results: Beklager! Vi fant ikke noen resultater.
14
+ no_items_yet: Det er ingen Categories enda. Klikk på "Lag en ny Category" for å legge til din første category.
15
+ category:
16
+ view_live_html: Vis hvordan denne category ser ut offentlig <br/><em>(åpner i et nytt vindu)</em>
17
+ edit: Rediger denne category
18
+ delete: Fjern denne category permanent
19
+ categories:
20
+ show:
21
+ other: Andre Categories
@@ -0,0 +1,21 @@
1
+ nl:
2
+ plugins:
3
+ categories:
4
+ title: Categories
5
+ admin:
6
+ categories:
7
+ actions:
8
+ create_new: Maak een nieuwe Category
9
+ reorder: Wijzig de volgorde van de Categories
10
+ reorder_done: Klaar met het wijzingen van de volgorde van de Categories
11
+ records:
12
+ title: Categories
13
+ sorry_no_results: Helaas! Er zijn geen resultaten gevonden.
14
+ no_items_yet: Er zijn nog geen Categories. Druk op 'Maak een nieuwe Category' om de eerste aan te maken.
15
+ category:
16
+ view_live_html: Bekijk deze category op de website <br/><em>(opent een nieuw venster)</em>
17
+ edit: Bewerk deze category
18
+ delete: Verwijder deze category voor eeuwig
19
+ categories:
20
+ show:
21
+ other: Andere Categories
@@ -0,0 +1,12 @@
1
+ ::Refinery::Application.routes.draw do
2
+ resources :categories, :only => [:index, :show]
3
+
4
+ scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
5
+ resources :categories, :except => :show do
6
+ resources :products
7
+ collection do
8
+ post :update_positions
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ class RefinerycmsCategories < Refinery::Generators::EngineInstaller
2
+
3
+ source_root File.expand_path('../../../', __FILE__)
4
+ engine_name "categories"
5
+
6
+ end
@@ -0,0 +1,30 @@
1
+ require 'refinerycms-base'
2
+
3
+ module Refinery
4
+ module Categories
5
+
6
+ class << self
7
+ attr_accessor :root
8
+ def root
9
+ @root ||= Pathname.new(File.expand_path('../../', __FILE__))
10
+ end
11
+ end
12
+
13
+ class Engine < Rails::Engine
14
+ initializer "static assets" do |app|
15
+ app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
16
+ end
17
+
18
+ config.after_initialize do
19
+ Refinery::Plugin.register do |plugin|
20
+ plugin.name = "categories"
21
+ plugin.pathname = root
22
+ plugin.activity = {
23
+ :class => Category,
24
+ :title => 'name'
25
+ }
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,13 @@
1
+ namespace :refinery do
2
+
3
+ namespace :categories do
4
+
5
+ # call this task my running: rake refinery:categories:my_task
6
+ # desc "Description of my task below"
7
+ # task :my_task => :environment do
8
+ # # add your logic here
9
+ # end
10
+
11
+ end
12
+
13
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refinerycms-categories
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ version: "1.0"
10
+ platform: ruby
11
+ authors:
12
+ - byropig
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-11-11 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Ruby on Rails Categories engine for Refinery CMS
22
+ email: byron@perfectcircle.co.za
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - lib/generators/refinerycms_categories_generator.rb
31
+ - lib/refinerycms-categories.rb
32
+ - lib/tasks/categories.rake
33
+ - config/locales/en.yml
34
+ - config/locales/fr.yml
35
+ - config/locales/lolcat.yml
36
+ - config/locales/nb.yml
37
+ - config/locales/nl.yml
38
+ - config/routes.rb
39
+ - app/controllers/admin/categories_controller.rb
40
+ - app/controllers/categories_controller.rb
41
+ - app/models/category.rb
42
+ - app/views/admin/categories/edit.html.erb
43
+ - app/views/admin/categories/index.html.erb
44
+ - app/views/admin/categories/new.html.erb
45
+ - app/views/admin/categories/_actions.html.erb
46
+ - app/views/admin/categories/_categories.html.erb
47
+ - app/views/admin/categories/_category.html.erb
48
+ - app/views/admin/categories/_form.html.erb
49
+ - app/views/admin/categories/_records.html.erb
50
+ - app/views/admin/categories/_sortable_list.html.erb
51
+ - app/views/categories/index.html.erb
52
+ - app/views/categories/show.html.erb
53
+ has_rdoc: true
54
+ homepage: http://www.perfectcircle.co.za
55
+ licenses: []
56
+
57
+ post_install_message:
58
+ rdoc_options: []
59
+
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ requirements: []
81
+
82
+ rubyforge_project:
83
+ rubygems_version: 1.5.2
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Categories engine for Refinery CMS
87
+ test_files: []
88
+