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.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/scms/scms-pageoptions.rb', line 44

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

  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"], pageconfig)
    @allowEdit = pageconfig["allowEdit"] if pageconfig["allowEdit"] != nil
  end
end

Instance Attribute Details

#allowEditObject

Returns the value of attribute allowEdit.



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

def allowEdit
  @allowEdit
end

#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, config) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/scms/scms-pageoptions.rb', line 72

def getResource(website, resource, config)
    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
    else
      ymlresource = config.dup
      ymlresource.delete("view")
      ymlresource.delete("views")
      ymlresource.delete("resource")
      ymlresource.delete("bundles")
      ymlresource.delete("navigation")
      ymlresource.delete("monkeyhook")
      ymlresource.delete("livereload")
    end
    return ymlresource
end