orange-more 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,6 @@ require File.join(libdir, 'orange-more', 'assets')
8
8
  require File.join(libdir, 'orange-more', 'pages')
9
9
  require File.join(libdir, 'orange-more', 'sitemap')
10
10
  require File.join(libdir, 'orange-more', 'slices')
11
- require File.join(libdir, 'orange-more', 'blog')
12
11
  require File.join(libdir, 'orange-more', 'news')
13
12
  require File.join(libdir, 'orange-more', 'disqus')
14
13
  require File.join(libdir, 'orange-more', 'contactforms')
@@ -162,12 +162,14 @@ module Orange
162
162
  end
163
163
 
164
164
  def create_home_for_site(packet, site_id)
165
- page = orange[:pages, true].new(packet, :title => 'Homepage', :body => 'this is an orange webpage', :no_reroute => true)
165
+ page = orange[:pages, true].new(packet, :title => 'Homepage', :body => 'this is an orange webpage', :no_reroute => true, :published => true)
166
166
  if page
167
- model_class.create_home_for_site(site_id, :resource => 'pages', :resource_id => page.id)
167
+ ret = model_class.create_home_for_site(site_id, :resource => 'pages', :resource_id => page.id)
168
168
  else
169
- model_class.create_home_for_site(site_id)
169
+ ret = model_class.create_home_for_site(site_id)
170
170
  end
171
+ orange.fire(:sitemap_created, {:packet => packet, :site_id => site_id})
172
+ ret
171
173
  end
172
174
 
173
175
  def one_level(packet, opts = {})
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 2
9
- version: 0.7.2
8
+ - 3
9
+ version: 0.7.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Haslem
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-08 00:00:00 -04:00
17
+ date: 2010-10-27 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -120,7 +120,7 @@ dependencies:
120
120
  type: :runtime
121
121
  version_requirements: *id008
122
122
  - !ruby/object:Gem::Dependency
123
- name: gattica
123
+ name: i18n
124
124
  prerelease: false
125
125
  requirement: &id009 !ruby/object:Gem::Requirement
126
126
  requirements:
@@ -132,7 +132,7 @@ dependencies:
132
132
  type: :runtime
133
133
  version_requirements: *id009
134
134
  - !ruby/object:Gem::Dependency
135
- name: rspec
135
+ name: gattica
136
136
  prerelease: false
137
137
  requirement: &id010 !ruby/object:Gem::Requirement
138
138
  requirements:
@@ -141,10 +141,10 @@ dependencies:
141
141
  segments:
142
142
  - 0
143
143
  version: "0"
144
- type: :development
144
+ type: :runtime
145
145
  version_requirements: *id010
146
146
  - !ruby/object:Gem::Dependency
147
- name: rack-test
147
+ name: rspec
148
148
  prerelease: false
149
149
  requirement: &id011 !ruby/object:Gem::Requirement
150
150
  requirements:
@@ -155,6 +155,18 @@ dependencies:
155
155
  version: "0"
156
156
  type: :development
157
157
  version_requirements: *id011
158
+ - !ruby/object:Gem::Dependency
159
+ name: rack-test
160
+ prerelease: false
161
+ requirement: &id012 !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ segments:
166
+ - 0
167
+ version: "0"
168
+ type: :development
169
+ version_requirements: *id012
158
170
  description: Orange is a Ruby framework for building managed websites with code as simple as Sinatra
159
171
  email: therabidbanana@gmail.com
160
172
  executables: []
@@ -198,19 +210,6 @@ files:
198
210
  - lib/orange-more/assets/views/assets/change.haml
199
211
  - lib/orange-more/assets/views/assets/create.haml
200
212
  - lib/orange-more/assets/views/assets/insert.haml
201
- - lib/orange-more/blog.rb
202
- - lib/orange-more/blog/base.rb
203
- - lib/orange-more/blog/cartons/blog.rb
204
- - lib/orange-more/blog/cartons/blog_post.rb
205
- - lib/orange-more/blog/plugin.rb
206
- - lib/orange-more/blog/resources/blog_post_resource.rb
207
- - lib/orange-more/blog/resources/blog_resource.rb
208
- - lib/orange-more/blog/views/blog/blog_archive_view.haml
209
- - lib/orange-more/blog/views/blog/blog_offset_list_view.haml
210
- - lib/orange-more/blog/views/blog/blog_post_view.haml
211
- - lib/orange-more/blog/views/blog/sitemap_row.haml
212
- - lib/orange-more/blog/views/blog_posts/edit.haml
213
- - lib/orange-more/blog/views/blog_posts/show.haml
214
213
  - lib/orange-more/cloud.rb
215
214
  - lib/orange-more/cloud/base.rb
216
215
  - lib/orange-more/cloud/plugin.rb
@@ -1 +0,0 @@
1
- require File.join('orange-more', 'blog', 'plugin')
@@ -1,4 +0,0 @@
1
- require 'orange-more/blog/cartons/blog'
2
- require 'orange-more/blog/cartons/blog_post'
3
- require 'orange-more/blog/resources/blog_resource'
4
- require 'orange-more/blog/resources/blog_post_resource'
@@ -1,8 +0,0 @@
1
- require 'orange-more/administration/cartons/site_carton'
2
- class OrangeBlog < Orange::SiteCarton
3
- id
4
- front do
5
- title :title
6
- end
7
- has n, :posts, "OrangeBlogPost", :child_key => [:blog_id]
8
- end
@@ -1,60 +0,0 @@
1
- require 'dm-timestamps'
2
- class OrangeBlogPost < Orange::Carton
3
- id
4
- front do
5
- title :title, :length => 255
6
- fulltext :body
7
- end
8
- admin do
9
- fulltext :summary
10
- end
11
- orange do
12
- boolean :published, :default => false
13
- text :slug, :length => 255
14
- text :author
15
- end
16
-
17
- property :created_at, DateTime
18
- property :published_at, DateTime
19
- property :updated_at, DateTime
20
- belongs_to :blog, "OrangeBlog"
21
-
22
- def title=(t)
23
- self.attribute_set('title', t)
24
- self.attribute_set('slug', t.downcase.gsub(/<\/?[^>]*>/, "").gsub(/[']+/, "").gsub(/[^a-z0-9]+/, "_"))
25
- end
26
-
27
- def published=(val)
28
- if val == '1' || val === true
29
- self.publish
30
- else
31
- self.attribute_set('published', false)
32
- end
33
- end
34
-
35
- def publish
36
- self.published_at = Time.now if self.published_at.blank?
37
- self.attribute_set('published', true)
38
- end
39
-
40
- def publish!
41
- self.publish
42
- self.save
43
- end
44
-
45
- def self.year_and_month(yr, mnth)
46
- all(:published_at.gte => DateTime.new(yr, mnth, 1), :published_at.lt => DateTime.new(yr, mnth + 1, 1))
47
- end
48
-
49
- def self.slug(slug)
50
- first(:slug => slug)
51
- end
52
-
53
- def self.published
54
- all(:published => true)
55
- end
56
-
57
- def self.draft
58
- all(:published => false)
59
- end
60
- end
@@ -1,13 +0,0 @@
1
- require 'orange-more/blog/base'
2
-
3
- module Orange::Plugins
4
- class Blog < Base
5
- views_dir File.join(File.dirname(__FILE__), 'views')
6
-
7
- resource Orange::BlogResource.new
8
- resource Orange::BlogPostResource.new
9
- end
10
- end
11
-
12
- Orange.plugin(Orange::Plugins::Blog.new)
13
-
@@ -1,54 +0,0 @@
1
- module Orange
2
- class BlogResource < Orange::ModelResource
3
- use OrangeBlogPost
4
- call_me :blog_posts
5
- def stack_init
6
- orange[:admin, true].add_link("Content", :resource => @my_orange_name, :text => 'Blog')
7
- end
8
-
9
-
10
- def publish(packet, *opts)
11
- if packet.request.post?
12
- m = model_class.get(packet['route.resource_id'])
13
- if m
14
- m.publish!
15
- cloud_publish(packet, m)
16
- end
17
- end
18
- packet.reroute(@my_orange_name, :orange)
19
- end
20
-
21
- def cloud_publish(packet, post)
22
- orange[:cloud].microblog(packet, "New post on our blog: #{post.title} - http://#{packet['site'].url}#{orange[:blog].blog_url_for(packet)}/#{post.published_at.year}/#{post.published_at.month}/#{post.slug}") if post.published && !post.published_at.blank?
23
- end
24
-
25
- # Creates a new model object and saves it (if a post), then reroutes to the main page
26
- # @param [Orange::Packet] packet the packet being routed
27
- def onNew(packet, params)
28
- params[:published] = false unless params.has_key?(:published) || params.has_key?("published")
29
- params[:author] = packet['user', false] ? packet['user'].name : "Author" unless params.has_key?(:author) || params.has_key?("author")
30
-
31
- blog = orange[:blog].blog_for_site(packet)
32
- post = blog.posts.new(params)
33
- post
34
- end
35
-
36
- # Saves updates to an object specified by packet['route.resource_id'], then reroutes to main
37
- # @param [Orange::Packet] packet the packet being routed
38
- def onSave(packet, m, params = {})
39
- m.update(params)
40
- m.blog = orange[:blog].blog_for_site(packet) unless m.blog #ensure blog exists
41
-
42
- m.save
43
- cloud_publish(packet, m)
44
- m
45
- end
46
-
47
- def find_list(packet, mode, opts = {})
48
- blog = orange[:blog].blog_for_site(packet)
49
- opts[:order] = [:updated_at.desc]
50
- blog ? blog.posts.all(opts) : []
51
- end
52
-
53
- end
54
- end
@@ -1,105 +0,0 @@
1
- module Orange
2
- class BlogPostResource < Orange::ModelResource
3
- use OrangeBlog
4
- call_me :blog
5
- def stack_init
6
- orange[:admin, true].add_link("Settings", :resource => @my_orange_name, :text => 'Blog')
7
- end
8
-
9
- def sitemap_row(packet, opts = {})
10
- do_view(packet, :sitemap_row, opts)
11
- end
12
-
13
- def blog_view(packet, opts = {})
14
- resource_path = packet['route.resource_path']
15
- if resource_path.blank?
16
- blog_list_view(packet, opts)
17
- elsif resource_path =~ /^\/page/
18
- blog_offset_list_view(packet, opts)
19
- elsif resource_path =~ /^\/archives?/
20
- blog_archive_view(packet, opts)
21
- else
22
- blog_post_view(packet, opts)
23
- end
24
- end
25
-
26
- def blog_post_view(packet, opts = {})
27
- resource_path = packet['route.resource_path']
28
- blog = blog_for_site(packet)
29
- opts.merge!( :blog_url => blog_url_for(packet))
30
- parts = resource_path.split('/')
31
- if parts.size == 2
32
- post = blog.posts.first(:id => parts[1].to_i)
33
- elsif parts.size == 4
34
- post = blog.posts.year_and_month(parts[1].to_i, parts[2].to_i).slug(parts[3])
35
- end
36
- if post
37
- orange[:blog_posts].do_view(packet, :show, opts.merge({:model => post}))
38
- else
39
- "Not found"
40
- end
41
- end
42
-
43
- def blog_url_for(packet)
44
- blog = blog_for_site(packet)
45
- blog_url = orange[:sitemap, true].url_for(packet, :orange_site_id => blog.orange_site_id, :resource => :blog, :resource_id => blog.id, :resource_action => :blog_view, :include_subsite => true)
46
- blog_url.gsub!(/\/$/, '')
47
- end
48
-
49
- def blog_offset_list_view(packet, opts = {})
50
- opts.merge!(packet.extract_opts)
51
- opts.merge!( :blog_url => blog_url_for(packet))
52
- blog = blog_for_site(packet)
53
- opts[:page] = opts[:page].to_i unless opts[:page].blank?
54
- page = opts[:page].blank? ? 0 : opts[:page] - 1
55
- opts[:list] = blog.posts.published.all(:order => :published_at.desc,
56
- :limit => 5,
57
- :offset => (5*page)
58
- )
59
- opts[:pages] = (blog.posts.published.count / 5) + 1
60
- do_list_view(packet, :blog_offset_list_view, opts)
61
- end
62
-
63
- def blog_list_view(packet, opts = {})
64
- blog_offset_list_view(packet, opts.merge!({:page => 1}))
65
- end
66
-
67
- def blog_archive_view(packet, opts = {})
68
- opts.merge!( :blog_url => blog_url_for(packet))
69
- do_list_view(packet, :blog_archive_view, opts)
70
- end
71
-
72
- def blog_for_site(packet, site_id = false)
73
- site_id ||= (packet['subsite'].blank? ? packet['site'] : packet['subsite'])
74
- site_id = OrangeSite.get(site_id) unless site_id.is_a? OrangeSite
75
- blog = OrangeBlog.first(:orange_site => site_id)
76
- if !blog && packet.request.post? # Only create a new blog if this is a post
77
- blog = OrangeBlog.new
78
- blog.title = 'An Orange Hosted Blog'
79
- blog.orange_site = packet['site']
80
- blog.save
81
- end
82
- if packet.request.post? && !OrangeRoute.first(:resource => 'blog', :orange_site => packet['site'])
83
- orange[:sitemap, true].add_route_for(packet,
84
- :orange_site => site_id,
85
- :resource => :blog,
86
- :resource_id => blog.id,
87
- :resource_action => :blog_view,
88
- :slug => 'blog',
89
- :link_text => 'Orange Blog'
90
- )
91
- end
92
- blog
93
- end
94
-
95
- def find_list(packet, mode, id =false)
96
- blog = blog_for_site(packet)
97
- case mode
98
- when :blog_list_view then blog.posts.published.all(:order => :published_at.desc, :limit => 5)
99
- when :blog_archive_view then blog.posts.published
100
- else OrangeBlog.all
101
- end
102
- end
103
-
104
- end
105
- end
@@ -1,6 +0,0 @@
1
- .blog_posts
2
- - for post in list
3
- .blog_post
4
- %h2
5
- %span #{post.created_at.strftime("%B %d, %Y")}
6
- %a{:href => "#{blog_url}/#{post.published_at.year}/#{post.published_at.month}/#{post.slug}"}= post.title
@@ -1,12 +0,0 @@
1
- .blog_posts
2
- - for post in list
3
- .blog_post
4
- %h2
5
- %a{:href => "#{blog_url}/#{post.created_at.year}/#{post.created_at.month}/#{post.slug}"}= post.title
6
- %h3.posted_by Posted by #{post.author}
7
- .blog_post_body= post.summary.blank? ? post.body : post.summary
8
- .blog_nav
9
- - if page > 1
10
- %a.newer{:href => "#{blog_url}/page/#{page-1}"} Newer Posts
11
- - if page < pages
12
- %a.older{:href => "#{blog_url}/page/#{page+1}"} Older Posts
@@ -1,4 +0,0 @@
1
- .blog_post
2
- %h2= model.title
3
- .blog_post_body= model.body
4
- = orange[:disqus, true].comment_thread(packet)
@@ -1,14 +0,0 @@
1
- - if route
2
- .sitemap_item{:class => "sitemap_level_#{route.level}"}
3
- - if route.level > 0
4
- = orange[:sitemap].route_actions(packet, :model => route)
5
- %h4 #{route.link_text} <span>(#{route.full_path})</span>
6
- .linked_to
7
- %p
8
- Blog titled "#{model.title}"
9
- %br
10
- %a{:href => route_to(:blog_posts, 'create')} Add New Blog Post
11
- .actions
12
- = form_link('Delete', route_to(:sitemap, route.id, 'delete'), 'Are you sure you want to delete this?', {:method => 'delete'})
13
- %a{:href => route_to(:sitemap, route.id, 'edit')} Edit
14
- %br.clear
@@ -1,8 +0,0 @@
1
- - if model
2
- %form{:action => route_to(model_name, model[:id], 'save'), :method => 'post'}
3
- - for prop in props
4
- %p~ view_attribute(prop, model_name, :label => true, :value => model.attribute_get(prop[:name]))
5
- %input{:type => 'submit', :value => 'Save Changes'}
6
- = form_link('Publish', packet.route_to(model_name, model[:id], 'publish'))
7
- - else
8
- %p Couldn't find the item you're looking for.
@@ -1,4 +0,0 @@
1
- .blog_post
2
- %h2= model.title
3
- .blog_post_body= model.body
4
- = orange[:disqus, true].comment_thread(packet)