Class: RuneBlog::ViewPost
- Inherits:
-
Object
- Object
- RuneBlog::ViewPost
- Defined in:
- lib/post.rb
Instance Attribute Summary collapse
-
#aslug ⇒ Object
readonly
Returns the value of attribute aslug.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#nslug ⇒ Object
readonly
Returns the value of attribute nslug.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#teaser_text ⇒ Object
readonly
Returns the value of attribute teaser_text.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #get_dirs ⇒ Object
-
#initialize(view, postdir) ⇒ ViewPost
constructor
A new instance of ViewPost.
Constructor Details
#initialize(view, postdir) ⇒ ViewPost
Returns a new instance of ViewPost.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/post.rb', line 117 def initialize(view, postdir) log!(enter: __method__, args: [view, postdir]) # Assumes already parsed/processed @blog = RuneBlog.blog || raise(NoBlogAccessor) @path = postdir.dup @nslug = @path.split("/").last @aslug = @nslug[5..-1] fname = "#{postdir}/teaser.txt" = File.read(fname).chomp # FIXME dumb hacks... mdfile = postdir/"metadata.txt" lines = File.readlines(mdfile) @title = lines.grep(/title:/).first[7..-1].chomp @date = lines.grep(/pubdate:/).first[9..-1].chomp end |
Instance Attribute Details
#aslug ⇒ Object (readonly)
Returns the value of attribute aslug.
114 115 116 |
# File 'lib/post.rb', line 114 def aslug @aslug end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
114 115 116 |
# File 'lib/post.rb', line 114 def date @date end |
#nslug ⇒ Object (readonly)
Returns the value of attribute nslug.
114 115 116 |
# File 'lib/post.rb', line 114 def nslug @nslug end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
114 115 116 |
# File 'lib/post.rb', line 114 def path @path end |
#teaser_text ⇒ Object (readonly)
Returns the value of attribute teaser_text.
114 115 116 |
# File 'lib/post.rb', line 114 def end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
114 115 116 |
# File 'lib/post.rb', line 114 def title @title end |
Instance Method Details
#get_dirs ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/post.rb', line 133 def get_dirs log!(enter: __method__, args: [view, postdir]) fname = File.basename(draft) noext = fname.sub(/.lt3$/, "") vdir = @root/:views/view dir = vdir/:posts/noext + "/" Dir.mkdir(dir) unless Dir.exist?(dir) system!("cp #{draft} #{dir}") viewdir, slugdir, aslug = vdir, dir, noext[5..-1] theme = viewdir/:themes/:standard [noext, viewdir, slugdir, aslug, theme] end |