feather_cms 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -2
- data/lib/feather_cms/config.rb +11 -15
- data/lib/feather_cms/version.rb +1 -1
- data/lib/generators/feather_cms/USAGE +4 -1
- data/lib/generators/feather_cms/feather_cms_generator.rb +14 -15
- data/lib/generators/feather_cms/templates/controller.rb +7 -1
- data/lib/generators/feather_cms/templates/initializer.rb +6 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -10,13 +10,15 @@ Add the gem to your Gemfile
|
|
10
10
|
|
11
11
|
Now, generate the pages
|
12
12
|
|
13
|
-
$ rake db:migrate
|
14
|
-
|
15
13
|
# Use file system to store pages( default: public/system/templates)
|
16
14
|
$ rails g feather_cms about_us jobs team
|
17
15
|
|
18
16
|
#Use db to store pages
|
19
17
|
$ rails g feather_cms about_us jobs team --storage=db
|
18
|
+
or
|
19
|
+
$ rails g feather_cms about_us jobs team -t=db
|
20
|
+
|
21
|
+
$ rake db:migrate
|
20
22
|
|
21
23
|
This generates a route, the controller action and the view for each page. Start the server and use the URL http://localhost:3000/feathers/pages to go to the admin panel.
|
22
24
|
|
data/lib/feather_cms/config.rb
CHANGED
@@ -28,24 +28,20 @@ module FeatherCms
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
@@config[:
|
33
|
-
end
|
34
|
-
|
35
|
-
def template_store_path
|
36
|
-
@@config[:template_store_path]
|
37
|
-
end
|
38
|
-
|
39
|
-
def template_extenstion=(value)
|
40
|
-
@@config[:template_extenstion] = value
|
31
|
+
def layouts
|
32
|
+
@@config[:layouts]
|
41
33
|
end
|
42
34
|
|
43
|
-
|
44
|
-
|
45
|
-
|
35
|
+
[:template_store_path, :template_extenstion, :authentication].each do |attr|
|
36
|
+
class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
37
|
+
def #{attr}=(value)
|
38
|
+
@@config[:#{attr}] = value
|
39
|
+
end
|
46
40
|
|
47
|
-
|
48
|
-
|
41
|
+
def #{attr}
|
42
|
+
@@config[:#{attr}]
|
43
|
+
end
|
44
|
+
METHOD
|
49
45
|
end
|
50
46
|
|
51
47
|
end
|
data/lib/feather_cms/version.rb
CHANGED
@@ -5,6 +5,9 @@ Description:
|
|
5
5
|
Example:
|
6
6
|
rails generate feather_cms about_us jobs [--storage=file or db]
|
7
7
|
|
8
|
+
Options
|
9
|
+
--storage= file or db / -t= file or db
|
10
|
+
|
8
11
|
This will create:
|
9
|
-
- Add config file 'feather_cms.
|
12
|
+
- Add config file 'feather_cms.rb'
|
10
13
|
- Add Codemirror javascript and css
|
@@ -1,17 +1,10 @@
|
|
1
|
-
class FeatherCmsGenerator < Rails::Generators::
|
1
|
+
class FeatherCmsGenerator < Rails::Generators::Base
|
2
2
|
source_root File.expand_path('../templates', __FILE__)
|
3
3
|
argument :attributes, :type => :array, :banner => "about_us jobs"
|
4
|
-
|
5
|
-
class_option :storage, :aliases => '-s', :type => :string, :desc => 'db or file storage.'
|
4
|
+
class_option :storage, :aliases => '-t', :type => :string, :desc => 'db or file storage.'
|
6
5
|
|
7
6
|
def create_cms_files
|
8
|
-
@
|
9
|
-
|
10
|
-
@storage = if ['file', 'db'].include?(options['storage'])
|
11
|
-
options['storage']
|
12
|
-
else
|
13
|
-
'file'
|
14
|
-
end
|
7
|
+
@storage = ['file', 'db'].include?(options['storage']) ? options['storage'] : 'file'
|
15
8
|
|
16
9
|
template 'initializer.rb', 'config/initializers/feather_cms.rb'
|
17
10
|
template 'controller.rb', 'app/controllers/feathers_controller.rb'
|
@@ -25,17 +18,25 @@ class FeatherCmsGenerator < Rails::Generators::NamedBase
|
|
25
18
|
end
|
26
19
|
|
27
20
|
template 'migration.rb', "db/migrate/#{migration_number}_create_feather_pages.rb"
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_routes
|
24
|
+
feather_route =
|
25
|
+
<<-ROUTES
|
28
26
|
|
29
|
-
|
27
|
+
scope '/feathers' do
|
30
28
|
match 'page/:type/(:status)' => 'feathers#page', :as => :feather_page
|
31
29
|
get 'pages' => 'feathers#index', :as => :feather_pages
|
32
30
|
get 'preivew/:type/(:status)' => 'feathers#preivew', :as => 'feather_page_preview'
|
33
31
|
end
|
34
|
-
get 'page/:type' => 'feathers#published', :as => 'feather_published_page'
|
32
|
+
get 'page/:type' => 'feathers#published', :as => 'feather_published_page'
|
33
|
+
ROUTES
|
34
|
+
|
35
|
+
route feather_route
|
35
36
|
end
|
36
37
|
|
37
38
|
def copy_view_files
|
38
|
-
@pages = attributes
|
39
|
+
@pages = attributes
|
39
40
|
base_path = File.join("app/views/feathers")
|
40
41
|
#empty_directory base_path
|
41
42
|
template 'layout.html.erb', 'app/views/layouts/feather_layout.html.erb'
|
@@ -58,6 +59,4 @@ class FeatherCmsGenerator < Rails::Generators::NamedBase
|
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
61
|
-
|
62
|
-
|
63
62
|
end
|
@@ -1,5 +1,11 @@
|
|
1
1
|
class FeathersController < ApplicationController
|
2
|
-
|
2
|
+
|
3
|
+
if FeatherCms::Config.authentication.kind_of?(Hash)
|
4
|
+
http_basic_authenticate_with FeatherCms::Config.authentication.merge(except: :published)
|
5
|
+
else
|
6
|
+
before_filter FeatherCms::Config.authentication.to_sym, except: :published
|
7
|
+
end
|
8
|
+
|
3
9
|
before_filter :find_page, only: [:page, :preivew]
|
4
10
|
|
5
11
|
layout 'feather_layout', except: [:preivew, :published]
|
@@ -1,5 +1,11 @@
|
|
1
1
|
FeatherCms::Config.init do |c|
|
2
2
|
c.template_store_path = 'public/system/templates'
|
3
3
|
c.template_store_type = :<%= @storage %>
|
4
|
+
|
5
|
+
#Note: For basic authentication
|
6
|
+
c.authentication = {name: 'feather', password: 'password'}
|
7
|
+
#Note: For before filter
|
8
|
+
#c.authentication = :authenticate_user!
|
9
|
+
|
4
10
|
#c.template_extenstion = 'html' #default : html
|
5
11
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feather_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152283260 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152283260
|
25
25
|
description: Lightweight do it youself cms
|
26
26
|
email:
|
27
27
|
- jiren@joshsoftware.com
|