adva-blog 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bundler/repository.rb +118 -0
- metadata +5 -33
- data/app/controllers/admin/blogs_controller.rb +0 -11
- data/app/controllers/admin/posts_controller.rb +0 -4
- data/app/controllers/posts_controller.rb +0 -20
- data/app/models/blog.rb +0 -6
- data/app/models/post.rb +0 -28
- data/app/models/site_slice.rb +0 -3
- data/app/views/admin/blogs/_form.html.rb +0 -17
- data/app/views/admin/blogs/_menu.html.rb +0 -25
- data/app/views/admin/blogs/edit.html.rb +0 -8
- data/app/views/admin/blogs/new.html.rb +0 -9
- data/app/views/admin/blogs/show.html.rb +0 -41
- data/app/views/admin/categories/_menu_slice.html.rb +0 -22
- data/app/views/admin/posts/_form.html.rb +0 -25
- data/app/views/admin/posts/_menu.html.rb +0 -10
- data/app/views/admin/posts/edit.html.rb +0 -8
- data/app/views/admin/posts/index.html.rb +0 -42
- data/app/views/admin/posts/new.html.rb +0 -8
- data/app/views/posts/_meta.html.rb +0 -17
- data/app/views/posts/index.html.rb +0 -22
- data/app/views/posts/show.html.rb +0 -11
- data/config/locales/en.yml +0 -38
- data/config/redirects.rb +0 -8
- data/config/routes.rb +0 -18
- data/lib/adva/blog.rb +0 -23
- data/lib/adva-blog.rb +0 -1
- data/lib/adva_blog/version.rb +0 -3
- data/lib/testing/factories.rb +0 -9
- data/lib/testing/paths.rb +0 -19
- data/public/stylesheets/default/blog.css +0 -0
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
# Bundler gemfile support for local/remote workspaces/repositories for work in
|
4
|
+
# development teams.
|
5
|
+
#
|
6
|
+
# Usage:
|
7
|
+
#
|
8
|
+
# # define paths to be searched for repositories:
|
9
|
+
# workspace '~/.projects ~/Development/{projects,work}'
|
10
|
+
#
|
11
|
+
# # define developer preferences for using local or remote repositories (uses ENV['user']):
|
12
|
+
# developer :sven, :prefer => :local
|
13
|
+
#
|
14
|
+
# # define repositories to be used for particular gems:
|
15
|
+
# adva_cms = repository('adva-cms2', :git => 'git@github.com:svenfuchs/adva-cms2.git', :ref => 'c2af0de')
|
16
|
+
# adva_shop = repository('adva-shop', :source => :local)
|
17
|
+
#
|
18
|
+
# # now use repositories to define gems:
|
19
|
+
# adva_cms.gem 'adva-core'
|
20
|
+
# adva_shop.gem 'adva-catalog'
|
21
|
+
#
|
22
|
+
# # The gem definition will now be proxied to Bundler with arguments according
|
23
|
+
# # to the setup defined earlier. E.g. as:
|
24
|
+
#
|
25
|
+
# gem 'adva-core', :path => 'Development/projects/adva-cms2/adva-core' # for developer 'sven'
|
26
|
+
# gem 'adva-core', :git => 'git@github.com:svenfuchs/adva-cms2.git', :ref => 'c2af0de' # for other developers
|
27
|
+
# gem 'adva-catalog', :path => 'Development/projects/adva-shop/adva-catalog' # for all developers
|
28
|
+
#
|
29
|
+
# One can also set an environment variable FORCE_REMOTE which will force remote
|
30
|
+
# repositories to be used *except* when a repository was defined with :source => :local
|
31
|
+
# which always forces the local repository to be used.
|
32
|
+
#
|
33
|
+
class Repository
|
34
|
+
class << self
|
35
|
+
def paths
|
36
|
+
@paths ||= []
|
37
|
+
end
|
38
|
+
|
39
|
+
def path(*paths)
|
40
|
+
paths.join(' ').split(' ').each do |path|
|
41
|
+
self.paths.concat(Pathname.glob(File.expand_path(path)))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def developer(name, preferences)
|
46
|
+
developers[name] = preferences
|
47
|
+
workspaces(preferences[:workspace])
|
48
|
+
end
|
49
|
+
|
50
|
+
def current_developer
|
51
|
+
developers[ENV['USER'].to_sym] || {}
|
52
|
+
end
|
53
|
+
|
54
|
+
def developers(developers = nil)
|
55
|
+
@developers ||= {}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class Gem < Array
|
60
|
+
def initialize(name, repository)
|
61
|
+
if repository.local?
|
62
|
+
sub_path = repository.path.join(name)
|
63
|
+
super([name, { :path => sub_path.exist? ? sub_path.to_s : repository.path.to_s }])
|
64
|
+
else
|
65
|
+
super([name, repository.options.dup])
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
attr_reader :bundler, :name, :options, :source
|
71
|
+
|
72
|
+
def initialize(bundler, name, options)
|
73
|
+
@bundler = bundler
|
74
|
+
@name = name
|
75
|
+
@source = options.delete(:source)
|
76
|
+
@options = options
|
77
|
+
end
|
78
|
+
|
79
|
+
def gem(name)
|
80
|
+
bundler.gem(*Gem.new(name, self))
|
81
|
+
end
|
82
|
+
|
83
|
+
def local?
|
84
|
+
source == :local # && path
|
85
|
+
end
|
86
|
+
|
87
|
+
def source
|
88
|
+
@source ||= forced_source || preferred_source || :remote
|
89
|
+
end
|
90
|
+
|
91
|
+
def forced_source
|
92
|
+
:remote if ENV['FORCE_REMOTE']
|
93
|
+
end
|
94
|
+
|
95
|
+
def preferred_source
|
96
|
+
self.class.current_developer[:prefer] || self.class.current_developer[name.to_sym]
|
97
|
+
end
|
98
|
+
|
99
|
+
def path
|
100
|
+
@path ||= begin
|
101
|
+
path = self.class.paths.detect { |path| path.join(name).exist? }
|
102
|
+
path ? path.join(name) : Pathname.new('.')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def workspace(*paths)
|
108
|
+
Repository.path(*paths)
|
109
|
+
end
|
110
|
+
alias :workspaces :workspace
|
111
|
+
|
112
|
+
def developer(name, preferences)
|
113
|
+
Repository.developer(name, preferences)
|
114
|
+
end
|
115
|
+
|
116
|
+
def repository(*args)
|
117
|
+
Repository.new(self, *args)
|
118
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adva-blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ingo Weiss
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-11-
|
19
|
+
date: 2010-11-19 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -56,35 +56,7 @@ extensions: []
|
|
56
56
|
extra_rdoc_files: []
|
57
57
|
|
58
58
|
files:
|
59
|
-
-
|
60
|
-
- app/controllers/admin/blogs_controller.rb
|
61
|
-
- app/controllers/admin/posts_controller.rb
|
62
|
-
- app/views/admin/categories/_menu_slice.html.rb
|
63
|
-
- app/views/admin/blogs/show.html.rb
|
64
|
-
- app/views/admin/blogs/edit.html.rb
|
65
|
-
- app/views/admin/blogs/new.html.rb
|
66
|
-
- app/views/admin/blogs/_form.html.rb
|
67
|
-
- app/views/admin/blogs/_menu.html.rb
|
68
|
-
- app/views/admin/posts/index.html.rb
|
69
|
-
- app/views/admin/posts/edit.html.rb
|
70
|
-
- app/views/admin/posts/new.html.rb
|
71
|
-
- app/views/admin/posts/_form.html.rb
|
72
|
-
- app/views/admin/posts/_menu.html.rb
|
73
|
-
- app/views/posts/index.html.rb
|
74
|
-
- app/views/posts/show.html.rb
|
75
|
-
- app/views/posts/_meta.html.rb
|
76
|
-
- app/models/post.rb
|
77
|
-
- app/models/site_slice.rb
|
78
|
-
- app/models/blog.rb
|
79
|
-
- config/redirects.rb
|
80
|
-
- config/routes.rb
|
81
|
-
- config/locales/en.yml
|
82
|
-
- lib/adva_blog/version.rb
|
83
|
-
- lib/adva/blog.rb
|
84
|
-
- lib/testing/factories.rb
|
85
|
-
- lib/testing/paths.rb
|
86
|
-
- lib/adva-blog.rb
|
87
|
-
- public/stylesheets/default/blog.css
|
59
|
+
- lib/bundler/repository.rb
|
88
60
|
has_rdoc: true
|
89
61
|
homepage: http://github.com/svenfuchs/adva-cms2
|
90
62
|
licenses: []
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class Admin::BlogsController < Admin::SectionsController
|
2
|
-
purges :create, :update, :destroy
|
3
|
-
|
4
|
-
def show
|
5
|
-
# TODO need to do an internal redirect here because the admin top section drop down menu
|
6
|
-
# links to section#show. Might want to invent a concept of default_action for a section
|
7
|
-
# type. Also might want to invent a :preserve_flash => true concept or something like that
|
8
|
-
# when redirecting through http (which otherwise looses the flash after, e.g. blog#create)
|
9
|
-
internal_redirect_to 'admin/posts#index', params.merge(:blog_id => params.delete(:id))
|
10
|
-
end
|
11
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
class PostsController < BaseController
|
2
|
-
nested_belongs_to :blog
|
3
|
-
before_filter :set_id, :only => :show
|
4
|
-
|
5
|
-
filtered_attributes :post if Adva.engine?(:markup) # FIXME move to adva-markup?
|
6
|
-
|
7
|
-
protected
|
8
|
-
|
9
|
-
def collection
|
10
|
-
# FIXME only here for reference tracking. how can we remove this?
|
11
|
-
@_references << [blog, :posts] if @_references
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
|
-
def set_id
|
16
|
-
blog = site.blogs.find(params[:blog_id])
|
17
|
-
permalink = params.values_at(:year, :month, :day, :slug)
|
18
|
-
params[:id] = blog.posts.by_permalink(*permalink).first.try(:id)
|
19
|
-
end
|
20
|
-
end
|
data/app/models/blog.rb
DELETED
data/app/models/post.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
class Post < Content
|
2
|
-
has_slug :scope => :section_id
|
3
|
-
|
4
|
-
validates_presence_of :title
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def by_permalink(year, month, day, slug)
|
8
|
-
by_archive(year, month, day).where(:slug => slug)
|
9
|
-
end
|
10
|
-
|
11
|
-
def by_archive(*args)
|
12
|
-
where("DATE(contents.created_at) = ?", Date.new(*args.map(&:to_i)).to_formatted_s(:db))
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# FIXME should be in adva-markup, shouldn't it?
|
17
|
-
def filter
|
18
|
-
read_attribute(:filter) || (section.respond_to?(:default_filter) ? section.default_filter : nil)
|
19
|
-
end
|
20
|
-
|
21
|
-
def permalink
|
22
|
-
"#{created_at.year}/#{created_at.month}/#{created_at.day}/#{slug}"
|
23
|
-
end
|
24
|
-
|
25
|
-
def to_param(name)
|
26
|
-
name == :permalink ? permalink : super()
|
27
|
-
end
|
28
|
-
end
|
data/app/models/site_slice.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
class Admin::Blogs::Form < Adva::View::Form
|
2
|
-
include do
|
3
|
-
def fields
|
4
|
-
form.hidden_field :type
|
5
|
-
|
6
|
-
fieldset do
|
7
|
-
column do
|
8
|
-
form.input :name
|
9
|
-
end
|
10
|
-
|
11
|
-
column do
|
12
|
-
form.input :slug
|
13
|
-
end unless params[:action] == 'new'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require_dependency 'admin/sections/_menu.html'
|
2
|
-
|
3
|
-
class Admin::Blogs::Menu < Admin::Sections::Menu
|
4
|
-
include do
|
5
|
-
def main
|
6
|
-
super
|
7
|
-
categories if persisted? && Adva.engine?(:categories)
|
8
|
-
end
|
9
|
-
|
10
|
-
def right
|
11
|
-
new_item if persisted?
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
|
-
protected
|
16
|
-
|
17
|
-
def show
|
18
|
-
item(:'.posts', index_path(:posts))
|
19
|
-
end
|
20
|
-
|
21
|
-
def new_item
|
22
|
-
item(:'.new_post', new_path(:post))
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
class Admin::Blogs::Show < Minimal::Template
|
2
|
-
include do
|
3
|
-
def to_html
|
4
|
-
table_for resource.posts do |t|
|
5
|
-
t.column :post, :comments, :published, :author, :actions
|
6
|
-
|
7
|
-
t.row do |r, post|
|
8
|
-
r.cell link_to_post(post)
|
9
|
-
r.cell ''.html_safe # post.accept_comments? && post.comments.present? ? link_to(post.comments.size, admin_comments_path) : t(:"adva.common.none")
|
10
|
-
r.cell ''.html_safe # published_at_formatted(post)
|
11
|
-
r.cell link_to_author(post)
|
12
|
-
r.cell links_to_actions([:view, :edit, :destroy], post)
|
13
|
-
end
|
14
|
-
|
15
|
-
t.foot.row do |r|
|
16
|
-
# r.cell will_paginate(@posts), :class => :pagination, :colspan => :all
|
17
|
-
end
|
18
|
-
|
19
|
-
t.empty :p, :class => 'posts list empty' do
|
20
|
-
self.t(:'.empty', :link => capture { link_to(:'.create_item', new_path(:post)) }).html_safe
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def link_to_post(post)
|
26
|
-
status(post) + capture { link_to_edit(post.title, post) } # , :class => post.state
|
27
|
-
end
|
28
|
-
|
29
|
-
def link_to_author(post)
|
30
|
-
''.html_safe # link_to(post.author_name, admin_site_user_path(@site, post.author))
|
31
|
-
end
|
32
|
-
|
33
|
-
def link_to_view(post)
|
34
|
-
capture { link_to(options[:text] || :'.view', public_url_for([post.section, post]), :class => :view) }
|
35
|
-
end
|
36
|
-
|
37
|
-
def status(post)
|
38
|
-
capture { span(t(:'.published'), :title => t(:'.published'), :class => 'status published') }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require_dependency 'admin/categories/_menu.html'
|
2
|
-
|
3
|
-
Admin::Categories::Menu.class_eval do
|
4
|
-
include do
|
5
|
-
def main
|
6
|
-
super
|
7
|
-
posts if blog?
|
8
|
-
end
|
9
|
-
|
10
|
-
protected
|
11
|
-
|
12
|
-
def posts
|
13
|
-
item(:'.posts', index_parent_path(:posts), :before => :'.categories')
|
14
|
-
end
|
15
|
-
|
16
|
-
def blog?
|
17
|
-
resource.section.is_a?(Blog)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
|
@@ -1,25 +0,0 @@
|
|
1
|
-
class Admin::Posts::Form < Adva::View::Form
|
2
|
-
include do
|
3
|
-
def fields
|
4
|
-
fieldset do
|
5
|
-
form.input :title
|
6
|
-
form.input :body
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def sidebar
|
11
|
-
if Adva.engine?(:categories) && blog.categories.present?
|
12
|
-
# TODO extract to Adva::View::Form#categorizable_tab or something
|
13
|
-
tab :categories do
|
14
|
-
fieldset do
|
15
|
-
form.has_many_through_collection_check_boxes(:categorizations, blog.categories, :name)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
tab :options do
|
21
|
-
form.input :slug
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
class Admin::Posts::Index < Minimal::Template
|
2
|
-
include do
|
3
|
-
def to_html
|
4
|
-
table_for collection do |t|
|
5
|
-
t.column :post, :comments, :published, :author, :actions
|
6
|
-
|
7
|
-
t.row do |r, post|
|
8
|
-
r.cell link_to_post(post)
|
9
|
-
r.cell ''.html_safe # post.accept_comments? && post.comments.present? ? link_to(post.comments.size, admin_comments_path) : t(:"adva.common.none")
|
10
|
-
r.cell ''.html_safe # published_at_formatted(post)
|
11
|
-
r.cell link_to_author(post)
|
12
|
-
r.cell links_to_actions([:view, :edit, :destroy], post)
|
13
|
-
end
|
14
|
-
|
15
|
-
t.foot.row do |r|
|
16
|
-
# r.cell will_paginate(@posts), :class => :pagination, :colspan => :all
|
17
|
-
end
|
18
|
-
|
19
|
-
t.empty :p, :class => 'posts list empty' do
|
20
|
-
self.t(:'.empty', :link => capture { link_to(:'.create_item', new_path) }).html_safe
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def link_to_post(post)
|
26
|
-
status(post) + capture { link_to_edit(post.title, post) } # , :class => post.state
|
27
|
-
end
|
28
|
-
|
29
|
-
def link_to_author(post)
|
30
|
-
''.html_safe # link_to(post.author_name, admin_site_user_path(@site, post.author))
|
31
|
-
end
|
32
|
-
|
33
|
-
def link_to_view(post)
|
34
|
-
capture { link_to(options[:text] || :'.actions.view', public_url_for([blog, post]), :class => :view) }
|
35
|
-
end
|
36
|
-
|
37
|
-
def status(post)
|
38
|
-
capture { span(t(:'.status.published'), :title => t(:'.status.published'), :class => 'status published') }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class Posts::Meta < Minimal::Template
|
2
|
-
include do
|
3
|
-
def to_html
|
4
|
-
div :class => :meta do
|
5
|
-
self << t(:'.info', :date => date, :author => nil).html_safe # TODO
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
def date
|
10
|
-
capture do
|
11
|
-
content_tag(:abbr, :title => post.created_at, :class => 'updated') do
|
12
|
-
self << l(post.created_at, :format => :post)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
class Posts::Index < Minimal::Template
|
2
|
-
include do
|
3
|
-
def to_html
|
4
|
-
ul :class => 'blog posts' do
|
5
|
-
collection.each do |post|
|
6
|
-
li :class => 'post hentry' do
|
7
|
-
h2 do
|
8
|
-
link_to(post.title, [post.section, post], :class => 'entry-title', :rel => 'bookmark')
|
9
|
-
end
|
10
|
-
render :partial => 'posts/meta', :locals => { :post => post }
|
11
|
-
div truncate_html(post.body, :length => 500, :omission => ' …'), :class => 'entry-content'
|
12
|
-
p do
|
13
|
-
link_to(:'.continue', [post.section, post], :class => :continue)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class Posts::Show < Minimal::Template
|
2
|
-
include do
|
3
|
-
def to_html
|
4
|
-
div :class => resource.class.name.underscore do
|
5
|
-
h2 { link_to(resource.title, resources, :class => 'entry-title', :rel => 'bookmark') }
|
6
|
-
render :partial => 'posts/meta', :locals => { :post => resource }
|
7
|
-
self << resource.body.html_safe
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
data/config/locales/en.yml
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
en:
|
2
|
-
time:
|
3
|
-
formats:
|
4
|
-
post: "%a, %d %b %Y"
|
5
|
-
|
6
|
-
section:
|
7
|
-
types:
|
8
|
-
blog: Blog
|
9
|
-
|
10
|
-
menu:
|
11
|
-
posts: Posts
|
12
|
-
new_post: New Post
|
13
|
-
|
14
|
-
columns:
|
15
|
-
post: Post
|
16
|
-
comments: Comments
|
17
|
-
|
18
|
-
posts:
|
19
|
-
index:
|
20
|
-
continue: Read the rest of this post
|
21
|
-
meta:
|
22
|
-
info: "posted on %{date}"
|
23
|
-
|
24
|
-
admin:
|
25
|
-
blogs:
|
26
|
-
new:
|
27
|
-
title: Create a New Section
|
28
|
-
edit:
|
29
|
-
title: Settings
|
30
|
-
posts:
|
31
|
-
index:
|
32
|
-
empty: "There are no posts. %{link}"
|
33
|
-
create_item: "Create one now »"
|
34
|
-
new:
|
35
|
-
title: Write a new blog post
|
36
|
-
edit:
|
37
|
-
title: Edit Post
|
38
|
-
delete: Delete
|
data/config/redirects.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
Adva::Registry.set :redirect, {
|
2
|
-
# see comment in admin/blog_controller
|
3
|
-
# 'admin/blogs#show' => lambda { |c| c.index_path(:posts) },
|
4
|
-
'admin/blogs#update' => lambda { |c| c.edit_url },
|
5
|
-
'admin/posts#create' => lambda { |c| c.edit_url },
|
6
|
-
'admin/posts#update' => lambda { |c| c.edit_url },
|
7
|
-
'admin/posts#destroy' => lambda { |c| c.show_parent_url }
|
8
|
-
}
|
data/config/routes.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
Rails.application.routes.draw do
|
2
|
-
namespace :admin do
|
3
|
-
resources :sites do
|
4
|
-
resources :blogs do
|
5
|
-
resources :posts
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
constraints :year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/ do
|
11
|
-
match 'blogs/:blog_id(/:year(/:month(/:day)))', :to => 'posts#index', :as => :blog
|
12
|
-
match 'blogs/:blog_id/:year/:month/:day/:slug', :to => 'posts#show'
|
13
|
-
end
|
14
|
-
|
15
|
-
# this is just here so we get the named url helper and can use url_for(blog, post)
|
16
|
-
# TODO how can we improve this?
|
17
|
-
match 'blogs/:blog_id/*permalink', :to => "posts#internal", :as => :blog_post
|
18
|
-
end
|
data/lib/adva/blog.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'adva/core'
|
2
|
-
require 'adva/engine'
|
3
|
-
|
4
|
-
require 'routing_filter'
|
5
|
-
require 'adva/routing_filters/section_root'
|
6
|
-
|
7
|
-
require 'action_controller' # really should be in truncate_html
|
8
|
-
require 'truncate_html'
|
9
|
-
|
10
|
-
module Adva
|
11
|
-
class Blog < ::Rails::Engine
|
12
|
-
include Adva::Engine
|
13
|
-
|
14
|
-
initializer 'adva-blog.require_section_types' do
|
15
|
-
config.to_prepare { require_dependency 'blog' }
|
16
|
-
end
|
17
|
-
|
18
|
-
initializer 'adva-blog.configure_routing_filters' do
|
19
|
-
RoutingFilter::SectionRoot.anchors << '\d{4}'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
data/lib/adva-blog.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'adva/blog'
|
data/lib/adva_blog/version.rb
DELETED
data/lib/testing/factories.rb
DELETED
data/lib/testing/paths.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Adva::Blog::Paths
|
2
|
-
def path_to(page)
|
3
|
-
case page
|
4
|
-
|
5
|
-
when /^the admin posts list page of the "([^"]*)" blog$/
|
6
|
-
section = Blog.find_by_name($1) || raise("could not find blog #{$1.inspect}")
|
7
|
-
polymorphic_path([:admin, section.site, section])
|
8
|
-
|
9
|
-
when /^the admin edit post page for the post "([^"]*)"$/
|
10
|
-
post = Post.find_by_title($1) || raise("could not find post #{$1.inspect}")
|
11
|
-
polymorphic_path([:edit, :admin, post.section.site, post.section, post])
|
12
|
-
|
13
|
-
else
|
14
|
-
super
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
World(Adva::Blog::Paths)
|
File without changes
|