creature 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/.document +5 -0
  2. data/Gemfile +13 -0
  3. data/Gemfile.lock +20 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +19 -0
  6. data/Rakefile +76 -0
  7. data/VERSION +1 -0
  8. data/creature.gemspec +89 -0
  9. data/lib/creature.rb +0 -0
  10. data/lib/generators/pages/USAGE +8 -0
  11. data/lib/generators/pages/pages_generator.rb +61 -0
  12. data/lib/generators/pages/templates/_admin_nav.html.haml +2 -0
  13. data/lib/generators/pages/templates/_footer.html.haml +1 -0
  14. data/lib/generators/pages/templates/_form.html.erb +99 -0
  15. data/lib/generators/pages/templates/_header.html.haml +1 -0
  16. data/lib/generators/pages/templates/_navigation.html.haml +5 -0
  17. data/lib/generators/pages/templates/_page.html.haml +9 -0
  18. data/lib/generators/pages/templates/_sidebar.html.haml +1 -0
  19. data/lib/generators/pages/templates/admin_pages_controller.rb +46 -0
  20. data/lib/generators/pages/templates/application.html.haml +22 -0
  21. data/lib/generators/pages/templates/application_controller.rb +15 -0
  22. data/lib/generators/pages/templates/dashboard_controller.rb +7 -0
  23. data/lib/generators/pages/templates/edit.html.erb +5 -0
  24. data/lib/generators/pages/templates/index.html.haml +1 -0
  25. data/lib/generators/pages/templates/new.html.erb +5 -0
  26. data/lib/generators/pages/templates/page.html.haml +25 -0
  27. data/lib/generators/pages/templates/page.rb +31 -0
  28. data/lib/generators/pages/templates/page_controller.rb +9 -0
  29. data/lib/generators/pages/templates/page_helper.rb +25 -0
  30. data/lib/generators/pages/templates/pages_index.html.haml +26 -0
  31. data/lib/generators/pages/templates/reset.sass +21 -0
  32. data/lib/generators/pages/templates/show.html.erb +20 -0
  33. data/lib/generators/pages/templates/show.html.haml +1 -0
  34. data/lib/generators/pages/templates/style.sass +102 -0
  35. data/test/helper.rb +18 -0
  36. data/test/test_creature.rb +7 -0
  37. metadata +163 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.5.1"
12
+ gem "rcov", ">= 0"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.5.1)
6
+ bundler (~> 1.0.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.8.7)
10
+ rcov (0.9.9)
11
+ shoulda (2.11.3)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.0.0)
18
+ jeweler (~> 1.5.1)
19
+ rcov
20
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Travis
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.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = creature
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to creature
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Travis. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,76 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "creature"
16
+ gem.homepage = "http://github.com/terard/creature"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Creature.}
19
+ gem.description = %Q{Creature.}
20
+ gem.email = "travis@impossiblecreature.com"
21
+ gem.authors = ["Travis"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ require 'rcov/rcovtask'
37
+ Rcov::RcovTask.new do |test|
38
+ test.libs << 'test'
39
+ test.pattern = 'test/**/test_*.rb'
40
+ test.verbose = true
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "creature #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
54
+
55
+ namespace :version do
56
+ desc "create a new version, create tag and push to github"
57
+ task :github_and_tag do
58
+ Rake::Task['github:release'].invoke
59
+ Rake::Task['git:release'].invoke
60
+ end
61
+
62
+ task :patch_release do
63
+ Rake::Task['version:bump:patch'].invoke
64
+ Rake::Task['version:github_and_tag'].invoke
65
+ end
66
+
67
+ task :minor_release do
68
+ Rake::Task['version:bump:minor'].invoke
69
+ Rake::Task['version:github_and_tag'].invoke
70
+ end
71
+
72
+ task :major_release do
73
+ Rake::Task['version:bump:major'].invoke
74
+ Rake::Task['version:github_and_tag'].invoke
75
+ end
76
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/creature.gemspec ADDED
@@ -0,0 +1,89 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{creature}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Travis"]
12
+ s.date = %q{2010-11-30}
13
+ s.description = %q{Creature.}
14
+ s.email = %q{travis@impossiblecreature.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "creature.gemspec",
28
+ "lib/creature.rb",
29
+ "lib/generators/pages/USAGE",
30
+ "lib/generators/pages/pages_generator.rb",
31
+ "lib/generators/pages/templates/_admin_nav.html.haml",
32
+ "lib/generators/pages/templates/_footer.html.haml",
33
+ "lib/generators/pages/templates/_form.html.erb",
34
+ "lib/generators/pages/templates/_header.html.haml",
35
+ "lib/generators/pages/templates/_navigation.html.haml",
36
+ "lib/generators/pages/templates/_page.html.haml",
37
+ "lib/generators/pages/templates/_sidebar.html.haml",
38
+ "lib/generators/pages/templates/admin_pages_controller.rb",
39
+ "lib/generators/pages/templates/application.html.haml",
40
+ "lib/generators/pages/templates/application_controller.rb",
41
+ "lib/generators/pages/templates/dashboard_controller.rb",
42
+ "lib/generators/pages/templates/edit.html.erb",
43
+ "lib/generators/pages/templates/index.html.haml",
44
+ "lib/generators/pages/templates/new.html.erb",
45
+ "lib/generators/pages/templates/page.html.haml",
46
+ "lib/generators/pages/templates/page.rb",
47
+ "lib/generators/pages/templates/page_controller.rb",
48
+ "lib/generators/pages/templates/page_helper.rb",
49
+ "lib/generators/pages/templates/pages_index.html.haml",
50
+ "lib/generators/pages/templates/reset.sass",
51
+ "lib/generators/pages/templates/show.html.erb",
52
+ "lib/generators/pages/templates/show.html.haml",
53
+ "lib/generators/pages/templates/style.sass",
54
+ "test/helper.rb",
55
+ "test/test_creature.rb"
56
+ ]
57
+ s.homepage = %q{http://github.com/terard/creature}
58
+ s.licenses = ["MIT"]
59
+ s.require_paths = ["lib"]
60
+ s.rubygems_version = %q{1.3.7}
61
+ s.summary = %q{Creature.}
62
+ s.test_files = [
63
+ "test/helper.rb",
64
+ "test/test_creature.rb"
65
+ ]
66
+
67
+ if s.respond_to? :specification_version then
68
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
69
+ s.specification_version = 3
70
+
71
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
72
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
73
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
74
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
75
+ s.add_development_dependency(%q<rcov>, [">= 0"])
76
+ else
77
+ s.add_dependency(%q<shoulda>, [">= 0"])
78
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
79
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
80
+ s.add_dependency(%q<rcov>, [">= 0"])
81
+ end
82
+ else
83
+ s.add_dependency(%q<shoulda>, [">= 0"])
84
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
85
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
86
+ s.add_dependency(%q<rcov>, [">= 0"])
87
+ end
88
+ end
89
+
data/lib/creature.rb ADDED
File without changes
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate pages Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,61 @@
1
+ class PagesGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+
4
+ def create_models
5
+ generate :model, 'page name:string content:text page_title:string meta_keywords:text meta_description:text'
6
+ rake 'db:migrate'
7
+ remove_file 'app/models/page.rb' if File.exists?('app/models/page.rb')
8
+ copy_file 'page.rb', 'app/models/page.rb'
9
+ end
10
+
11
+ def seed_data
12
+ # append_file 'db/seeds.rb', "Page.create! :name => 'index', :content => 'i am index. i have no data.'"
13
+ # rake 'db:seed'
14
+ end
15
+
16
+ def gems
17
+ gem 'haml'
18
+
19
+ gsub_file "Gemfile", /#.*\n/, "\n"
20
+ gsub_file "Gemfile", /\n+/, "\n"
21
+ end
22
+
23
+ def remove_index_html
24
+ remove_file 'public/index.html' if File.exists?('public/index.html')
25
+ end
26
+
27
+ def add_routes
28
+ route "resources :pages, :module => 'admin'"
29
+ route "resources :messages, :module => 'admin'"
30
+ route "root :to => 'page#show#index', :page => 'index'"
31
+ route "match ':page/' => 'page#show#:page'"
32
+ end
33
+
34
+ def copy_files
35
+ copy_file 'admin_pages_controller.rb', 'app/controllers/admin/pages_controller.rb'
36
+ copy_file 'application_controller.rb', 'app/controllers/application_controller.rb'
37
+ copy_file 'dashboard_controller.rb', 'app/controllers/dashboard_controller.rb'
38
+ copy_file 'page_controller.rb', 'app/controllers/page_controller.rb'
39
+ copy_file 'page_helper.rb', 'app/helpers/page_helper.rb'
40
+ copy_file 'index.html.haml', 'app/views/page/index.html.haml'
41
+ copy_file 'page.html.haml', 'app/views/layouts/page.html.haml'
42
+ copy_file 'style.sass', 'public/stylesheets/sass/style.sass'
43
+ copy_file 'reset.sass', 'public/stylesheets/sass/reset.sass'
44
+ copy_file 'show.html.haml', 'app/views/page/show.html.haml'
45
+ copy_file '_page.html.haml', 'app/views/page/_page.html.haml'
46
+ copy_file '_header.html.haml', 'app/views/page/_header.html.haml'
47
+ copy_file '_navigation.html.haml', 'app/views/page/_navigation.html.haml'
48
+ copy_file '_sidebar.html.haml', 'app/views/page/_sidebar.html.haml'
49
+ copy_file '_footer.html.haml', 'app/views/page/_footer.html.haml'
50
+
51
+ copy_file 'edit.html.erb', 'app/views/admin/pages/edit.html.erb'
52
+ copy_file 'pages_index.html.haml', 'app/views/admin/pages/index.html.haml'
53
+ copy_file 'new.html.erb', 'app/views/admin/pages/new.html.erb'
54
+ copy_file 'show.html.erb', 'app/views/admin/pages/show.html.erb'
55
+ copy_file '_admin_nav.html.haml', 'app/views/layouts/_admin_nav.html.haml'
56
+ end
57
+
58
+ def blast_off
59
+ run 'touch tmp/restart.txt'
60
+ end
61
+ end
@@ -0,0 +1,2 @@
1
+ %ul{:class => 'sf-menu'}
2
+ %li= link_to "Pages", pages_path
@@ -0,0 +1,99 @@
1
+ <%= form_for([:admin, @page]) do |f| %>
2
+ <fieldset class="inputs">
3
+ <% if @page.errors.any? %>
4
+ <div id="error_explanation">
5
+ <h2><%= pluralize(@page.errors.count, "error") %> prohibited this page from being saved:</h2>
6
+
7
+ <ul>
8
+ <% @page.errors.full_messages.each do |msg| %>
9
+ <li><%= msg %></li>
10
+ <% end %>
11
+ </ul>
12
+ </div>
13
+ <% end %>
14
+
15
+ <ol class="main">
16
+
17
+ <li class="string required title">
18
+ <%= f.label :Location %><br />
19
+ <%= f.select("section", Page::SECTIONS) %>
20
+ / <%= f.text_field :name %>
21
+ </li>
22
+ <% if !@page.isroot && !@page.id.nil? %>
23
+ <li class="title">
24
+ <ul class="check_boxes">
25
+ <li class="field">
26
+ <%= f.label "Show in navigation?" %>
27
+ <%= f.check_box :navigation %>
28
+ <p class="inline-hints">check box for item to appear in navigation</p>
29
+ <%= f.text_field :navigation_title %>
30
+ </li>
31
+ </ul>
32
+ </li>
33
+ <% end %>
34
+ <li class="string required title">
35
+ <%= f.label :title %><br />
36
+ <%= f.text_field :page_title %>
37
+ <p class="inline-hints">this will appear in title</p>
38
+ </li>
39
+ <li class="string required title">
40
+ <%= f.label :meta_keywords %><br />
41
+ <%= f.text_area :meta_keywords, :class => 'small' %>
42
+ </li>
43
+ <li class="string required title">
44
+ <%= f.label :meta_description %><br />
45
+ <%= f.text_area :meta_description, :class => 'small' %>
46
+ </li>
47
+ <li class="string required title">
48
+ <%= f.label :content %><br />
49
+ <%= ckeditor_textarea("page", "content", :width => '100%', :height => '200px', :toolbar => 'Easy') %>
50
+ </li>
51
+ <li class="string required title">
52
+ </li>
53
+ <li class="select required">
54
+ <label for="page_type">Page Layout:</label>
55
+ <%= f.select("page_type", Page::PAGE_TYPES, {:include_blank => 'None'}) %>
56
+ <p class="inline-hints">this will determines which template will be used</p>
57
+ </li>
58
+ <!-- <li class="title">
59
+ <ul class="checks">
60
+ <li class="field">
61
+ <%= f.label :visible %>
62
+ <%= f.check_box :visible %>
63
+ <p class="inline-hints">this is ignored, unless we want to turn it on.</p>
64
+ </li>
65
+ </ul>
66
+ </li> -->
67
+ <hr>
68
+ <li class="buttons">
69
+ <%= f.submit %>
70
+ </li>
71
+ </ol>
72
+
73
+ <div class="sidebar">
74
+ <ol>
75
+ <li class="select check">
76
+ <%= f.check_box :contactform %>
77
+ <%= image_tag "contact_form.png", :width => "100" %>
78
+ </li>
79
+ <li class="title">
80
+ <%= link_to_add_fields image_tag("add.png"), f, :imagelinks %>
81
+ <%= link_to_add_fields "Add An Image", f, :imagelinks %>
82
+ <hr/>
83
+ <%= f.fields_for :imagelinks do |builder| %>
84
+ <%= render "imagelink_fields", :f => builder %>
85
+ <% end %>
86
+ </li>
87
+ <li class="select required">
88
+ <%= f.label :sidebar %><br />
89
+ <%= ckeditor_textarea("page", "sidebar_html", :width => '100%', :height => '200px', :toolbar => 'Sidebar') %>
90
+ </li>
91
+ <li class="select check">
92
+ <%= f.check_box :accordion %>
93
+ <%= image_tag "accordion.png", :width => "100" %>
94
+ </li>
95
+ </ol>
96
+ </div>
97
+
98
+ </fieldset>
99
+ <% end %>
@@ -0,0 +1 @@
1
+ =image_tag 'http://placehold.it/300x100'
@@ -0,0 +1,5 @@
1
+ %ul
2
+ %li= link_to "Home"
3
+ %li= link_to "About"
4
+ %li= link_to "Services"
5
+ %li= link_to "Contact"
@@ -0,0 +1,9 @@
1
+ = title @page.title
2
+ = page_name @page.name
3
+
4
+ = meta_keywords @page.meta_keywords
5
+ = meta_desc @page.meta_description
6
+
7
+ = @page.content
8
+
9
+ = sidebar @page.sidebar
@@ -0,0 +1 @@
1
+ sidebar
@@ -0,0 +1,46 @@
1
+ class Admin::PagesController < ApplicationController
2
+ before_filter :authenticate
3
+
4
+ def index
5
+ @pages = Page.order('updated_at desc')
6
+ end
7
+
8
+ def show
9
+ @page = Page.find(params[:id])
10
+ end
11
+
12
+ def new
13
+ @page = Page.new
14
+ end
15
+
16
+ def edit
17
+ @page = Page.find(params[:id])
18
+ end
19
+
20
+ def create
21
+ @page = Page.new(params[:page])
22
+
23
+ if @page.save
24
+ redirect_to(dashboard_path, :notice => 'Page was successfully created.')
25
+ else
26
+ render :action => "new"
27
+ end
28
+ end
29
+
30
+ def update
31
+ @page = Page.find(params[:id])
32
+
33
+ if @page.update_attributes(params[:page])
34
+ redirect_to(dashboard_path, :notice => 'Page was successfully updated.')
35
+ else
36
+ render :action => "edit"
37
+ end
38
+ end
39
+
40
+ def destroy
41
+ @page = Page.find(params[:id])
42
+ @page.destroy
43
+
44
+ redirect_to(dashboard_path, :notice => 'Page was successfully removed.')
45
+ end
46
+ end
@@ -0,0 +1,22 @@
1
+ !!! 5
2
+
3
+ %html
4
+ %head
5
+ %title Wookiee - Site Dashboard
6
+ = stylesheet_link_tag :all
7
+ = javascript_include_tag :defaults
8
+ = csrf_meta_tag
9
+
10
+ %body{:id => "dashboard"}
11
+ #container
12
+ #header
13
+ Wookiee - Site Dashboard
14
+ .user_nav
15
+ #navigation
16
+ =render :partial => "layouts/admin_nav"
17
+ #content
18
+ / =render :partial => "layouts/flashes"
19
+ = yield
20
+ #footer
21
+ / =render :partial => "layouts/footer"
22
+ / =render :partial => "layouts/tracking"
@@ -0,0 +1,15 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ protected
5
+
6
+ def authenticate
7
+ authenticate_or_request_with_http_basic do |username, password|
8
+ username == "admin" && password == "p4ss"
9
+ end
10
+ # Only needed if Devise is running
11
+ # warden.custom_failure! if performed?
12
+ end
13
+
14
+
15
+ end
@@ -0,0 +1,7 @@
1
+ class DashboardController < ApplicationController
2
+ before_filter :authenticate
3
+
4
+ def show
5
+ render :action => params[:page]
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ <h1>Editing page</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', admin_pages_path %>
@@ -0,0 +1 @@
1
+ i am index.
@@ -0,0 +1,5 @@
1
+ <h1>New page</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', admin_pages_path %>
@@ -0,0 +1,25 @@
1
+ !!! 5
2
+
3
+ %html
4
+ %head
5
+ %title= yield(:title) || "Website"
6
+ %meta{:name => 'description', :content => "#{yield(:meta_desc)}"}
7
+ %meta{:name => "keywords", :content => "#{yield(:meta_keywords)}"}
8
+
9
+ = stylesheet_link_tag 'reset', 'style'
10
+ = javascript_include_tag :defaults
11
+ = csrf_meta_tag
12
+
13
+ %body{:id => "#{yield(:page_name)}" || "default"}
14
+
15
+ #container
16
+ #header
17
+ = render :partial => 'header'
18
+ #navigation
19
+ = render :partial => 'navigation'
20
+ #content
21
+ = yield
22
+ #sidebar
23
+ = render :partial => 'sidebar'
24
+ #footer
25
+ = render :partial => 'footer'
@@ -0,0 +1,31 @@
1
+ class Page < ActiveRecord::Base
2
+ validates_presence_of :name
3
+ validates_uniqueness_of :name
4
+ before_save :downcase_name
5
+
6
+ def title
7
+ name.titleize
8
+ end
9
+
10
+ def search_result_title
11
+ r = page_title.split(' | ')
12
+ r[0]
13
+ end
14
+
15
+ scope :visible, where("visible = ?", true).order('id')
16
+ scope :home, where("page_type = ?", 'home')
17
+
18
+ def self.search(search)
19
+ if search
20
+ find(:all, :conditions => ['name LIKE ? OR content LIKE ? OR page_title LIKE ? OR meta_keywords LIKE ? OR meta_description LIKE ?', "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%"])
21
+ else
22
+ find(:all)
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def downcase_name
29
+ self.name.downcase! unless self.name.blank?
30
+ end
31
+ end
@@ -0,0 +1,9 @@
1
+ class PageController < ApplicationController
2
+ def show
3
+ @page = Page.find_by_name params[:page]
4
+
5
+ if !@page
6
+ render :action => params[:page]
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ module PageHelper
2
+ def title(page_title)
3
+ content_for(:title) { page_title.to_s + " | BlizzardLaw.com" }
4
+ end
5
+
6
+ def page_name(name)
7
+ content_for(:page_name) { name.to_s }
8
+ end
9
+
10
+ def meta_desc(desc)
11
+ content_for(:meta_desc) { desc.to_s }
12
+ end
13
+
14
+ def meta_keywords(desc)
15
+ content_for(:meta_keywords) { desc.to_s }
16
+ end
17
+
18
+ def sidebar(content)
19
+ content_for(:sidebar) { content.to_s }
20
+ end
21
+
22
+ def nav_link(page)
23
+ link_to page.titleize, page_path(page.downcase), :id => page
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ %h1 Listing pages
2
+
3
+ %table{:class => "tablesorter"}
4
+ %thead
5
+ %tr
6
+ %th{:width => 200} Name
7
+ %th{:width => 290} Content
8
+ / %th{:width => 100} Type
9
+ / %th{:width => 120} Visible
10
+ / %th{:width => 170} Section
11
+ %th
12
+ %th
13
+ %tbody
14
+ - @pages.each do |page|
15
+ %tr
16
+ %td= page.name
17
+ %td= truncate page.content, :length => 60
18
+ / %td= page.page_type
19
+ / %td= page.visible
20
+ / %td= page.section
21
+ / %td= page.contactform
22
+ / %td= page.accordion
23
+ %td= link_to 'Edit', edit_admin_page_path(page)
24
+ %td= link_to 'Destroy', [:admin, page], :confirm => 'Are you sure?', :method => :delete
25
+
26
+ = link_to 'New Page', new_admin_page_path
@@ -0,0 +1,21 @@
1
+ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td
2
+ margin: 0
3
+ padding: 0
4
+ font-size: 100%
5
+ vertical-align: baseline
6
+ border: 0
7
+ outline: 0
8
+ background: transparent
9
+
10
+ ol, ul
11
+ list-style: none
12
+
13
+ blockquote, q
14
+ quotes: none
15
+
16
+ \:focus
17
+ outline: 0
18
+
19
+ table
20
+ border-collapse: collapse
21
+ border-spacing: 0
@@ -0,0 +1,20 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Name:</b>
5
+ <%= @page.name %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Content:</b>
10
+ <%= @page.content %>
11
+ </p>
12
+
13
+ <p>
14
+ <b>Visible:</b>
15
+ <%= @page.visible %>
16
+ </p>
17
+
18
+
19
+ <%= link_to 'Edit', edit_page_path(@page) %> |
20
+ <%= link_to 'Back', pages_path %>
@@ -0,0 +1 @@
1
+ = render 'page'
@@ -0,0 +1,102 @@
1
+ html
2
+ font: 13px/1.5em "Lucida Grande", calibri, Tahoma, Arial
3
+ body
4
+ background-color: #fff
5
+ #container
6
+ font-size: 1em
7
+ #header
8
+ background-color: #aaa
9
+ color: #fff
10
+ #navigation
11
+ background-color: #666
12
+ ul
13
+ li
14
+ list-style: none
15
+ margin: 5px 20px
16
+ padding: 3px
17
+ float: left
18
+ width: 100%
19
+ float: left
20
+ height: 35px
21
+ #flash
22
+ background-color: #000000
23
+ #content
24
+ background-color: #efefef
25
+ float: left
26
+ #sidebar
27
+ background-color: #aaa
28
+ color: #efefef
29
+ width: 200px
30
+ float: left
31
+ height: 140px
32
+ #footer
33
+ background-color: #999
34
+ color: #fff
35
+ clear: both
36
+
37
+ a
38
+ color: #fff
39
+ text-decoration: none
40
+
41
+ h1, h2, h3, h4, h5, h6
42
+ font-family: helvetica, arial, verdana, sans-serif
43
+ font-weight: normal
44
+
45
+ h1
46
+ font-size: 208%
47
+
48
+ h2
49
+ font-size: 164%
50
+
51
+ h3
52
+ font-size: 145%
53
+
54
+ h4
55
+ font-size: 118%
56
+
57
+
58
+ #flash
59
+ margin: 10px 0
60
+ width: 720px
61
+ color: #0f0f0f
62
+ font-size: 16px
63
+ .alert, .notice
64
+ background-color: #F5DF94
65
+ border: solid 5px #F5D671
66
+ padding: 7px
67
+
68
+ #flash_notice
69
+ background-color: #CFC
70
+ border: solid 1px #6C6
71
+
72
+ #flash_error
73
+ background-color: #FCC
74
+ border: solid 1px #C66
75
+
76
+ .fieldWithErrors
77
+ display: inline
78
+
79
+ #errorExplanation
80
+ width: 400px
81
+ border: 2px solid #CF0000
82
+ padding: 0px
83
+ padding-bottom: 12px
84
+ margin-bottom: 20px
85
+ background-color: #f0f0f0
86
+ h2
87
+ text-align: left
88
+ font-weight: bold
89
+ padding: 5px 5px 5px 15px
90
+ font-size: 12px
91
+ margin: 0
92
+ background-color: #c00
93
+ color: #fff
94
+ p
95
+ color: #333
96
+ margin-bottom: 0
97
+ padding: 8px
98
+ ul
99
+ margin: 2px 24px
100
+ li
101
+ font-size: 12px
102
+ list-style: disc
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'creature'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestCreature < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: creature
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Travis
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-30 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ type: :development
24
+ name: shoulda
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ prerelease: false
37
+ type: :development
38
+ name: bundler
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 23
45
+ segments:
46
+ - 1
47
+ - 0
48
+ - 0
49
+ version: 1.0.0
50
+ requirement: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ prerelease: false
53
+ type: :development
54
+ name: jeweler
55
+ version_requirements: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ hash: 1
61
+ segments:
62
+ - 1
63
+ - 5
64
+ - 1
65
+ version: 1.5.1
66
+ requirement: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ prerelease: false
69
+ type: :development
70
+ name: rcov
71
+ version_requirements: &id004 !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
+ requirement: *id004
81
+ description: Creature.
82
+ email: travis@impossiblecreature.com
83
+ executables: []
84
+
85
+ extensions: []
86
+
87
+ extra_rdoc_files:
88
+ - LICENSE.txt
89
+ - README.rdoc
90
+ files:
91
+ - .document
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.rdoc
96
+ - Rakefile
97
+ - VERSION
98
+ - creature.gemspec
99
+ - lib/creature.rb
100
+ - lib/generators/pages/USAGE
101
+ - lib/generators/pages/pages_generator.rb
102
+ - lib/generators/pages/templates/_admin_nav.html.haml
103
+ - lib/generators/pages/templates/_footer.html.haml
104
+ - lib/generators/pages/templates/_form.html.erb
105
+ - lib/generators/pages/templates/_header.html.haml
106
+ - lib/generators/pages/templates/_navigation.html.haml
107
+ - lib/generators/pages/templates/_page.html.haml
108
+ - lib/generators/pages/templates/_sidebar.html.haml
109
+ - lib/generators/pages/templates/admin_pages_controller.rb
110
+ - lib/generators/pages/templates/application.html.haml
111
+ - lib/generators/pages/templates/application_controller.rb
112
+ - lib/generators/pages/templates/dashboard_controller.rb
113
+ - lib/generators/pages/templates/edit.html.erb
114
+ - lib/generators/pages/templates/index.html.haml
115
+ - lib/generators/pages/templates/new.html.erb
116
+ - lib/generators/pages/templates/page.html.haml
117
+ - lib/generators/pages/templates/page.rb
118
+ - lib/generators/pages/templates/page_controller.rb
119
+ - lib/generators/pages/templates/page_helper.rb
120
+ - lib/generators/pages/templates/pages_index.html.haml
121
+ - lib/generators/pages/templates/reset.sass
122
+ - lib/generators/pages/templates/show.html.erb
123
+ - lib/generators/pages/templates/show.html.haml
124
+ - lib/generators/pages/templates/style.sass
125
+ - test/helper.rb
126
+ - test/test_creature.rb
127
+ has_rdoc: true
128
+ homepage: http://github.com/terard/creature
129
+ licenses:
130
+ - MIT
131
+ post_install_message:
132
+ rdoc_options: []
133
+
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ hash: 3
142
+ segments:
143
+ - 0
144
+ version: "0"
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ none: false
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ hash: 3
151
+ segments:
152
+ - 0
153
+ version: "0"
154
+ requirements: []
155
+
156
+ rubyforge_project:
157
+ rubygems_version: 1.3.7
158
+ signing_key:
159
+ specification_version: 3
160
+ summary: Creature.
161
+ test_files:
162
+ - test/helper.rb
163
+ - test/test_creature.rb