Class: RuneBlog::View

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/runeblog_version.rb,
lib/view.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#copy_data, #find_draft_slugs, #get_repo_config, #new_sequence, #quit_RubyText, #read_features, #read_vars, #retrieve_views, #subdirs, #write_repo_config

Constructor Details

#initialize(name) ⇒ View

Returns a new instance of View.

Raises:

  • (NoBlogAccessor)


9
10
11
12
13
14
15
16
17
18
# File 'lib/view.rb', line 9

def initialize(name)
  log!(enter: __method__, args: [name], level: 3)
  raise NoBlogAccessor if RuneBlog.blog.nil?
  @blog = RuneBlog.blog
  @name = name
  @publisher = RuneBlog::Publishing.new(name)
  @can_publish = true  # FIXME
  @blog.view = self
  get_globals
end

Instance Attribute Details

#globalsObject (readonly)

Returns the value of attribute globals.



4
5
6
# File 'lib/view.rb', line 4

def globals
  @globals
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/view.rb', line 4

def name
  @name
end

#publisherObject

Returns the value of attribute publisher.



5
6
7
# File 'lib/view.rb', line 5

def publisher
  @publisher
end

#stateObject (readonly)

Returns the value of attribute state.



4
5
6
# File 'lib/view.rb', line 4

def state
  @state
end

Instance Method Details

#can_publish?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/view.rb', line 45

def can_publish?
  @can_publish
end

#dirObject



29
30
31
# File 'lib/view.rb', line 29

def dir
  @blog.root + "/views/#@name/"
end

#get_globalsObject



20
21
22
23
24
25
26
27
# File 'lib/view.rb', line 20

def get_globals
  gfile = @blog.root/"views/#{name}/themes/standard/global.lt3"
  return unless File.exist?(gfile)  # Hackish!! how is View.new called from create_view??

  live = Livetext.customize(call: ".nopara")
  live.xform_file(gfile)
  @globals = live.vars
end

#indexObject



37
38
39
# File 'lib/view.rb', line 37

def index
  dir + "index.html"
end

#local_indexObject



33
34
35
# File 'lib/view.rb', line 33

def local_index
  dir + "/remote/index.html"
end

#recent?(file) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
52
53
# File 'lib/view.rb', line 49

def recent?(file)
  File.mtime(file) > File.mtime("#{self.dir()}/last_published")
rescue
  true
end

#to_sObject



41
42
43
# File 'lib/view.rb', line 41

def to_s
  @name
end