Class: Scms::PageOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/scms/scms-pageoptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, website, pageconfig, siteConfig) ⇒ PageOptions

Returns a new instance of PageOptions.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/scms/scms-pageoptions.rb', line 40

def initialize (name, website, pageconfig, siteConfig)  
  @name = name
  @template = siteConfig["template"]
  @url = "#{name}.html"
  @title = name
  @keywords = ""
  @description = ""
  @resource = Hash.new
  @handler = nil

  if pageconfig != nil
    @template = pageconfig["template"] unless pageconfig["template"] == nil
    
    @url = "#{name}/index.html" if pageconfig["cleanurl"] == true
    @url = pageconfig["generate"] if pageconfig["generate"] != nil #depreciated
    @url = pageconfig["url"] if pageconfig["url"] != nil

    @title = pageconfig["title"] unless pageconfig["title"] == nil
    @keywords = pageconfig["keywords"] if pageconfig["keywords"] != nil
    @description = pageconfig["description"] if pageconfig["description"] != nil
    @handler = pageconfig["handler"]
    @resource = getResource(website, pageconfig["resource"])
  end
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



6
7
8
# File 'lib/scms/scms-pageoptions.rb', line 6

def description
  @description
end

#handlerObject

Returns the value of attribute handler.



6
7
8
# File 'lib/scms/scms-pageoptions.rb', line 6

def handler
  @handler
end

#keywordsObject

Returns the value of attribute keywords.



6
7
8
# File 'lib/scms/scms-pageoptions.rb', line 6

def keywords
  @keywords
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/scms/scms-pageoptions.rb', line 6

def name
  @name
end

#resourceObject

Returns the value of attribute resource.



6
7
8
# File 'lib/scms/scms-pageoptions.rb', line 6

def resource
  @resource
end

#templateObject

Returns the value of attribute template.



6
7
8
# File 'lib/scms/scms-pageoptions.rb', line 6

def template
  @template
end

#titleObject

Returns the value of attribute title.



6
7
8
# File 'lib/scms/scms-pageoptions.rb', line 6

def title
  @title
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/scms/scms-pageoptions.rb', line 6

def url
  @url
end

Instance Method Details

#getResource(website, resource) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/scms/scms-pageoptions.rb', line 66

def getResource(website, resource)
    ymlresource = Hash.new
    if resource != nil
        resourcepath = File.join(website, resource)
        if File.exists?(resourcepath)
            #ScmsUtils.log( "_Resource found: #{pageOptions.resource}_" )
            begin
                ymlresource = YAML.load_file(resourcepath)
            rescue Exception=>e
                ScmsUtils.errLog(e.message)
                ScmsUtils.log(e.backtrace.inspect)
            end
        else
            ScmsUtils.errLog("Resource not found: #{resource}")
            ScmsUtils.writelog("::Resource not found #{resource}", website)
            ScmsUtils.writelog("type NUL > #{resourcepath}", website)
        end
    end
    return ymlresource
end