content_engine 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/content_engine.gemspec +3 -118
- metadata +6 -117
- data/Gemfile +0 -40
- data/README.md +0 -43
- data/app/controllers/content_engine/articles_controller.rb +0 -54
- data/app/controllers/content_engine/pages_controller.rb +0 -76
- data/app/controllers/content_engine_controller.rb +0 -14
- data/app/helpers/application_helper.rb +0 -2
- data/app/models/article.rb +0 -29
- data/app/models/content.rb +0 -64
- data/app/models/page.rb +0 -40
- data/app/models/site.rb +0 -26
- data/app/models/tag.rb +0 -53
- data/app/models/user.rb +0 -5
- data/app/views/content_engine/articles/_form.erb +0 -8
- data/app/views/content_engine/articles/edit.html.erb +0 -7
- data/app/views/content_engine/articles/index.html.erb +0 -10
- data/app/views/content_engine/articles/new.html.erb +0 -6
- data/app/views/content_engine/articles/show.html.erb +0 -9
- data/app/views/content_engine/pages/_form.erb +0 -8
- data/app/views/content_engine/pages/edit.html.erb +0 -7
- data/app/views/content_engine/pages/index.html.erb +0 -10
- data/app/views/content_engine/pages/new.html.erb +0 -6
- data/app/views/content_engine/pages/show.html.erb +0 -9
- data/app/views/layouts/application.html.erb +0 -16
- data/config/application.rb +0 -1
- data/config/locales/en.yml +0 -5
- data/config/routes.rb +0 -25
- data/db/migrate/20100225105011_create_contents.rb +0 -22
- data/db/migrate/20100225105903_create_users.rb +0 -8
- data/db/migrate/20100225110024_create_sites.rb +0 -15
- data/db/migrate/20100225110037_create_memberships.rb +0 -12
- data/db/migrate/20100225112236_acts_as_taggable_on.rb +0 -26
- data/db/schema.rb +0 -58
- data/lib/content_engine.rb +0 -24
- data/lib/tasks/content_engine.rake +0 -24
- data/spec/blueprint.rb +0 -41
- data/spec/models/article_spec.rb +0 -56
- data/spec/models/page_spec.rb +0 -158
- data/spec/models/site_spec.rb +0 -32
- data/spec/rails_app/.gitignore +0 -4
- data/spec/rails_app/Rakefile +0 -10
- data/spec/rails_app/app/controllers/admins_controller.rb +0 -6
- data/spec/rails_app/app/controllers/application_controller.rb +0 -6
- data/spec/rails_app/app/controllers/home_controller.rb +0 -4
- data/spec/rails_app/app/controllers/sessions_controller.rb +0 -6
- data/spec/rails_app/app/controllers/users_controller.rb +0 -12
- data/spec/rails_app/app/helpers/application_helper.rb +0 -3
- data/spec/rails_app/app/views/home/index.html.erb +0 -1
- data/spec/rails_app/app/views/layouts/application.html.erb +0 -19
- data/spec/rails_app/config.ru +0 -4
- data/spec/rails_app/config/application.rb +0 -30
- data/spec/rails_app/config/boot.rb +0 -9
- data/spec/rails_app/config/database.yml +0 -16
- data/spec/rails_app/config/environment.rb +0 -5
- data/spec/rails_app/config/environments/development.rb +0 -19
- data/spec/rails_app/config/environments/production.rb +0 -33
- data/spec/rails_app/config/environments/test.rb +0 -29
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails_app/config/initializers/cookie_verification_secret.rb +0 -7
- data/spec/rails_app/config/initializers/inflections.rb +0 -2
- data/spec/rails_app/config/initializers/session_store.rb +0 -15
- data/spec/rails_app/config/routes.rb +0 -21
- data/spec/rails_app/db/migrate/20100225105011_create_contents.rb +0 -22
- data/spec/rails_app/db/migrate/20100225105903_create_users.rb +0 -8
- data/spec/rails_app/db/migrate/20100225110024_create_sites.rb +0 -15
- data/spec/rails_app/db/migrate/20100225110037_create_memberships.rb +0 -12
- data/spec/rails_app/db/migrate/20100225112236_acts_as_taggable_on.rb +0 -26
- data/spec/rails_app/db/schema.rb +0 -59
- data/spec/rails_app/public/404.html +0 -26
- data/spec/rails_app/public/422.html +0 -26
- data/spec/rails_app/public/500.html +0 -26
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/rails_app/public/images/rails.png +0 -0
- data/spec/rails_app/public/javascripts/application.js +0 -2
- data/spec/rails_app/public/javascripts/controls.js +0 -963
- data/spec/rails_app/public/javascripts/dragdrop.js +0 -973
- data/spec/rails_app/public/javascripts/effects.js +0 -1128
- data/spec/rails_app/public/javascripts/prototype.js +0 -4320
- data/spec/rails_app/public/javascripts/rails.js +0 -110
- data/spec/rails_app/public/robots.txt +0 -5
- data/spec/rails_app/public/stylesheets/.gitkeep +0 -0
- data/spec/rails_app/script/rails +0 -10
- data/spec/requests/user_manage_articles_spec.rb +0 -85
- data/spec/requests/user_manage_pages_spec.rb +0 -92
- data/spec/requests/webrat.log +0 -17
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -36
@@ -1,76 +0,0 @@
|
|
1
|
-
module ContentEngine
|
2
|
-
class PagesController < ContentEngineController
|
3
|
-
respond_to :html, :xml
|
4
|
-
|
5
|
-
# GET /pages
|
6
|
-
# GET /pages.xml
|
7
|
-
def index
|
8
|
-
@pages = @site.pages.order('created_at desc').all.paginate(:page => params[:page])
|
9
|
-
@rootpage = @site.pages.root
|
10
|
-
|
11
|
-
if request.xhr? and params[:parent_id]
|
12
|
-
@rootpage = @site.pages.find(params[:parent_id])
|
13
|
-
return render(:partial => 'treeview')
|
14
|
-
end
|
15
|
-
|
16
|
-
respond_with @pages
|
17
|
-
end
|
18
|
-
|
19
|
-
# GET /pages/1
|
20
|
-
# GET /pages/1.xml
|
21
|
-
def show
|
22
|
-
respond_with @page = @site.pages.find(params[:id])
|
23
|
-
end
|
24
|
-
|
25
|
-
def lookup
|
26
|
-
@page = @site.pages.find_by_url(params[:url])
|
27
|
-
|
28
|
-
render :template => 'content_engine/pages/show'
|
29
|
-
end
|
30
|
-
|
31
|
-
# GET /pages/new
|
32
|
-
# GET /pages/new.xml
|
33
|
-
def new
|
34
|
-
respond_with @page = @site.pages.new
|
35
|
-
end
|
36
|
-
|
37
|
-
# GET /pages/1/edit
|
38
|
-
def edit
|
39
|
-
respond_with @page = @site.pages.find(params[:id])
|
40
|
-
end
|
41
|
-
|
42
|
-
# POST /pages
|
43
|
-
# POST /pages.xml
|
44
|
-
def create
|
45
|
-
@page = @site.pages.new(params[:page])
|
46
|
-
flash[:notice] = "Page was successfully created." if @page.save
|
47
|
-
respond_with @page
|
48
|
-
end
|
49
|
-
|
50
|
-
# PUT /pages/1
|
51
|
-
# PUT /pages/1.xml
|
52
|
-
def update
|
53
|
-
@page = @site.pages.find(params[:id])
|
54
|
-
flash[:notice] = "Page was successfully updated." if @page.update_attributes(params[:page])
|
55
|
-
respond_with @page
|
56
|
-
end
|
57
|
-
|
58
|
-
# DELETE /pages/1
|
59
|
-
# DELETE /pages/1.xml
|
60
|
-
def destroy
|
61
|
-
@page = @site.pages.find(params[:id])
|
62
|
-
@page.destroy
|
63
|
-
|
64
|
-
respond_with @page
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
# # GET /pages/1/move?to=(up|down)
|
69
|
-
# def move
|
70
|
-
# @page = @site.pages.find(params[:id])
|
71
|
-
# @page.move_left
|
72
|
-
#
|
73
|
-
# redirect_to pages_path
|
74
|
-
# end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class ContentEngineController < ApplicationController
|
2
|
-
protect_from_forgery
|
3
|
-
before_filter :load_site
|
4
|
-
|
5
|
-
protected
|
6
|
-
def load_site
|
7
|
-
# Single site mode
|
8
|
-
if Site.count == 1
|
9
|
-
@site = Site.first
|
10
|
-
else
|
11
|
-
@site = Site.find_by_host(request.host)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/app/models/article.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
class Article < Content
|
2
|
-
has_permalink :title
|
3
|
-
acts_as_taggable_on :tags
|
4
|
-
|
5
|
-
validates_presence_of :title
|
6
|
-
validates_presence_of :body
|
7
|
-
|
8
|
-
def excerpt
|
9
|
-
content = body[0, 300]
|
10
|
-
words = content.gsub(/<\/?[^>]+>/, "").split(' ')
|
11
|
-
words[0 .. 59].join(' ') + '...'
|
12
|
-
end
|
13
|
-
|
14
|
-
def url
|
15
|
-
"/articles/%04d/%02d/%02d/#{permalink}" % [created_at.year, created_at.month, created_at.day]
|
16
|
-
end
|
17
|
-
|
18
|
-
def next
|
19
|
-
site.articles.published.order('id').where("id > ?", id).first
|
20
|
-
end
|
21
|
-
|
22
|
-
def prev
|
23
|
-
site.articles.published.order('id').where("id < ?", id).first
|
24
|
-
end
|
25
|
-
|
26
|
-
def to_param
|
27
|
-
"#{id}-#{permalink}"
|
28
|
-
end
|
29
|
-
end
|
data/app/models/content.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
class Content < ActiveRecord::Base
|
2
|
-
abstract_class = true
|
3
|
-
|
4
|
-
belongs_to :site
|
5
|
-
belongs_to :author, :class_name => 'User'
|
6
|
-
|
7
|
-
scope :recent, order("published_at DESC")
|
8
|
-
scope :published, lambda{
|
9
|
-
where("published_at is NOT null").where("published_at <= ?", Time.now).recent
|
10
|
-
}
|
11
|
-
scope :draft, where(:published_at => nil).recent
|
12
|
-
|
13
|
-
before_save :update_published_at
|
14
|
-
|
15
|
-
def body
|
16
|
-
self[:body]
|
17
|
-
end
|
18
|
-
|
19
|
-
def body_html
|
20
|
-
if self.body_source
|
21
|
-
markdown = RDiscount.new(self.body_source)
|
22
|
-
@body_html ||= markdown.to_html
|
23
|
-
end
|
24
|
-
end
|
25
|
-
alias_method :body_source, :body
|
26
|
-
alias_method :body, :body_html
|
27
|
-
|
28
|
-
|
29
|
-
def author_name
|
30
|
-
author.display_name if author
|
31
|
-
end
|
32
|
-
|
33
|
-
def status
|
34
|
-
published? ? 'published' : 'draft'
|
35
|
-
end
|
36
|
-
|
37
|
-
def status=(status)
|
38
|
-
if status == 'draft'
|
39
|
-
self[:published_at] = nil
|
40
|
-
else
|
41
|
-
self[:published_at] = Time.now unless published?
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def published=(flag)
|
46
|
-
@mark_published = flag
|
47
|
-
end
|
48
|
-
|
49
|
-
def published?
|
50
|
-
published_at != nil
|
51
|
-
end
|
52
|
-
|
53
|
-
def publish!
|
54
|
-
self.published = true
|
55
|
-
self.send(:update_published_at)
|
56
|
-
save
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
def update_published_at
|
61
|
-
self[:published_at] = Time.now if @mark_published and not published?
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
data/app/models/page.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
class Page < Content
|
2
|
-
belongs_to :parent, :class_name => 'Page'
|
3
|
-
has_many :children, :class_name => 'Page', :foreign_key => 'parent_id'
|
4
|
-
|
5
|
-
acts_as_taggable_on :tags
|
6
|
-
|
7
|
-
before_validation :ensure_hierarchy
|
8
|
-
has_permalink :title, :scope => :parent_id, :unless => :homepage?
|
9
|
-
|
10
|
-
validates_presence_of :title, :body
|
11
|
-
|
12
|
-
# Tree structure
|
13
|
-
scope :roots, where(:parent_id => nil)
|
14
|
-
|
15
|
-
def self.root
|
16
|
-
roots.first
|
17
|
-
end
|
18
|
-
|
19
|
-
def root?
|
20
|
-
self == Page.root || Page.count == 0 && new_record?
|
21
|
-
end
|
22
|
-
alias :homepage? :root?
|
23
|
-
|
24
|
-
def ancestors
|
25
|
-
node, nodes = self, []
|
26
|
-
nodes << node = node.parent while node.parent
|
27
|
-
nodes
|
28
|
-
end
|
29
|
-
|
30
|
-
def url
|
31
|
-
links = (ancestors.map(&:permalink) << permalink).delete_if(&:blank?)
|
32
|
-
|
33
|
-
"/#{links.join('/')}"
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
def ensure_hierarchy
|
38
|
-
self.parent = site.homepage if !parent_id && site && site.homepage
|
39
|
-
end
|
40
|
-
end
|
data/app/models/site.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
class Site < ActiveRecord::Base
|
2
|
-
belongs_to :owner, :class_name => 'User'
|
3
|
-
|
4
|
-
has_many :memberships, :dependent => :destroy
|
5
|
-
has_many :users, :through => :memberships
|
6
|
-
|
7
|
-
# has_many :tags, :dependent => :destroy
|
8
|
-
has_many :articles, :dependent => :destroy
|
9
|
-
has_many :pages, :dependent => :destroy do
|
10
|
-
def find_by_url(url = [])
|
11
|
-
url = url.split('/').delete_if(&:blank?) if url.is_a? String
|
12
|
-
|
13
|
-
page = where(:parent_id => nil).first
|
14
|
-
|
15
|
-
url.each do |part|
|
16
|
-
page = page.children.published.where(:permalink => part).first
|
17
|
-
end
|
18
|
-
|
19
|
-
page
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def homepage
|
24
|
-
pages.root
|
25
|
-
end
|
26
|
-
end
|
data/app/models/tag.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
class Tag < ActiveRecord::Base
|
2
|
-
|
3
|
-
attr_accessible :name
|
4
|
-
|
5
|
-
### ASSOCIATIONS:
|
6
|
-
|
7
|
-
has_many :taggings, :dependent => :destroy
|
8
|
-
|
9
|
-
### VALIDATIONS:
|
10
|
-
|
11
|
-
validates_presence_of :name
|
12
|
-
validates_uniqueness_of :name
|
13
|
-
|
14
|
-
### NAMED SCOPES:
|
15
|
-
|
16
|
-
scope :named, lambda { |name| { :conditions => ["name LIKE ?", name] } }
|
17
|
-
scope :named_any, lambda { |list| { :conditions => list.map { |tag| sanitize_sql(["name LIKE ?", tag.to_s]) }.join(" OR ") } }
|
18
|
-
scope :named_like, lambda { |name| { :conditions => ["name LIKE ?", "%#{name}%"] } }
|
19
|
-
scope :named_like_any, lambda { |list| { :conditions => list.map { |tag| sanitize_sql(["name LIKE ?", "%#{tag.to_s}%"]) }.join(" OR ") } }
|
20
|
-
|
21
|
-
### CLASS METHODS:
|
22
|
-
|
23
|
-
def self.find_or_create_with_like_by_name(name)
|
24
|
-
named_like(name).first || create(:name => name)
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.find_or_create_all_with_like_by_name(*list)
|
28
|
-
list = [list].flatten
|
29
|
-
|
30
|
-
return [] if list.empty?
|
31
|
-
|
32
|
-
existing_tags = Tag.named_any(list).all
|
33
|
-
new_tag_names = list.reject { |name| existing_tags.any? { |tag| tag.name.downcase == name.downcase } }
|
34
|
-
created_tags = new_tag_names.map { |name| Tag.create(:name => name) }
|
35
|
-
|
36
|
-
existing_tags + created_tags
|
37
|
-
end
|
38
|
-
|
39
|
-
### INSTANCE METHODS:
|
40
|
-
|
41
|
-
def ==(object)
|
42
|
-
super || (object.is_a?(Tag) && name == object.name)
|
43
|
-
end
|
44
|
-
|
45
|
-
def to_s
|
46
|
-
name
|
47
|
-
end
|
48
|
-
|
49
|
-
def count
|
50
|
-
read_attribute(:count).to_i
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
data/app/models/user.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<title><%= @site.title %> - Content Engine</title>
|
6
|
-
</head>
|
7
|
-
<body>
|
8
|
-
<div id="container">
|
9
|
-
<%- flash.each do |name, msg| -%>
|
10
|
-
<%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
|
11
|
-
<%- end -%>
|
12
|
-
|
13
|
-
<%= yield %>
|
14
|
-
</div>
|
15
|
-
</body>
|
16
|
-
</html>
|
data/config/application.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require File.expand_path("../../content_engine", __FILE__)
|