Class: RuneBlog::ViewPost

Inherits:
Object
  • Object
show all
Defined in:
lib/post.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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"
  @teaser_text = 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

#aslugObject (readonly)

Returns the value of attribute aslug.



117
118
119
# File 'lib/post.rb', line 117

def aslug
  @aslug
end

#dateObject (readonly)

Returns the value of attribute date.



117
118
119
# File 'lib/post.rb', line 117

def date
  @date
end

#nslugObject (readonly)

Returns the value of attribute nslug.



117
118
119
# File 'lib/post.rb', line 117

def nslug
  @nslug
end

#pathObject (readonly)

Returns the value of attribute path.



117
118
119
# File 'lib/post.rb', line 117

def path
  @path
end

#teaser_textObject (readonly)

Returns the value of attribute teaser_text.



117
118
119
# File 'lib/post.rb', line 117

def teaser_text
  @teaser_text
end

#titleObject (readonly)

Returns the value of attribute title.



117
118
119
# File 'lib/post.rb', line 117

def title
  @title
end

Instance Method Details

#get_dirsObject



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