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.
120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/post.rb', line 120 def initialize(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.
117 118 119 |
# File 'lib/post.rb', line 117 def aslug @aslug end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
117 118 119 |
# File 'lib/post.rb', line 117 def date @date end |
#nslug ⇒ Object (readonly)
Returns the value of attribute nslug.
117 118 119 |
# File 'lib/post.rb', line 117 def nslug @nslug end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
117 118 119 |
# File 'lib/post.rb', line 117 def path @path end |
#teaser_text ⇒ Object (readonly)
Returns the value of attribute teaser_text.
117 118 119 |
# File 'lib/post.rb', line 117 def end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
117 118 119 |
# File 'lib/post.rb', line 117 def title @title end |
Instance Method Details
#get_dirs ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/post.rb', line 135 def get_dirs 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 |