public
Description: Rails Plugin - a RailsEngines-based CMS extension for any Rails project
Homepage: http://6brand.com
Clone URL: git://github.com/JackDanger/simple_pages.git
Search Repo:
importing bare plugin

git-svn-id: http://svn.6brand.com/projects/plugins/simple_pages@289 
7491b73d-821b-0410-9297-ad1f6b5b4194
studioda (author)
Tue Feb 20 13:13:18 -0800 2007
commit  1aa1cfb1b026aebd5fe58b59809a0643ddc1a23c
tree    b52a4cc92cace5ccd1de37c90253447b67e4d71c
0
...
 
 
 
 
0
...
1
2
3
4
5
0
@@ -0,0 +1,4 @@
0
+SimplePages
0
+===========
0
+
0
+Description goes here
0
\ No newline at end of file
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -0,0 +1,22 @@
0
+require 'rake'
0
+require 'rake/testtask'
0
+require 'rake/rdoctask'
0
+
0
+desc 'Default: run unit tests.'
0
+task :default => :test
0
+
0
+desc 'Test the simple_pages plugin.'
0
+Rake::TestTask.new(:test) do |t|
0
+ t.libs << 'lib'
0
+ t.pattern = 'test/**/*_test.rb'
0
+ t.verbose = true
0
+end
0
+
0
+desc 'Generate documentation for the simple_pages plugin.'
0
+Rake::RDocTask.new(:rdoc) do |rdoc|
0
+ rdoc.rdoc_dir = 'rdoc'
0
+ rdoc.title = 'SimplePages'
0
+ rdoc.options << '--line-numbers' << '--inline-source'
0
+ rdoc.rdoc_files.include('README')
0
+ rdoc.rdoc_files.include('lib/**/*.rb')
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
0
@@ -0,0 +1,69 @@
0
+class SimplePagesController < ApplicationController
0
+
0
+ before_filter :admin_required, :only => [:edit,
0
+ :create,
0
+ :update,
0
+ :destroy]
0
+ before_filter :find_or_initialize, :except => :index
0
+ before_filter :set_title
0
+
0
+ def index
0
+ @pages = Page.find(:all)
0
+ end
0
+
0
+ # render show
0
+
0
+ def edit
0
+ @page.revert_to(params[:version]) if params[:version] && @page.respond_to(:revert_to)
0
+ end
0
+
0
+ def create
0
+ @page.update_attributes!(params[:page])
0
+ flash[:success] = "Page successfully created"
0
+ redirect_to :action => 'show', :id => @page
0
+ end
0
+
0
+ def update
0
+ @page.update_attributes!(params[:page])
0
+ flash[:success] = "Page successfully modified"
0
+ redirect_to :action => 'show', :id => @page
0
+ end
0
+
0
+ def destroy
0
+ @page.destroy
0
+ flash[:success] = "Page successfully deleted"
0
+ redirect_to :action => 'index'
0
+ end
0
+
0
+ protected
0
+
0
+ def find_or_initialize
0
+ @page = params[:id] ? Page.find_by_filename(params[:id]) : Page.new
0
+ end
0
+
0
+ def set_title
0
+ @title = @page.title if @page.respond_to(:title)
0
+ end
0
+
0
+ def rescue_action(exception)
0
+ case exception.class.name
0
+ when 'ActiveRecord::RecordInvalid'
0
+ render_invalid_record(exception.record)
0
+ when 'ActionController::RoutingError',
0
+ 'ActionController::UnknownAction',
0
+ 'ActiveRecord::RecordNotFound'
0
+ render_404
0
+ else
0
+ super
0
+ end
0
+ end
0
+
0
+ def render_invalid_record(record)
0
+ render :action => (record.new_record? ? 'new' : 'edit')
0
+ end
0
+
0
+ def render_404
0
+ render :text => "<h1>Whoops! That's a bad link.</h1>", :layout => true, :status => "404 Not Found"
0
+ end
0
+
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
0
@@ -0,0 +1,24 @@
0
+class SimplePage < ActiveRecord::Base
0
+
0
+ # make sure to install the acts_as_versioned plugin to make simple_pages work!
0
+ # $ ruby script/plugin source http://svn.techno-weenie.net/projects/plugins
0
+ # $ ruby script/plugin install -x acts_as_versioned
0
+ acts_as_versioned
0
+
0
+ validates_presence_of :filename, :title
0
+ validates_uniqueness_of :filename, :title
0
+
0
+ before_save :fix_filename
0
+ before_save :process_content
0
+
0
+ # Page#to_param is used to fill the :id portion of the request. This gives us pretty urls.
0
+ def to_param
0
+ self.filename
0
+ end
0
+
0
+ # make lowercase and underscored
0
+ def fix_filename
0
+ self.filename = filename.downcase.gsub(' ', '_')
0
+ end
0
+
0
+end
0
\ No newline at end of file
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
0
@@ -0,0 +1,17 @@
0
+class CreateSimplePages < ActiveRecord::Migration
0
+ def self.up
0
+ create_table :simple_pages do |t|
0
+ t.column :filename, :string
0
+ t.column :title, :string
0
+ t.column :content, :text
0
+ t.column :created_at, :datetime
0
+ t.column :updated_at, :datetime
0
+ end
0
+ SimplePage.create_versioned_table
0
+ end
0
+
0
+ def self.down
0
+ drop_table :simple_pages
0
+ SimplePage.drop_versioned_table
0
+ end
0
+end
...
 
0
...
1
2
0
@@ -0,0 +1 @@
0
+# Include hook code here
0
\ No newline at end of file
...
 
...
1
0
@@ -0,0 +1 @@
0
+# Install hook code here
...
 
0
...
1
2
0
@@ -0,0 +1 @@
0
+# SimplePages
0
\ No newline at end of file
...
 
 
 
 
0
...
1
2
3
4
5
0
@@ -0,0 +1,4 @@
0
+# desc "Explaining what the task does"
0
+# task :simple_pages do
0
+# # Task goes here
0
+# end
0
\ No newline at end of file
...
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
0
@@ -0,0 +1,8 @@
0
+require 'test/unit'
0
+
0
+class SimplePagesTest < Test::Unit::TestCase
0
+ # Replace this with your real tests.
0
+ def test_this_plugin
0
+ flunk
0
+ end
0
+end
...
 
...
1
0
@@ -0,0 +1 @@
0
+# Uninstall hook code here

Comments

    No one has commented yet.