etabliocms_pages 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ = EtabliocmsPages
2
+
3
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'EtabliocmsCore'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
28
+ require 'rake/testtask'
29
+
30
+ Rake::TestTask.new(:test) do |t|
31
+ t.libs << 'lib'
32
+ t.libs << 'test'
33
+ t.pattern = 'test/**/*_test.rb'
34
+ t.verbose = false
35
+ end
36
+
37
+
38
+ task :default => :test
@@ -0,0 +1,52 @@
1
+ module EtabliocmsPages
2
+ module Admin
3
+ class PagesController < EtabliocmsCore::Admin::BaseController
4
+
5
+ def new
6
+ @page = Page.new
7
+ end
8
+
9
+ def create
10
+ @page = Page.new(params[:page])
11
+ if @page.save
12
+ flash[:notice] = t('page.created')
13
+ redirect_to :action => 'index'
14
+ else
15
+ render :action => 'new'
16
+ end
17
+ end
18
+
19
+ def edit
20
+ @page = Page.find(params[:id])
21
+ end
22
+
23
+ def update
24
+ @page = Page.find(params[:id])
25
+ if @page.update_attributes(params[:page])
26
+ flash[:notice] = t('page.updated')
27
+ redirect_to :action => 'index'
28
+ else
29
+ render :action => 'edit'
30
+ end
31
+ end
32
+
33
+ def destroy
34
+ Page.find(params[:id]).destroy
35
+ flash[:notice] = t('page.destroyed')
36
+ redirect_to :action => 'index'
37
+ end
38
+
39
+ def move
40
+ @page = Page.find(params[:id])
41
+ if ["move_lower", "move_higher", "move_to_top", "move_to_bottom"].include?(params[:method])
42
+ @page.send(params[:method])
43
+ flash[:notice] = t('page.moved')
44
+ else
45
+ flash[:notice] = t('page.not_moved')
46
+ end
47
+ redirect_to :action => 'index'
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,43 @@
1
+ module EtabliocmsPages
2
+ class Page < ActiveRecord::Base
3
+
4
+ acts_as_nested_set
5
+ attr_accessor :child_of
6
+ after_save :update_position
7
+
8
+ validates :title, :presence => true
9
+ validates :locale, :presence => true
10
+
11
+ has_slug :to_param => "path"
12
+
13
+ def path
14
+ self_and_ancestors.map(&:slug).join("/")
15
+ end
16
+
17
+ def other_pages_for_select
18
+ pages = EtabliocmsPages::Page.order("lft ASC")
19
+ pages = pages.where("id != ?", id) unless new_record?
20
+ pages.map { |d| [d.title, d.id] }
21
+ end
22
+
23
+ scope :for_locale, lambda { |locale| where(:locale => locale) }
24
+ scope :visible, where(:visible => true)
25
+
26
+ private
27
+ def update_position
28
+ if child_of.to_i != parent_id.to_i
29
+ if child_of.present?
30
+ parent = Page.find(child_of)
31
+ move_to_child_of parent unless parent == self or parent == self.parent
32
+ move_to_bottom
33
+ elsif !child_of.nil?
34
+ move_to_root
35
+ move_to_bottom
36
+ end
37
+ end
38
+ self.child_of = nil
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,48 @@
1
+ <%= render "layouts/errors", :target => @page %>
2
+
3
+ <fieldset>
4
+ <legend><%= t('page.admin_legend') %></legend>
5
+
6
+ <p>
7
+ <%= f.label :title, :id => "page_title_label" %>
8
+ <%= f.text_field :title, :class => 'text-field' %>
9
+ </p>
10
+
11
+ <p>
12
+ <%= f.label :child_of, :id => "page_child_of_label" %>
13
+ <%= f.select :child_of, [[t('hierarchy.top_level'), nil]] + @page.other_pages_for_select,
14
+ :selected => @page.parent ? [@page.parent.title, @page.parent_id] : nil %>
15
+ </p>
16
+
17
+ <p>
18
+ <%= f.label :locale, :id => "page_locale_label" %>
19
+ <%= f.select :locale, [[t('admin.locale.cs'), 'cs'], [t('admin.locale.en'), 'en']] %>
20
+ </p>
21
+
22
+
23
+ <p>
24
+ <%= f.label :visible, :id => "page_visible_label" %>
25
+ <%= f.boolean_yes_no_select :visible %>
26
+ </p>
27
+
28
+ <p>
29
+ <%= f.textile_text_area :text, :width => 560, :height => 200 %>
30
+ </p>
31
+
32
+ <p>
33
+ <%= f.label :url, :id => "page_url_label" %>
34
+ <%= f.text_field :url, :class => 'text-field' %>
35
+ </p>
36
+
37
+ <% if !@page.new_record? && respond_to?(:page_path) %>
38
+ <p>
39
+ <strong>Náhled: </strong>
40
+ <%= link_to @page.title, page_url(@page, :locale => @page.locale), :"data-popup" => "true" %>
41
+ </p>
42
+ <% end %>
43
+
44
+ <p>
45
+ <%= submit_tag t('admin.save'), :class => 'submit' %>
46
+ </p>
47
+
48
+ </fieldset>
@@ -0,0 +1,7 @@
1
+ <% set_title_and_breadcrumb t('page.edit', :title => @page.title) %>
2
+
3
+ <h1><%= @page.title %></h1>
4
+
5
+ <%= form_for :page, :url => admin_page_path(@page.id), :html => {:method => :put, :id => "admin-form"} do |f| -%>
6
+ <%= render :partial => 'form', :locals => { :f => f } %>
7
+ <% end %>
@@ -0,0 +1,25 @@
1
+ <% set_title_and_breadcrumb t('page.pages') %>
2
+
3
+ <h1><%= t('page.pages') %></h1>
4
+
5
+ <div class="strap">
6
+ <%= link_to "#{t('page.add')} &raquo;".html_safe, new_admin_page_path, :class => 'text-icon icon-add' %>
7
+ <%= link_to "#{t('admin.refresh')} &raquo;".html_safe, admin_pages_path, :class => 'text-icon icon-refresh' %>
8
+ <%= link_to "#{t('admin.back_to_admin')} &raquo;".html_safe, admin_path, :class => 'text-icon icon-backward' %>
9
+ </div>
10
+
11
+ <table class="admin-table hierarchical-table">
12
+ <thead>
13
+ <tr>
14
+ <th><%= t('activerecord.attributes.page.title') %></th>
15
+ <th><%= t('admin.created_at') %></th>
16
+ <th><%= t('activerecord.attributes.page.locale') %></th>
17
+ <th><%= t('admin.actions') %></th>
18
+ </tr>
19
+ </thead>
20
+ <tbody>
21
+
22
+ <%= render_table_tree(EtabliocmsPages::Page.order("lft asc")) %>
23
+
24
+ </tbody>
25
+ </table>
@@ -0,0 +1,7 @@
1
+ <% set_title_and_breadcrumb t('page.new') %>
2
+
3
+ <h1><%= t('page.new') %></h1>
4
+
5
+ <%= form_for :page, :url => admin_pages_url, :html => {:method => :post, :id => "admin-form"} do |f| -%>
6
+ <%= render :partial => 'form', :locals => { :f => f } %>
7
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <h3><%= image_tag asset_path("admin/sidebar-pages.png"), :alt => t('page.pages') %><%= t('page.pages') %></h3>
2
+ <ul>
3
+ <li><%= link_to_unless_current I18n.t('page.pages_count', :count => EtabliocmsPages::Page.count), admin_pages_path %></li>
4
+ <li><%= link_to_unless_current t('page.add'), new_admin_page_path %></li>
5
+ </ul>
@@ -0,0 +1,24 @@
1
+ cs:
2
+ page:
3
+ pages: Stránky
4
+ pages_count: "Stránky (%{count})"
5
+ add: Přidat stránku
6
+ created: Stránka byla úspěšně vytvořena.
7
+ updated: Stránka byla úspěšně upravena.
8
+ destroyed: Stránka byla úspěšně odstraněna.
9
+ moved: Stránka byla úspěšně přesunuta.
10
+ not_moved: Stránka nebyla přesunuta.
11
+ destroy_confirmation: Skutečně chcete smazat tuto stránku?
12
+ admin_legend: Základní údaje o stránce
13
+ edit: "Editace stránky %{title}"
14
+ new: Nová stránka
15
+ activerecord:
16
+ attributes:
17
+ "etabliocms_pages/page":
18
+ title: Nadpis
19
+ child_of: Rodič
20
+ text: Text
21
+ visible: Viditelné
22
+ locale: Jazyk
23
+ page_title: Meta title
24
+ page_description: Meta description
@@ -0,0 +1,13 @@
1
+ Rails.application.routes.draw do
2
+
3
+ scope :module => "etabliocms_pages" do
4
+ namespace :admin do
5
+ resources :pages do
6
+ member do
7
+ put :move
8
+ end
9
+ end
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,20 @@
1
+ class CreatePages < ActiveRecord::Migration
2
+
3
+ def change
4
+ create_table :pages do |t|
5
+ t.string :title, :null => false
6
+ t.string :slug, :null => false
7
+ t.text :text
8
+ t.string :url
9
+
10
+ t.integer :lft
11
+ t.integer :rgt
12
+ t.integer :parent_id
13
+
14
+ t.boolean :visible
15
+ t.string :locale, :null => false
16
+ t.timestamps
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,7 @@
1
+ require "active_support/dependencies"
2
+
3
+ module EtabliocmsPages
4
+ end
5
+
6
+ require "etabliocms_pages/engine"
7
+ require "form_helper"
@@ -0,0 +1,14 @@
1
+ module EtabliocmsPages
2
+
3
+ class Engine < ::Rails::Engine
4
+
5
+ initializer "etabliocms_core.initialize" do |app|
6
+ EtabliocmsCore.setup do |config|
7
+ config.modules ||= []
8
+ config.modules << :pages
9
+ end
10
+ end
11
+
12
+ end
13
+
14
+ end
@@ -0,0 +1,3 @@
1
+ module EtabliocmsPages
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: etabliocms_pages
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - papricek
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &14094540 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *14094540
25
+ - !ruby/object:Gem::Dependency
26
+ name: etabliocms_core
27
+ requirement: &14094060 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *14094060
36
+ - !ruby/object:Gem::Dependency
37
+ name: awesome_nested_set
38
+ requirement: &14093460 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - =
42
+ - !ruby/object:Gem::Version
43
+ version: 2.1.2
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *14093460
47
+ - !ruby/object:Gem::Dependency
48
+ name: sqlite3
49
+ requirement: &14092960 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *14092960
58
+ description: Small CMS - module for pages
59
+ email:
60
+ - patrikjira@gmail.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - app/views/layouts/_sidebar_pages.html.erb
66
+ - app/views/etabliocms_pages/admin/pages/_form.html.erb
67
+ - app/views/etabliocms_pages/admin/pages/new.html.erb
68
+ - app/views/etabliocms_pages/admin/pages/edit.html.erb
69
+ - app/views/etabliocms_pages/admin/pages/index.html.erb
70
+ - app/assets/images/admin/sidebar-pages.png
71
+ - app/controllers/etabliocms_pages/admin/pages_controller.rb
72
+ - app/models/etabliocms_pages/page.rb
73
+ - config/routes.rb
74
+ - config/locales/pages.cs.yml
75
+ - db/migrate/20120223140555_create_pages.etabliocms_core_engine.rb
76
+ - lib/etabliocms_pages/version.rb
77
+ - lib/etabliocms_pages/engine.rb
78
+ - lib/etabliocms_pages.rb
79
+ - MIT-LICENSE
80
+ - Rakefile
81
+ - README.rdoc
82
+ homepage: https://github.com/papricek/etabliocms_pages
83
+ licenses: []
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 1.8.5
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: Small CMS - module for pages
106
+ test_files: []