Add sitemap functionality and better documentation
This commit is contained in:
@@ -5,9 +5,9 @@ source "http://rubygems.org"
|
|||||||
# development dependencies will be added by default to the :development group.
|
# development dependencies will be added by default to the :development group.
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
gem "rails", ">= 4.1.4"
|
gem "rails", "4.2.0.beta4"
|
||||||
group :assets do
|
group :assets do
|
||||||
gem 'sass-rails', '4.0.2'
|
gem 'sass-rails', '5.0.0.beta1'
|
||||||
gem 'bourbon'
|
gem 'bourbon'
|
||||||
gem 'coffee-script'
|
gem 'coffee-script'
|
||||||
#gem 'therubyracer', :platforms => :ruby
|
#gem 'therubyracer', :platforms => :ruby
|
||||||
@@ -25,6 +25,7 @@ gem 'haml-rails'
|
|||||||
gem 'slim-rails'
|
gem 'slim-rails'
|
||||||
gem 'paperclip'
|
gem 'paperclip'
|
||||||
gem 'email_validator'
|
gem 'email_validator'
|
||||||
|
gem 'actionpack-page_caching'
|
||||||
# Declare any dependencies that are still in development here instead of in
|
# Declare any dependencies that are still in development here instead of in
|
||||||
# your gemspec. These might include edge Rails or gems from your path or
|
# your gemspec. These might include edge Rails or gems from your path or
|
||||||
# Git. Remember to move these dependencies to your gemspec before releasing
|
# Git. Remember to move these dependencies to your gemspec before releasing
|
||||||
|
|||||||
+118
-95
@@ -1,6 +1,6 @@
|
|||||||
GIT
|
GIT
|
||||||
remote: git://github.com/bterkuile/couch_potato.git
|
remote: git://github.com/bterkuile/couch_potato.git
|
||||||
revision: 6fbcb3edcaf3edec63230308f123c1e03417967d
|
revision: 8929326ee855e964a441a8ede941b52c0ee88a16
|
||||||
specs:
|
specs:
|
||||||
couch_potato (0.7.1)
|
couch_potato (0.7.1)
|
||||||
activemodel
|
activemodel
|
||||||
@@ -43,41 +43,52 @@ PATH
|
|||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
actionmailer (4.1.4)
|
actionmailer (4.2.0.beta4)
|
||||||
actionpack (= 4.1.4)
|
actionpack (= 4.2.0.beta4)
|
||||||
actionview (= 4.1.4)
|
actionview (= 4.2.0.beta4)
|
||||||
mail (~> 2.5.4)
|
activejob (= 4.2.0.beta4)
|
||||||
actionpack (4.1.4)
|
mail (~> 2.5, >= 2.5.4)
|
||||||
actionview (= 4.1.4)
|
rails-dom-testing (~> 1.0, >= 1.0.4)
|
||||||
activesupport (= 4.1.4)
|
actionpack (4.2.0.beta4)
|
||||||
rack (~> 1.5.2)
|
actionview (= 4.2.0.beta4)
|
||||||
|
activesupport (= 4.2.0.beta4)
|
||||||
|
rack (~> 1.6.0.beta)
|
||||||
rack-test (~> 0.6.2)
|
rack-test (~> 0.6.2)
|
||||||
actionview (4.1.4)
|
rails-dom-testing (~> 1.0, >= 1.0.4)
|
||||||
activesupport (= 4.1.4)
|
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
||||||
|
actionpack-page_caching (1.0.2)
|
||||||
|
actionpack (>= 4.0.0, < 5)
|
||||||
|
actionview (4.2.0.beta4)
|
||||||
|
activesupport (= 4.2.0.beta4)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
erubis (~> 2.7.0)
|
erubis (~> 2.7.0)
|
||||||
activemodel (4.1.4)
|
rails-dom-testing (~> 1.0, >= 1.0.4)
|
||||||
activesupport (= 4.1.4)
|
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
||||||
|
activejob (4.2.0.beta4)
|
||||||
|
activesupport (= 4.2.0.beta4)
|
||||||
|
globalid (>= 0.3.0)
|
||||||
|
activemodel (4.2.0.beta4)
|
||||||
|
activesupport (= 4.2.0.beta4)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
activerecord (4.1.4)
|
activerecord (4.2.0.beta4)
|
||||||
activemodel (= 4.1.4)
|
activemodel (= 4.2.0.beta4)
|
||||||
activesupport (= 4.1.4)
|
activesupport (= 4.2.0.beta4)
|
||||||
arel (~> 5.0.0)
|
arel (>= 6.0.0.beta2, < 6.1)
|
||||||
activesupport (4.1.4)
|
activesupport (4.2.0.beta4)
|
||||||
i18n (~> 0.6, >= 0.6.9)
|
i18n (>= 0.7.0.beta1, < 0.8)
|
||||||
json (~> 1.7, >= 1.7.7)
|
json (~> 1.7, >= 1.7.7)
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
arel (5.0.1.20140414130214)
|
arel (6.0.0.beta2)
|
||||||
bcrypt (3.1.7)
|
bcrypt (3.1.9)
|
||||||
bootstrap-sass (2.3.2.2)
|
bootstrap-sass (2.3.2.2)
|
||||||
sass (~> 3.2)
|
sass (~> 3.2)
|
||||||
bourbon (3.2.3)
|
bourbon (4.0.2)
|
||||||
sass (~> 3.2)
|
sass (~> 3.3)
|
||||||
thor
|
thor
|
||||||
builder (3.2.2)
|
builder (3.2.2)
|
||||||
capybara (2.4.1)
|
capybara (2.4.4)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
nokogiri (>= 1.3.3)
|
nokogiri (>= 1.3.3)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
@@ -91,16 +102,17 @@ GEM
|
|||||||
coffee-script (2.3.0)
|
coffee-script (2.3.0)
|
||||||
coffee-script-source
|
coffee-script-source
|
||||||
execjs
|
execjs
|
||||||
coffee-script-source (1.7.1)
|
coffee-script-source (1.8.0)
|
||||||
couchrest (1.2.0)
|
couchrest (1.2.0)
|
||||||
mime-types (~> 1.15)
|
mime-types (~> 1.15)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
rest-client (~> 1.6.1)
|
rest-client (~> 1.6.1)
|
||||||
daemons (1.1.9)
|
daemons (1.1.9)
|
||||||
devise (3.2.4)
|
devise (3.4.1)
|
||||||
bcrypt (~> 3.0)
|
bcrypt (~> 3.0)
|
||||||
orm_adapter (~> 0.1)
|
orm_adapter (~> 0.1)
|
||||||
railties (>= 3.2.6, < 5)
|
railties (>= 3.2.6, < 5)
|
||||||
|
responders
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
warden (~> 1.2.3)
|
warden (~> 1.2.3)
|
||||||
diff-lcs (1.2.5)
|
diff-lcs (1.2.5)
|
||||||
@@ -108,12 +120,14 @@ GEM
|
|||||||
activemodel
|
activemodel
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
eventmachine (1.0.3)
|
eventmachine (1.0.3)
|
||||||
execjs (2.2.1)
|
execjs (2.2.2)
|
||||||
factory_girl (4.4.0)
|
factory_girl (4.5.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
factory_girl_rails (4.4.1)
|
factory_girl_rails (4.5.0)
|
||||||
factory_girl (~> 4.4.0)
|
factory_girl (~> 4.5.0)
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
|
globalid (0.3.0)
|
||||||
|
activesupport (>= 4.1.0)
|
||||||
haml (4.0.5)
|
haml (4.0.5)
|
||||||
tilt
|
tilt
|
||||||
haml-rails (0.5.3)
|
haml-rails (0.5.3)
|
||||||
@@ -122,119 +136,127 @@ GEM
|
|||||||
haml (>= 3.1, < 5.0)
|
haml (>= 3.1, < 5.0)
|
||||||
railties (>= 4.0.1)
|
railties (>= 4.0.1)
|
||||||
hike (1.2.3)
|
hike (1.2.3)
|
||||||
i18n (0.6.11)
|
i18n (0.7.0.beta1)
|
||||||
jquery-rails (3.1.1)
|
jquery-rails (3.1.2)
|
||||||
railties (>= 3.0, < 5.0)
|
railties (>= 3.0, < 5.0)
|
||||||
thor (>= 0.14, < 2.0)
|
thor (>= 0.14, < 2.0)
|
||||||
jquery-ui-rails (5.0.0)
|
jquery-ui-rails (5.0.2)
|
||||||
railties (>= 3.2.16)
|
railties (>= 3.2.16)
|
||||||
json (1.8.1)
|
json (1.8.1)
|
||||||
mail (2.5.4)
|
loofah (2.0.1)
|
||||||
mime-types (~> 1.16)
|
nokogiri (>= 1.5.9)
|
||||||
treetop (~> 1.4.8)
|
mail (2.6.3)
|
||||||
|
mime-types (>= 1.16, < 3)
|
||||||
method_source (0.8.2)
|
method_source (0.8.2)
|
||||||
mime-types (1.25.1)
|
mime-types (1.25.1)
|
||||||
mini_portile (0.6.0)
|
mini_portile (0.6.1)
|
||||||
minitest (5.4.0)
|
minitest (5.4.2)
|
||||||
multi_json (1.10.1)
|
multi_json (1.10.1)
|
||||||
nokogiri (1.6.2.1)
|
nokogiri (1.6.4)
|
||||||
mini_portile (= 0.6.0)
|
mini_portile (~> 0.6.0)
|
||||||
paperclip (4.2.0)
|
paperclip (4.2.0)
|
||||||
activemodel (>= 3.0.0)
|
activemodel (>= 3.0.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
cocaine (~> 0.5.3)
|
cocaine (~> 0.5.3)
|
||||||
mime-types
|
mime-types
|
||||||
polyglot (0.3.5)
|
pry (0.10.1)
|
||||||
pry (0.10.0)
|
|
||||||
coderay (~> 1.1.0)
|
coderay (~> 1.1.0)
|
||||||
method_source (~> 0.8.1)
|
method_source (~> 0.8.1)
|
||||||
slop (~> 3.4)
|
slop (~> 3.4)
|
||||||
pry-rails (0.3.2)
|
pry-rails (0.3.2)
|
||||||
pry (>= 0.9.10)
|
pry (>= 0.9.10)
|
||||||
rack (1.5.2)
|
rack (1.6.0.beta)
|
||||||
rack-test (0.6.2)
|
rack-test (0.6.2)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
rails (4.1.4)
|
rails (4.2.0.beta4)
|
||||||
actionmailer (= 4.1.4)
|
actionmailer (= 4.2.0.beta4)
|
||||||
actionpack (= 4.1.4)
|
actionpack (= 4.2.0.beta4)
|
||||||
actionview (= 4.1.4)
|
actionview (= 4.2.0.beta4)
|
||||||
activemodel (= 4.1.4)
|
activejob (= 4.2.0.beta4)
|
||||||
activerecord (= 4.1.4)
|
activemodel (= 4.2.0.beta4)
|
||||||
activesupport (= 4.1.4)
|
activerecord (= 4.2.0.beta4)
|
||||||
|
activesupport (= 4.2.0.beta4)
|
||||||
bundler (>= 1.3.0, < 2.0)
|
bundler (>= 1.3.0, < 2.0)
|
||||||
railties (= 4.1.4)
|
railties (= 4.2.0.beta4)
|
||||||
sprockets-rails (~> 2.0)
|
sprockets-rails (~> 3.0.0.beta1)
|
||||||
railties (4.1.4)
|
rails-deprecated_sanitizer (1.0.3)
|
||||||
actionpack (= 4.1.4)
|
activesupport (>= 4.2.0.alpha)
|
||||||
activesupport (= 4.1.4)
|
rails-dom-testing (1.0.4)
|
||||||
|
activesupport (>= 4.2.0.beta, < 5.0)
|
||||||
|
nokogiri (~> 1.6.0)
|
||||||
|
rails-deprecated_sanitizer (>= 1.0.1)
|
||||||
|
rails-html-sanitizer (1.0.1)
|
||||||
|
loofah (~> 2.0)
|
||||||
|
railties (4.2.0.beta4)
|
||||||
|
actionpack (= 4.2.0.beta4)
|
||||||
|
activesupport (= 4.2.0.beta4)
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
thor (>= 0.18.1, < 2.0)
|
thor (>= 0.18.1, < 2.0)
|
||||||
rake (10.3.2)
|
rake (10.3.2)
|
||||||
rdoc (4.1.1)
|
rdoc (4.1.2)
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
|
responders (2.0.1)
|
||||||
|
railties (>= 4.2.0.alpha, < 5)
|
||||||
rest-client (1.6.8)
|
rest-client (1.6.8)
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
rdoc (>= 2.4.2)
|
rdoc (>= 2.4.2)
|
||||||
rspec-core (3.0.2)
|
rspec-core (3.1.7)
|
||||||
rspec-support (~> 3.0.0)
|
rspec-support (~> 3.1.0)
|
||||||
rspec-expectations (3.0.2)
|
rspec-expectations (3.1.2)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.0.0)
|
rspec-support (~> 3.1.0)
|
||||||
rspec-its (1.0.1)
|
rspec-its (1.1.0)
|
||||||
rspec-core (>= 2.99.0.beta1)
|
rspec-core (>= 3.0.0)
|
||||||
rspec-expectations (>= 2.99.0.beta1)
|
rspec-expectations (>= 3.0.0)
|
||||||
rspec-mocks (3.0.2)
|
rspec-mocks (3.1.3)
|
||||||
rspec-support (~> 3.0.0)
|
rspec-support (~> 3.1.0)
|
||||||
rspec-rails (3.0.1)
|
rspec-rails (3.1.0)
|
||||||
actionpack (>= 3.0)
|
actionpack (>= 3.0)
|
||||||
activesupport (>= 3.0)
|
activesupport (>= 3.0)
|
||||||
railties (>= 3.0)
|
railties (>= 3.0)
|
||||||
rspec-core (~> 3.0.0)
|
rspec-core (~> 3.1.0)
|
||||||
rspec-expectations (~> 3.0.0)
|
rspec-expectations (~> 3.1.0)
|
||||||
rspec-mocks (~> 3.0.0)
|
rspec-mocks (~> 3.1.0)
|
||||||
rspec-support (~> 3.0.0)
|
rspec-support (~> 3.1.0)
|
||||||
rspec-support (3.0.2)
|
rspec-support (3.1.2)
|
||||||
sass (3.2.19)
|
sass (3.4.7)
|
||||||
sass-rails (4.0.2)
|
sass-rails (5.0.0.beta1)
|
||||||
railties (>= 4.0.0, < 5.0)
|
railties (>= 4.0.0, < 5.0)
|
||||||
sass (~> 3.2.0)
|
sass (~> 3.2)
|
||||||
sprockets (~> 2.8, <= 2.11.0)
|
sprockets (~> 2.12)
|
||||||
sprockets-rails (~> 2.0.0)
|
sprockets-rails (>= 2.0, < 4.0)
|
||||||
slim (2.0.3)
|
slim (2.1.0)
|
||||||
temple (~> 0.6.6)
|
temple (~> 0.6.9)
|
||||||
tilt (>= 1.3.3, < 2.1)
|
tilt (>= 1.3.3, < 2.1)
|
||||||
slim-rails (2.1.5)
|
slim-rails (2.1.5)
|
||||||
actionpack (>= 3.0, < 4.2)
|
actionpack (>= 3.0, < 4.2)
|
||||||
activesupport (>= 3.0, < 4.2)
|
activesupport (>= 3.0, < 4.2)
|
||||||
railties (>= 3.0, < 4.2)
|
railties (>= 3.0, < 4.2)
|
||||||
slim (~> 2.0)
|
slim (~> 2.0)
|
||||||
slop (3.5.0)
|
slop (3.6.0)
|
||||||
sprockets (2.11.0)
|
sprockets (2.12.3)
|
||||||
hike (~> 1.2)
|
hike (~> 1.2)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
rack (~> 1.0)
|
rack (~> 1.0)
|
||||||
tilt (~> 1.1, != 1.3.0)
|
tilt (~> 1.1, != 1.3.0)
|
||||||
sprockets-rails (2.0.1)
|
sprockets-rails (3.0.0.beta1)
|
||||||
actionpack (>= 3.0)
|
actionpack (>= 4.0)
|
||||||
activesupport (>= 3.0)
|
activesupport (>= 4.0)
|
||||||
sprockets (~> 2.8)
|
sprockets (~> 2.8)
|
||||||
steak (2.0.0)
|
steak (2.0.0)
|
||||||
capybara (>= 1.0.0)
|
capybara (>= 1.0.0)
|
||||||
rspec-rails (>= 2.5.0)
|
rspec-rails (>= 2.5.0)
|
||||||
temple (0.6.8)
|
temple (0.6.10)
|
||||||
thin (1.6.2)
|
thin (1.6.3)
|
||||||
daemons (>= 1.0.9)
|
daemons (~> 1.0, >= 1.0.9)
|
||||||
eventmachine (>= 1.0.0)
|
eventmachine (~> 1.0)
|
||||||
rack (>= 1.0.0)
|
rack (~> 1.0)
|
||||||
thor (0.19.1)
|
thor (0.19.1)
|
||||||
thread_safe (0.3.4)
|
thread_safe (0.3.4)
|
||||||
tilt (1.4.1)
|
tilt (1.4.1)
|
||||||
tinymce-rails (4.1.0)
|
tinymce-rails (4.1.6)
|
||||||
railties (>= 3.1.1)
|
railties (>= 3.1.1)
|
||||||
treetop (1.4.15)
|
tzinfo (1.2.2)
|
||||||
polyglot
|
|
||||||
polyglot (>= 0.3.1)
|
|
||||||
tzinfo (1.2.1)
|
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
warden (1.2.3)
|
warden (1.2.3)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
@@ -245,6 +267,7 @@ PLATFORMS
|
|||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
actionpack-page_caching
|
||||||
bootstrap-sass (~> 2.3)
|
bootstrap-sass (~> 2.3)
|
||||||
bourbon
|
bourbon
|
||||||
cmtool!
|
cmtool!
|
||||||
@@ -260,9 +283,9 @@ DEPENDENCIES
|
|||||||
orm_adapter!
|
orm_adapter!
|
||||||
paperclip
|
paperclip
|
||||||
pry-rails
|
pry-rails
|
||||||
rails (>= 4.1.4)
|
rails (= 4.2.0.beta4)
|
||||||
rspec-its
|
rspec-its
|
||||||
sass-rails (= 4.0.2)
|
sass-rails (= 5.0.0.beta1)
|
||||||
simply_stored!
|
simply_stored!
|
||||||
slim-rails
|
slim-rails
|
||||||
steak
|
steak
|
||||||
|
|||||||
@@ -0,0 +1,163 @@
|
|||||||
|
# Cmtool
|
||||||
|
[<img src="https://secure.travis-ci.org/bterkuile/cmtool.png?branch=master"
|
||||||
|
alt="Build Status" />](http://travis-ci.org/bterkuile/cmtool)
|
||||||
|
## About
|
||||||
|
Cmtool is a CMS to give you a quickstart for a website using CouchDB as
|
||||||
|
database backend. It is in developing stage, but already used in production.
|
||||||
|
It is designed as an engine. The thought behind is that you will have to
|
||||||
|
create your own rails website, but get a lot of stuff for free. These things
|
||||||
|
are:
|
||||||
|
|
||||||
|
* User management
|
||||||
|
* Page management
|
||||||
|
* Faq
|
||||||
|
* News
|
||||||
|
* Newsletter subscriptions
|
||||||
|
* Directory manager
|
||||||
|
* Image manager
|
||||||
|
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
To start using Cmtool as website CMS add it to your Gemfile. Since it depends
|
||||||
|
on github gems and gem dependencies do not support those you have to
|
||||||
|
explicitly add two dependencies to your Gemfile:
|
||||||
|
gem 'couch_potato' , :git => 'git://github.com/bterkuile/couch_potato.git'
|
||||||
|
gem 'simply_stored' , :git => 'git://github.com/bterkuile/simply_stored.git'
|
||||||
|
gem 'cmtool'
|
||||||
|
|
||||||
|
This will add some gems you might like anyway, here a list:
|
||||||
|
|
||||||
|
* bourbon
|
||||||
|
* jquery-rails
|
||||||
|
* tinymce-rails
|
||||||
|
* sass-rails
|
||||||
|
* haml-rails
|
||||||
|
* paperclip
|
||||||
|
* email_validator (validates :email, email: true)
|
||||||
|
|
||||||
|
|
||||||
|
### Controllers
|
||||||
|
|
||||||
|
in `app/controllers/pages_controller.rb`:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
class PagesController
|
||||||
|
include Cmtool::Includes::PagesController
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
in `app/models/page.rb`:
|
||||||
|
```ruby
|
||||||
|
class Page
|
||||||
|
include Cmtool::Includes::Page
|
||||||
|
|
||||||
|
def self.layouts
|
||||||
|
%w[home application contact]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
### Securing
|
||||||
|
|
||||||
|
Cmtool is looking for an authorize_cmtool method present in the application
|
||||||
|
controller. Something like:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
class ApplicationController
|
||||||
|
...
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def authorize_cmtool
|
||||||
|
redirect_to main_app.root_path, alert: t('general.unauthorized') unless current_user.present? && current_user.is_admin?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
### Routing
|
||||||
|
|
||||||
|
Add the following routes:
|
||||||
|
```ruby
|
||||||
|
devise_for :users, :controllers => {:sessions => 'cmtool/sessions', :passwords => 'cmtool/passwords'}
|
||||||
|
mount Cmtool::Engine => '/cmtool'
|
||||||
|
get '/sitemap(.:format)' => 'pages#sitemap'
|
||||||
|
scope '(/:locale)', constraints: {locale: /nl|be|de|fr|en/}, defaults: { locale: :nl } do
|
||||||
|
get "/:name" => "pages#show", constraints: {name: /.*/}, as: :page
|
||||||
|
end
|
||||||
|
match "/*url" => "pages#not_found"
|
||||||
|
root :to => 'pages#home'
|
||||||
|
```
|
||||||
|
|
||||||
|
### User model
|
||||||
|
The user model is important. We recommend you to create your own user model:
|
||||||
|
```ruby
|
||||||
|
class User
|
||||||
|
include Cmtool::User
|
||||||
|
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
This is enough to start using Cmtool. But probably you want to add some
|
||||||
|
goodies of your own. Remember that this is a SimplyStored model with almost
|
||||||
|
all the ActiveModel features.
|
||||||
|
|
||||||
|
### Page model
|
||||||
|
The page model allows you to control some interesting things. To create it
|
||||||
|
(app/models/page.rb):
|
||||||
|
```ruby
|
||||||
|
class Page
|
||||||
|
include Cmtool::Page
|
||||||
|
|
||||||
|
# Define the locales you want to use in your website
|
||||||
|
def self.locales
|
||||||
|
[:en]
|
||||||
|
end
|
||||||
|
|
||||||
|
# Define the layouts you want to use in your website. Be sure to create them in
|
||||||
|
# app/views/layouts/...
|
||||||
|
# The first specified layout will become the default
|
||||||
|
def self.layouts
|
||||||
|
[:application, :home, :contact]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
### Controlling the language of the system
|
||||||
|
If you add a method `cmtool_locale` to your application controller Cmtool will
|
||||||
|
take this value:
|
||||||
|
```ruby
|
||||||
|
class ApplicationController
|
||||||
|
before_filter :set_locale
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_locale
|
||||||
|
# Do some magic
|
||||||
|
I18n.locale = :en
|
||||||
|
end
|
||||||
|
|
||||||
|
def cmtool_locale
|
||||||
|
I18n.locale
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
### Customize a page
|
||||||
|
All pages by default are rendered using the view: app/pages/show. So adding
|
||||||
|
and changing this file will change all displayed pages without their own
|
||||||
|
specific page. To create a specific page, create a page with the name of the
|
||||||
|
page you created in the Admin section. If for example you have created a page
|
||||||
|
with the name: about Then you can give this page a custom look using the view:
|
||||||
|
`app/views/about.html.haml` You can also use erb, slim or your choice of
|
||||||
|
templating engine
|
||||||
|
|
||||||
|
### Customize your 404
|
||||||
|
You can customize what is shown when a page cannot be found. There is a
|
||||||
|
standard view app/pages/404.html.erb with the following content:
|
||||||
|
|
||||||
|
<%= render template: 'pages/show' %>
|
||||||
|
|
||||||
|
Overwrite this to get another page as show. To controll the content of the 404
|
||||||
|
page, create a page in the Admin area having the name: 404. You can make a
|
||||||
|
404 page for every language in this manner. Here you can also give a custom
|
||||||
|
layout if you do not want to use the default layout.
|
||||||
-131
@@ -1,131 +0,0 @@
|
|||||||
= Cmtool
|
|
||||||
{<img src="https://secure.travis-ci.org/bterkuile/cmtool.png?branch=master" alt="Build Status" />}[http://travis-ci.org/bterkuile/cmtool]
|
|
||||||
== About
|
|
||||||
Cmtool is a CMS to give you a quickstart for a website using CouchDB as database
|
|
||||||
backend. It is in developing stage, but already used in production.
|
|
||||||
It is designed as an engine. The thought behind is that you will have to
|
|
||||||
create your own rails website, but get a lot of stuff for free. These things are:
|
|
||||||
|
|
||||||
* User management
|
|
||||||
* Page management
|
|
||||||
* Faq
|
|
||||||
* News
|
|
||||||
* Newsletter subscriptions
|
|
||||||
* Directory manager
|
|
||||||
* Image manager
|
|
||||||
|
|
||||||
== Setup
|
|
||||||
To start using Cmtool as website CMS add it to your Gemfile. Since it
|
|
||||||
depends on github gems and gem dependencies do not support those you
|
|
||||||
have to explicitly add two dependencies to your Gemfile:
|
|
||||||
gem 'couch_potato' , :git => 'git://github.com/bterkuile/couch_potato.git'
|
|
||||||
gem 'simply_stored' , :git => 'git://github.com/bterkuile/simply_stored.git'
|
|
||||||
gem 'cmtool'
|
|
||||||
This will add some gems you might like anyway, here a list:
|
|
||||||
|
|
||||||
* bourbon
|
|
||||||
* jquery-rails
|
|
||||||
* tinymce-rails
|
|
||||||
* sass-rails
|
|
||||||
* haml-rails
|
|
||||||
* paperclip
|
|
||||||
* email_validator (validates :email, email: true)
|
|
||||||
|
|
||||||
=== Controllers
|
|
||||||
|
|
||||||
in <tt>app/controllers/pages_controller.rb</tt>:
|
|
||||||
class PagesController
|
|
||||||
include Cmtool::Includes::PagesController
|
|
||||||
end
|
|
||||||
|
|
||||||
in <tt>app/models/page.rb</tt>:
|
|
||||||
class Page
|
|
||||||
include Cmtool::Includes::Page
|
|
||||||
|
|
||||||
def self.layouts
|
|
||||||
%w[home application contact]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
=== Securing
|
|
||||||
|
|
||||||
Cmtool is looking for an authorize_cmtool method present in the application controller. Something like:
|
|
||||||
class ApplicationController
|
|
||||||
...
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def authorize_cmtool
|
|
||||||
redirect_to main_app.root_path, alert: t('general.unauthorized') unless current_user.present? && current_user.is_admin?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
=== Routing
|
|
||||||
|
|
||||||
Add the following routes:
|
|
||||||
devise_for :users, :controllers => {:sessions => 'cmtool/sessions', :passwords => 'cmtool/passwords'}
|
|
||||||
mount Cmtool::Engine => '/cmtool'
|
|
||||||
scope '(/:locale)', constraints: {locale: /nl|be|de|fr|en/}, defaults: { locale: :nl } do
|
|
||||||
get "/:name" => "pages#show", constraints: {name: /.*/}, as: :page
|
|
||||||
end
|
|
||||||
match "/*url" => "pages#not_found"
|
|
||||||
root :to => 'pages#home'
|
|
||||||
|
|
||||||
=== User model
|
|
||||||
The user model is important. We recommend you to create your own user model:
|
|
||||||
class User
|
|
||||||
include Cmtool::User
|
|
||||||
|
|
||||||
end
|
|
||||||
This is enough to start using Cmtool. But probably you want to add some goodies of your own.
|
|
||||||
Remember that this is a SimplyStored model with almost all the ActiveModel features.
|
|
||||||
|
|
||||||
=== Page model
|
|
||||||
The page model allows you to control some interesting things. To create it (app/models/page.rb):
|
|
||||||
class Page
|
|
||||||
include Cmtool::Page
|
|
||||||
|
|
||||||
# Define the locales you want to use in your website
|
|
||||||
def self.locales
|
|
||||||
[:en]
|
|
||||||
end
|
|
||||||
|
|
||||||
# Define the layouts you want to use in your website. Be sure to create them in
|
|
||||||
# app/views/layouts/...
|
|
||||||
# The first specified layout will become the default
|
|
||||||
def self.layouts
|
|
||||||
[:application, :home, :contact]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
=== Controlling the language of the system
|
|
||||||
If you add a method <tt>cmtool_locale</tt> to your application controller
|
|
||||||
Cmtool will take this value:
|
|
||||||
class ApplicationController
|
|
||||||
before_filter :set_locale
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_locale
|
|
||||||
# Do some magic
|
|
||||||
I18n.locale = :en
|
|
||||||
end
|
|
||||||
|
|
||||||
def cmtool_locale
|
|
||||||
I18n.locale
|
|
||||||
end
|
|
||||||
end
|
|
||||||
=== Customize a page
|
|
||||||
All pages by default are rendered using the view: app/pages/show. So adding and changing this file will
|
|
||||||
change all displayed pages without their own specific page. To create a specific page, create a page
|
|
||||||
with the name of the page you created in the Admin section. If for example you have created a page
|
|
||||||
with the name: about
|
|
||||||
Then you can give this page a custom look using the view:
|
|
||||||
<tt>app/views/about.html.haml</tt>
|
|
||||||
You can also use erb, slim or your choice of templating engine
|
|
||||||
|
|
||||||
=== Customize your 404
|
|
||||||
You can customize what is shown when a page cannot be found. There is a standard view app/pages/404.html.erb with the following content:
|
|
||||||
<%= render template: 'pages/show' %>
|
|
||||||
Overwrite this to get another page as show. To controll the content of the 404 page, create a page in the Admin area having the name: 404.
|
|
||||||
You can make a 404 page for every language in this manner. Here you can also give a custom layout if you do not want to use the default layout.
|
|
||||||
@@ -10,6 +10,7 @@ Cmtool::Engine.routes.draw do
|
|||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
get :generate_name
|
get :generate_name
|
||||||
|
get :sitemap
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :news do
|
resources :news do
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
module Cmtool
|
module Cmtool
|
||||||
module Includes
|
module Includes
|
||||||
module PagesController
|
module PagesController
|
||||||
|
extend ActiveSupport::Concern
|
||||||
def home
|
def home
|
||||||
page_name = "home"
|
page_name = "home"
|
||||||
@page = ::Page.find_by_name_and_locale(page_name, I18n.locale.to_s) || ::Page.new(:name => page_name, locale: I18n.locale.to_s)
|
@page = ::Page.find_by_name_and_locale(page_name, I18n.locale.to_s) || ::Page.new(:name => page_name, locale: I18n.locale.to_s)
|
||||||
@@ -28,6 +29,22 @@ module Cmtool
|
|||||||
@sub_pages = []
|
@sub_pages = []
|
||||||
render template: 'pages/404', layout: @page.layout.presence || ::Page.layouts.first.to_s, status: 404
|
render template: 'pages/404', layout: @page.layout.presence || ::Page.layouts.first.to_s, status: 404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sitemap
|
||||||
|
respond_to do |format|
|
||||||
|
format.xml do
|
||||||
|
page_uris = ::Page.all.map{|p| page_path(p.name, locale: p.locale)}
|
||||||
|
pages_xml = page_uris.map{|uri| "<url><loc>#{uri}</loc></url>"}.join("\n")
|
||||||
|
result = <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
#{pages_xml}
|
||||||
|
</urlset>
|
||||||
|
XML
|
||||||
|
render xml: result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe Cmtool::PagesController, type: :controller do
|
describe Cmtool::PagesController, type: :controller do
|
||||||
routes { Cmtool::Engine.routes }
|
routes { Cmtool::Engine.routes }
|
||||||
|
|
||||||
describe 'GET index' do
|
describe 'GET index' do
|
||||||
it "should render standard view when tree is available" do
|
it "should render standard view when tree is available" do
|
||||||
create_pages_tree
|
create_pages_tree
|
||||||
expect{ get :index }.not_to raise_error
|
expect{ get :index }.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ Rails.application.routes.draw do
|
|||||||
|
|
||||||
devise_for :users, :controllers => {:sessions => 'cmtool/sessions', :passwords => 'cmtool/passwords'}
|
devise_for :users, :controllers => {:sessions => 'cmtool/sessions', :passwords => 'cmtool/passwords'}
|
||||||
mount Cmtool::Engine => "/cmtool"
|
mount Cmtool::Engine => "/cmtool"
|
||||||
|
get '/sitemap(.:format)' => 'test_pages#sitemap'
|
||||||
get "/:name" => "pages#show"
|
get "/:name" => "pages#show"
|
||||||
|
scope '(/:locale)', constraints: {locale: /nl|be|de|fr|en/}, defaults: { locale: :nl } do
|
||||||
|
get "/:name" => "pages#show", constraints: {name: /.*/}, as: :page
|
||||||
|
end
|
||||||
get "/*url" => "pages#not_found"
|
get "/*url" => "pages#not_found"
|
||||||
root :to => 'pages#home'
|
root :to => 'pages#home'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
class TestPagesController < ApplicationController
|
||||||
|
include Cmtool::Includes::PagesController
|
||||||
|
end
|
||||||
|
|
||||||
|
describe TestPagesController, type: :controller do
|
||||||
|
describe 'sitemap' do
|
||||||
|
it 'returns a proper sitemap' do
|
||||||
|
create_pages_tree
|
||||||
|
get :sitemap, format: 'xml'
|
||||||
|
expect( response.body ).to include "<url><loc>/en/child2.2</loc></url>"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user