orthorings 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -9,8 +9,6 @@ The 2 main things you can do with Orthorings are:
9
9
 
10
10
  ## Installation
11
11
 
12
- As a gem
13
-
14
12
  gem install orthorings
15
13
 
16
14
  ## Configuration
@@ -125,7 +123,7 @@ Other attributes that will be present on a per item specific basis are the names
125
123
  {{Markdown body}}
126
124
 
127
125
 
128
- ## Example Usage (as provided by the OrthorHelper module, defined as class methods of Orthorings)
126
+ ## Example Usage
129
127
 
130
128
  In all the methods below, if you don't provide a template name, you will get the parsed JSON array/hash back.
131
129
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -5,6 +5,7 @@ class OrthorContentController < ApplicationController
5
5
  if params[:id]
6
6
  resource = Orthor::Site.find_resource_by_page_path(request.request_uri, params[:id])
7
7
  @orthor_content = Orthorings.content(params[:id], (resource.page_template || resource.template))
8
+ @orthor_page_title = Orthorings.content(id)["Title"]
8
9
  else
9
10
  resource = Orthor::Site.find_resource_by_path(request.request_uri)
10
11
  @orthor_content = resource.content
@@ -17,6 +18,7 @@ class OrthorContentController < ApplicationController
17
18
  @meta_keywords = resource.keywords
18
19
  @meta_description = resource.description
19
20
  @orthor_feeds = resource.respond_to?(:feeds) ? resource.feeds : []
21
+ @orthor_page_title ||= resource.title
20
22
 
21
23
  render :action => (resource.view || "orthor_content"), :layout => Orthor::Site.layout.to_s
22
24
  end
@@ -15,5 +15,9 @@ module Orthor
15
15
  def fetch_content
16
16
  Orthorings.category(@id, @template)
17
17
  end
18
+
19
+ def title
20
+ Orthorings.category(@id)["Title"]
21
+ end
18
22
  end
19
23
  end
data/lib/orthor/object.rb CHANGED
@@ -19,6 +19,10 @@ module Orthor
19
19
  fetch_content
20
20
  end
21
21
 
22
+ def title
23
+ ""
24
+ end
25
+
22
26
  def path_name
23
27
  @id.gsub(/[^a-z0-9]+/i, '_')
24
28
  end
data/lib/orthor/page.rb CHANGED
@@ -3,5 +3,9 @@ module Orthor
3
3
  def fetch_content
4
4
  Orthorings.content(@id, @template)
5
5
  end
6
+
7
+ def title
8
+ Orthorings.content(@id)["Title"]
9
+ end
6
10
  end
7
11
  end
@@ -4,7 +4,7 @@ module Orthor
4
4
  include Orthor::MetaData
5
5
 
6
6
  attr_accessor :path
7
- dsl_accessor :view, :controller
7
+ dsl_accessor :view, :name, :controller
8
8
 
9
9
  def initialize(path, options = {})
10
10
  @path = path
@@ -13,6 +13,10 @@ module Orthor
13
13
  options.each { |key, val| send(key, val) }
14
14
  end
15
15
 
16
+ def title
17
+ name
18
+ end
19
+
16
20
  def path_name
17
21
  @path.gsub("/", " ").strip.gsub(/[^a-z0-9]+/i, '_')
18
22
  end
data/lib/orthor_helper.rb CHANGED
@@ -32,4 +32,8 @@ module OrthorHelper
32
32
  html += %Q(<link rel="alternate" type="application/rss+xml" title="#{feed.name || "RSS"}" href="#{feed.path}" />)
33
33
  end
34
34
  end
35
+
36
+ def orthor_page_title
37
+ @orthor_page_title
38
+ end
35
39
  end
data/lib/orthorings.rb CHANGED
@@ -107,13 +107,17 @@ class Orthorings
107
107
  end
108
108
  json.collect do |c|
109
109
  c.inject(template) do |html, (key, val)|
110
- # if val.is_a?(Hash)
111
- if html.include?("{{#{key}.blurb}}")
110
+ if val.is_a?(String) && html.include?("{{#{key}.blurb}}")
112
111
  val = "#{val.to_s.gsub(/<\/?[^>]*>/, "")[0..150]}..."
113
112
  key = "#{key}.blurb"
114
- end
115
113
 
116
- html = html.gsub("{{#{key}}}", val.to_s)
114
+ html = html.gsub("{{#{key}}}", val.to_s)
115
+ elsif val.is_a?(Hash) && html.include?("{{#{key}.")
116
+ # we've got something like Author.Email
117
+ html = val.inject(html) { |h, (k, v)| h = h.gsub("{{#{key}.#{k}}}", v) }
118
+ else
119
+ html = html.gsub("{{#{key}}}", val.to_s)
120
+ end
117
121
  end
118
122
  end.join("")
119
123
  rescue => e
@@ -123,4 +127,3 @@ class Orthorings
123
127
  end
124
128
  end
125
129
 
126
-
@@ -9,6 +9,7 @@ module Sinatra
9
9
  @meta_keywords = resource.keywords
10
10
  @meta_description = resource.description
11
11
  @orthor_feeds = resource.respond_to?(:feeds) ? resource.feeds : []
12
+ @orthor_page_title = resource.title
12
13
  end
13
14
  end
14
15
 
@@ -20,8 +21,9 @@ module Sinatra
20
21
  ::Orthor::Site.resources.each do |resource|
21
22
  if resource.is_a?(::Orthor::Category) && !resource.page_path.nil?
22
23
  get resource.page_path do |id|
23
- @orthor_content = orthor_content(id, (resource.page_template || resource.template))
24
24
  handle_request(resource)
25
+ @orthor_content = orthor_content(id, (resource.page_template || resource.template))
26
+ @orthor_page_title = orthor_content(id)["Title"]
25
27
  erb (resource.view || "orthor_content").to_sym, { :layout => ::Orthor::Site.layout }
26
28
  end
27
29
  end
data/orthorings.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{orthorings}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Anthony Langhorne"]
12
- s.date = %q{2010-06-06}
12
+ s.date = %q{2010-06-09}
13
13
  s.email = %q{anthony@orthor.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -25,9 +25,16 @@ describe Orthor::Templates do
25
25
  describe "should use custom {{}} replacement for rendering" do
26
26
  before(:all) do
27
27
  Orthor::Templates.define do
28
- template :basic, %!<h2>{{title}}</h2><div class="content">{{Content}}</div>!
29
- template :brief, %!<h2>{{title}}</h2>!
28
+ template :basic, %!<h2>{{Title}}</h2><div class="content">{{Content}}</div>!
29
+ template :brief, %!<h2>{{Title}}</h2>!
30
30
  template :blurb, %!<div>{{Content.blurb}}</div>!
31
+ template :user, %!<div>{{Creator.Email}}</div><div>{{Creator.First name}} {{Creator.Last name}}</div>!
32
+ end
33
+ end
34
+
35
+ describe "users" do
36
+ it "should replace user.email" do
37
+ Orthorings.content("homepage", :user).should == "<div>demo@orthor.com</div><div>Bob Demo</div>"
31
38
  end
32
39
  end
33
40
 
@@ -1 +1 @@
1
- {"type":"content","public_id":"what-is-orthor","category":{"public_id":"content-pages","link":"http://content.orthor.com/orthor-demo/categories/content-pages.json","title":"Content Pages"},"Content":"<h2>So what is Orthor really??</h2>","template":"Text Block","created_at":"April 06, 2010","updater":{"email":"demo@orthor.com","firstname":"demo","lastname":"demo"},"updated_at":"April 26, 2010","author":{"email":"demo@orthor.com","firstname":"demo","lastname":"demo"},"title":"What is Orthor"}
1
+ {"type":"content","public_id":"what-is-orthor","category":{"public_id":"content-pages","link":"http://content.orthor.com/orthor-demo/categories/content-pages.json","Title":"Content Pages"},"Content":"<h2>So what is Orthor really??</h2>","template":"Text Block","created_at":"April 06, 2010","Updater":{"email":"demo@orthor.com","firstname":"Bob","lastname":"Demo"},"updated_at":"April 26, 2010","Creator":{"Email":"demo@orthor.com","First name":"Bob","Last name":"Demo"},"Title":"What is Orthor"}
@@ -1 +1 @@
1
- [{"type":"content","public_id":"user-manual-updated","Content":"The User Manual has recently had a big overhaul with increased documentation for lots of Orthor's great features, including Content Queries, RSS Feeds, Custom CSS and more!","url":"http://www.orthor.com/manual","created_at":"April 06, 2010","template":"Brief News Item","title":"User Manual updated","category":{"public_id":"news","link":"http://content.orthor.com/orthor-demo/categories/news.json","title":"News"},"updated_at":"April 06, 2010","author":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"}},{"type":"content","public_id":"account-event-tracking","Content":"All accounts now have access to event tracking, use this to gain a snapshot of what everyone in your account has been doing, for example, what were the latest items to get published, edited, created etc. Login to check it out.","url":"http://www.orthor.com/login","created_at":"April 06, 2010","template":"Brief News Item","title":"Account event tracking","category":{"public_id":"news","link":"http://content.orthor.com/orthor-demo/categories/news.json","title":"News"},"updated_at":"April 06, 2010","author":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"}},{"type":"content","public_id":"tutorials-have-been-updated","Content":"We've recently made the tutorials section of the site public, stay tuned for some more language examples + increased detail of the existing languages. ","url":"http://www.orthor.com/tutorials","created_at":"April 06, 2010","template":"Brief News Item","title":"Tutorials have been updated","category":{"public_id":"news","link":"http://content.orthor.com/orthor-demo/categories/news.json","title":"News"},"updated_at":"April 06, 2010","author":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"}}]
1
+ [{"type":"content","public_id":"user-manual-updated","Content":"The User Manual has recently had a big overhaul with increased documentation for lots of Orthor's great features, including Content Queries, RSS Feeds, Custom CSS and more!","url":"http://www.orthor.com/manual","created_at":"April 06, 2010","template":"Brief News Item","Title":"User Manual updated","category":{"public_id":"news","link":"http://content.orthor.com/orthor-demo/categories/news.json","Title":"News"},"updated_at":"April 06, 2010","author":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"}},{"type":"content","public_id":"account-event-tracking","Content":"All accounts now have access to event tracking, use this to gain a snapshot of what everyone in your account has been doing, for example, what were the latest items to get published, edited, created etc. Login to check it out.","url":"http://www.orthor.com/login","created_at":"April 06, 2010","template":"Brief News Item","Title":"Account event tracking","category":{"public_id":"news","link":"http://content.orthor.com/orthor-demo/categories/news.json","Title":"News"},"updated_at":"April 06, 2010","author":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"}},{"type":"content","public_id":"tutorials-have-been-updated","Content":"We've recently made the tutorials section of the site public, stay tuned for some more language examples + increased detail of the existing languages. ","url":"http://www.orthor.com/tutorials","created_at":"April 06, 2010","template":"Brief News Item","Title":"Tutorials have been updated","category":{"public_id":"news","link":"http://content.orthor.com/orthor-demo/categories/news.json","Title":"News"},"updated_at":"April 06, 2010","author":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"}}]
@@ -1 +1 @@
1
- {"type":"category","public_id":"news","children":[{"public_id":"media-releases","link":"http://content.orthor.com/orthor-demo/categories/media-releases.json","title":"Media Releases"},{"public_id":"quarterly-results","link":"http://content.orthor.com/orthor-demo/categories/quarterly-results.json","title":"Quarterly Results"}],"link":"http://content.orthor.com/orthor-demo/categories/news.json","title":"News","content":[{"type":"content","public_id":"user-manual-updated","Content":"The User Manual has recently had a big overhaul with increased documentation for lots of Orthor's great features, including Content Queries, RSS Feeds, Custom CSS and more!","url":"http://www.orthor.com/manual","created_at":"April 06, 2010","template":"Brief News Item","title":"User Manual updated","category":{"public_id":"news","link":"http://content.orthor.com/orthor-demo/categories/news.json","title":"News"},"updated_at":"April 06, 2010","author":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"}},{"type":"content","public_id":"account-event-tracking","Content":"All accounts now have access to event tracking, use this to gain a snapshot of what everyone in your account has been doing, for example, what were the latest items to get published, edited, created etc. Login to check it out.","url":"http://www.orthor.com/login","created_at":"April 06, 2010","template":"Brief News Item","title":"Account event tracking","category":{"public_id":"news","link":"http://content.orthor.com/orthor-demo/categories/news.json","title":"News"},"updated_at":"April 06, 2010","author":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"}},{"type":"content","public_id":"tutorials-have-been-updated","Content":"We've recently made the tutorials section of the site public, stay tuned for some more language examples + increased detail of the existing languages. ","url":"http://www.orthor.com/tutorials","created_at":"April 06, 2010","template":"Brief News Item","title":"Tutorials have been updated","category":{"public_id":"news","link":"http://content.orthor.com/orthor-demo/categories/news.json","title":"News"},"updated_at":"April 06, 2010","author":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"}},{"type":"content","public_id":"content-queries-have-landed-in-orthor","Content":"Content Queries are a powerful way to query all of your content at once. Some examples uses of content queries: Latest news items, Products on Sale or Featured Media releases.\r\n","url":"http://www.orthor.com/manual/content_queries","created_at":"April 04, 2010","template":"Brief News Item","title":"Content Queries have landed in Orthor","category":{"public_id":"news","link":"http://content.orthor.com/orthor-demo/categories/news.json","title":"News"},"updater":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"},"updated_at":"April 06, 2010","author":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"}}]}
1
+ {"type":"category","public_id":"news","children":[{"public_id":"media-releases","link":"http://content.orthor.com/orthor-demo/categories/media-releases.json","Title":"Media Releases"},{"public_id":"quarterly-results","link":"http://content.orthor.com/orthor-demo/categories/quarterly-results.json","Title":"Quarterly Results"}],"link":"http://content.orthor.com/orthor-demo/categories/news.json","Title":"News","content":[{"type":"content","public_id":"user-manual-updated","Content":"The User Manual has recently had a big overhaul with increased documentation for lots of Orthor's great features, including Content Queries, RSS Feeds, Custom CSS and more!","url":"http://www.orthor.com/manual","created_at":"April 06, 2010","template":"Brief News Item","Title":"User Manual updated","category":{"public_id":"news","link":"http://content.orthor.com/orthor-demo/categories/news.json","Title":"News"},"updated_at":"April 06, 2010","author":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"}},{"type":"content","public_id":"account-event-tracking","Content":"All accounts now have access to event tracking, use this to gain a snapshot of what everyone in your account has been doing, for example, what were the latest items to get published, edited, created etc. Login to check it out.","url":"http://www.orthor.com/login","created_at":"April 06, 2010","template":"Brief News Item","Title":"Account event tracking","category":{"public_id":"news","link":"http://content.orthor.com/orthor-demo/categories/news.json","Title":"News"},"updated_at":"April 06, 2010","author":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"}},{"type":"content","public_id":"tutorials-have-been-updated","Content":"We've recently made the tutorials section of the site public, stay tuned for some more language examples + increased detail of the existing languages. ","url":"http://www.orthor.com/tutorials","created_at":"April 06, 2010","template":"Brief News Item","Title":"Tutorials have been updated","category":{"public_id":"news","link":"http://content.orthor.com/orthor-demo/categories/news.json","Title":"News"},"updated_at":"April 06, 2010","author":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"}},{"type":"content","public_id":"content-queries-have-landed-in-orthor","Content":"Content Queries are a powerful way to query all of your content at once. Some examples uses of content queries: Latest news items, Products on Sale or Featured Media releases.\r\n","url":"http://www.orthor.com/manual/content_queries","created_at":"April 04, 2010","template":"Brief News Item","Title":"Content Queries have landed in Orthor","category":{"public_id":"news","link":"http://content.orthor.com/orthor-demo/categories/news.json","Title":"News"},"updater":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"},"updated_at":"April 06, 2010","author":{"firstname":"demo","lastname":"demo","email":"demo@orthor.com"}}]}
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 0
9
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Anthony Langhorne
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-06 00:00:00 +10:00
17
+ date: 2010-06-09 00:00:00 +10:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency