Class: Aerial::Article
Instance Attribute Summary collapse
-
#archive_name ⇒ Object
readonly
Returns the value of attribute archive_name.
-
#body_html ⇒ Object
readonly
Returns the value of attribute body_html.
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#publish_date ⇒ Object
readonly
Returns the value of attribute publish_date.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#updated_on ⇒ Object
readonly
Returns the value of attribute updated_on.
Attributes inherited from Content
Class Method Summary collapse
-
.all(options = {}) ⇒ Object
Find all articles, including drafts.
-
.archives ⇒ Object
Calculate the archives.
-
.exists?(id) ⇒ Boolean
Return true if the article file exists
id. -
.find(id, options = {}) ⇒ Object
Find a single article by id
idof the blob. -
.open(id, options = {}) ⇒ Object
A quick way to load an article by blob id
idof the blob. -
.recent(options = {}) ⇒ Object
Find the most recent articles.
-
.tags ⇒ Object
Return all the tags assigned to the articles.
-
.with_date(year, month, options = {}) ⇒ Object
Find articles by month and year
yearof when article was published + month+ of when the article was published. -
.with_name(name, options = {}) ⇒ Object
Find a single article by name
nameof the article file. -
.with_permalink(link, options = {}) ⇒ Object
Return an article given its permalink value
linkfull path of the link. -
.with_tag(tag, options = {}) ⇒ Object
Find articles by tag
tagcategory.
Instance Method Summary collapse
-
#add_comment(comment) ⇒ Object
Add a comment to the list of this Article’s comments +comment new comment.
-
#archive_expand_path ⇒ Object
Returns the full path to the article archive (directory).
-
#expand_path ⇒ Object
Returns the absolute path to the article file.
-
#permalink ⇒ Object
Make a permanent link for the article.
Methods inherited from Content
Constructor Details
This class inherits a constructor from Aerial::Content
Instance Attribute Details
#archive_name ⇒ Object (readonly)
Returns the value of attribute archive_name.
5 6 7 |
# File 'lib/aerial/article.rb', line 5 def archive_name @archive_name end |
#body_html ⇒ Object (readonly)
Returns the value of attribute body_html.
5 6 7 |
# File 'lib/aerial/article.rb', line 5 def body_html @body_html end |
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
5 6 7 |
# File 'lib/aerial/article.rb', line 5 def comments @comments end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
5 6 7 |
# File 'lib/aerial/article.rb', line 5 def file_name @file_name end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/aerial/article.rb', line 5 def id @id end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
5 6 7 |
# File 'lib/aerial/article.rb', line 5 def @meta end |
#publish_date ⇒ Object (readonly)
Returns the value of attribute publish_date.
5 6 7 |
# File 'lib/aerial/article.rb', line 5 def publish_date @publish_date end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
5 6 7 |
# File 'lib/aerial/article.rb', line 5 def @tags end |
#updated_on ⇒ Object (readonly)
Returns the value of attribute updated_on.
5 6 7 |
# File 'lib/aerial/article.rb', line 5 def updated_on @updated_on end |
Class Method Details
.all(options = {}) ⇒ Object
Find all articles, including drafts
13 14 15 |
# File 'lib/aerial/article.rb', line 13 def self.all(={}) self.find_all end |
.archives ⇒ Object
Calculate the archives
72 73 74 |
# File 'lib/aerial/article.rb', line 72 def self.archives self.find_archives end |
.exists?(id) ⇒ Boolean
Return true if the article file exists id
62 63 64 |
# File 'lib/aerial/article.rb', line 62 def self.exists?(id) self.find_by_name(id) ? true : false end |
.find(id, options = {}) ⇒ Object
Find a single article by id
+id+ of the blob
25 26 27 |
# File 'lib/aerial/article.rb', line 25 def self.find(id, ={}) self.find_by_id(id, ) end |
.open(id, options = {}) ⇒ Object
A quick way to load an article by blob id
+id+ of the blob
19 20 21 |
# File 'lib/aerial/article.rb', line 19 def self.open(id, = {}) self.find_by_blob_id(id, ) end |
.recent(options = {}) ⇒ Object
Find the most recent articles
55 56 57 58 |
# File 'lib/aerial/article.rb', line 55 def self.recent(={}) limit = .delete(:limit) || 4 self.find_all().first(limit) end |
.tags ⇒ Object
Return all the tags assigned to the articles
67 68 69 |
# File 'lib/aerial/article.rb', line 67 def self. self. end |
.with_date(year, month, options = {}) ⇒ Object
Find articles by month and year
+year+ of when article was published
+ month+ of when the article was published
44 45 46 |
# File 'lib/aerial/article.rb', line 44 def self.with_date(year, month, ={}) self.find_by_date(year, month, ) end |
.with_name(name, options = {}) ⇒ Object
Find a single article by name
+name+ of the article file
31 32 33 |
# File 'lib/aerial/article.rb', line 31 def self.with_name(name, ={}) self.find_by_name(name, ) end |
.with_permalink(link, options = {}) ⇒ Object
Return an article given its permalink value
+link+ full path of the link
50 51 52 |
# File 'lib/aerial/article.rb', line 50 def self.with_permalink(link, ={}) self.find_by_permalink(link, ) end |
.with_tag(tag, options = {}) ⇒ Object
Find articles by tag
+tag+ category
37 38 39 |
# File 'lib/aerial/article.rb', line 37 def self.with_tag(tag, ={}) self.find_by_tag(tag, ) end |
Instance Method Details
#add_comment(comment) ⇒ Object
Add a comment to the list of this Article’s comments
+comment new comment
82 83 84 |
# File 'lib/aerial/article.rb', line 82 def add_comment(comment) self.comments << comment.save(self.archive_name) # TODO: should we overload the << method? end |
#archive_expand_path ⇒ Object
Returns the full path to the article archive (directory)
98 99 100 101 |
# File 'lib/aerial/article.rb', line 98 def return unless archive = self.archive_name return "#{Aerial.repo.working_dir}/#{Aerial.config.articles.dir}/#{archive}" end |
#expand_path ⇒ Object
Returns the absolute path to the article file
93 94 95 |
# File 'lib/aerial/article.rb', line 93 def return "#{self.}/#{self.file_name}" end |
#permalink ⇒ Object
Make a permanent link for the article
87 88 89 90 |
# File 'lib/aerial/article.rb', line 87 def permalink link = self.file_name.gsub(/\.article$|\.markdown$|\.md$|\.mdown$|\.mkd$|\.mkdn$/, '') "/#{publish_date.year}/#{publish_date.month}/#{publish_date.day}/#{escape(link)}" end |