Class: RuneBlog::Post
- Inherits:
-
Object
- Object
- RuneBlog::Post
- Includes:
- Helpers
- Defined in:
- lib/runeblog_version.rb,
lib/post.rb
Instance Attribute Summary collapse
-
#blog ⇒ Object
Returns the value of attribute blog.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#draft ⇒ Object
Returns the value of attribute draft.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#num ⇒ Object
readonly
Returns the value of attribute num.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#views ⇒ Object
readonly
Returns the value of attribute views.
Class Method Summary collapse
- .create(title:, teaser:, body:, pubdate: Time.now.strftime("%Y-%m-%d"), views: [], file: nil) ⇒ Object
- .load(post) ⇒ Object
Instance Method Summary collapse
- #build ⇒ Object
- #edit ⇒ Object
-
#initialize ⇒ Post
constructor
A new instance of Post.
Methods included from Helpers
#copy_data, #find_draft_slugs, #get_all_widgets, #get_repo_config, #get_widget, #new_sequence, #quit_RubyText, #read_features, #read_vars, #subdirs, #write_features, #write_repo_config
Constructor Details
Instance Attribute Details
#blog ⇒ Object
Returns the value of attribute blog.
7 8 9 |
# File 'lib/post.rb', line 7 def blog @blog end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
6 7 8 |
# File 'lib/post.rb', line 6 def date @date end |
#draft ⇒ Object
Returns the value of attribute draft.
7 8 9 |
# File 'lib/post.rb', line 7 def draft @draft end |
#meta ⇒ Object
Returns the value of attribute meta.
7 8 9 |
# File 'lib/post.rb', line 7 def @meta end |
#num ⇒ Object (readonly)
Returns the value of attribute num.
6 7 8 |
# File 'lib/post.rb', line 6 def num @num end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
6 7 8 |
# File 'lib/post.rb', line 6 def slug @slug end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/post.rb', line 6 def title @title end |
#views ⇒ Object (readonly)
Returns the value of attribute views.
6 7 8 |
# File 'lib/post.rb', line 6 def views @views end |
Class Method Details
.create(title:, teaser:, body:, pubdate: Time.now.strftime("%Y-%m-%d"), views: [], file: nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/post.rb', line 36 def self.create(title:, teaser:, body:, pubdate: Time.now.strftime("%Y-%m-%d"), views:[], file: nil) log!(enter: __method__, args: [title, , body, pubdate, views], stderr: true) post = self.new # NOTE: This is the ONLY place next_sequence is called! num = post..num = post.blog.next_sequence # new_metadata post..title, post.., post..body, post..pubdate = title, , body, pubdate post..views = [post.blog.view.to_s] + views post.. = [] post.blog.make_slug(post.) # adds to meta # create_draft viewhome = post.blog.view.publisher.url = post. if file.nil? text = RuneBlog.post_template(num: .num, title: .title, date: .pubdate, view: .view, teaser: ., body: .body, views: .views, tags: ., home: viewhome) srcdir = post.blog.root/:drafts + "/" vpdir = post.blog.root/:drafts + "/" fname = .slug + ".lt3" post.draft = srcdir + fname dump(text, post.draft) else dump(File.read(file), post.draft) end return post end |
.load(post) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/post.rb', line 12 def self.load(post) log!(enter: __method__, args: [post], level: 3) raise NotImplemented raise NoBlogAccessor if RuneBlog.blog.nil? # "post" is a slug? pdir = RuneBlog.blog.root/:drafts/post = nil Dir.chdir(pdir) do # meta = read_config("metadata.txt") # meta.date = Date.parse(meta.date) # meta.views = meta.views.split # meta.tags = meta.tags.split # meta.teaser = File.read("teaser.txt") # meta.body = File.read("body.txt") end end |