scms 3.1.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODViYzEwYjJkYmM3OGFlMDY0ZGI3Y2U3ZTQ1YjVjMDBhOWRmMDYwMg==
4
+ NTQyZDcwZTdiYzYyZmM4YzQyY2Q2NTNlMWRkNjQ0ZjQ1ZDFkNTVkNA==
5
5
  data.tar.gz: !binary |-
6
- ODQ2Y2JhMDVjMmNkOGY0MGU3M2Q1OTU1MWM2N2VlZTBjNDEyNDNhYQ==
6
+ YWNhMDA4Y2QxOGRmODJkYTExZDE2N2UzMWNiYjI3M2M5ZWM5ZWMyYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjBlYTdiYTIzY2Y4NjQyMDIyMDU0MzNjZTQ5Mjg5NGVmMzEzZGUzNWM1ODlj
10
- NGM3NTQ3YjM3NGYwNDc0OGRhNmI4YzhjNmY1M2ZhY2U3Nzk1ODRjZGIxZTA4
11
- YjkxMDhhNzdkNmJmNmIxMWM3MmFjYWE2YjZjNDcwY2RmZmNlOGI=
9
+ YTdkNTc3ZjNmMTgxNjNlNGVjZGRlZDdiMWEwMzIwMzY4YzBhMDQwZGIwYjQ1
10
+ ZjZmODY5NDliMzg3ZDA5YjRlMmVkZWM3ZTJhMjBjM2IxYzgyNmVmYzgwZjUw
11
+ MTI4MWFjYTA0YTU1OTM4ZmJhOGRjZjljOWY0NGQxN2UwZWMyZjQ=
12
12
  data.tar.gz: !binary |-
13
- YzRiMmZmZGZkOGU0Y2Y4YThhZWRmMzhiODdlZjgwNGZkYzVjOGNhMWY5OWE5
14
- MTYxMjAxNGNmY2FjOTZmZDVlZDg5MjFjZDM3MGJhYmM1MzcyZTc5NTk4ZmYz
15
- NzRmMmQxOTUxYmZiNmFkZWVjZTgzNDg3NTk5MDY4ZWQ5YmY5ZTA=
13
+ NGVmNjYzYmUzN2ZkNGRhMmIzNTRkM2M0MjY0NzBmYjgzZjYzYjYyNDliYmZk
14
+ NTJiNjkxZTZhZDEwYjI3NDFjY2U1YjYyOTY0YjY0ZjA1NDA5ZWFiMDVkNTQw
15
+ ZTM1ZTk1OTkzNTViZWQ2ZTU5NWY5NTkzYmM1NDg1OWFjMDZkZDM=
data/bin/scms CHANGED
@@ -11,6 +11,7 @@ require 'optparse'
11
11
  require 'fileutils'
12
12
  require 'Scms'
13
13
  require "scms/version"
14
+ require 'scms/scms-watcher.rb'
14
15
  require 'scms/scms-httpserver.rb'
15
16
 
16
17
  class String
@@ -62,7 +63,7 @@ optparse = OptionParser.new do|opts|
62
63
  options[:configdir] = c
63
64
  end
64
65
 
65
- options[:mode] = "pub"
66
+ options[:mode] = nil
66
67
  opts.on( '-m', '--mode Mode', 'CMS or Publish (for use with Air-Monkey: http://ipassexam.github.io/Air-Monkey/)' ) do|m|
67
68
  options[:mode] = m
68
69
  end
@@ -90,13 +91,11 @@ Folders = {
90
91
  :config => (options[:configdir] or ENV["SCMS_CONFIG_FOLDER"] or options[:website]),
91
92
  :assets => File.join(root_folder, "assets")
92
93
  }
93
- # These can be used in the bootstrap.rb
94
+ # Globals: These can be used in the bootstrap.rb
94
95
  $website = Folders[:website]
95
96
  $watch = options[:watch]
96
97
  $cmsmode = options[:mode] == "cms"
97
98
 
98
- configfile = File.join(Folders[:website], "_config.yml")
99
-
100
99
  # ScmsUtils.log "System root folder = #{Folders[:root]}"
101
100
  # ScmsUtils.log "Website folder = #{Folders[:website]}"
102
101
  # ScmsUtils.log "Destination dir = #{Folders[:destination]}"
@@ -126,44 +125,19 @@ else
126
125
  FileUtils.rm(monkeyhook) if File.exist?(monkeyhook) && options[:publish]
127
126
  end
128
127
 
129
- Scms.build(Folders[:website], Folders[:config], options[:mode])
128
+ settings = Scms.getsettings(Folders[:config])
129
+ Scms.sassall(Folders[:website])
130
+ Scms.bundle(settings, Folders[:website])
131
+ Scms.build(Folders[:website], settings, options[:mode])
130
132
  Scms.copywebsite(Folders[:website], Folders[:destination]) if Folders[:destination] != ''
131
133
 
132
134
  if options[:watch]
133
- require "filewatcher"
134
- # I dont really want to use filewatcher but I can't get listen to watch the config file
135
- # I'd use filewatcher to monitor directories but it crashes if a file id deleted
136
- watcher = Thread.new {
137
- puts "Watching yam files"
138
- FileWatcher.new(["_config.yml"]).watch do |filename|
139
- puts "Updated " + filename
140
- Scms.build(Folders[:website], Folders[:config], options[:mode])
141
- end
142
- }
143
-
144
- psst = []
145
- #psst.push("_config.yml")# if File.exists?(configfile)
146
- psst.push("_views") if File.directory? "_views"
147
- psst.push("_layouts") if File.directory? "_layouts"
148
- psst.push("_templates") if File.directory? "_templates"
149
- psst.push("_source") if File.directory? "_source"
150
- psst.push("_resources") if File.directory? "_resources"
151
-
152
- require "listen"
153
- puts "Setting up listen"
154
- listener = Listen.to(psst, force_polling: true) do |modified, added, removed|
155
- puts "modified: #{modified}" if modified.length > 0
156
- puts "added: #{added}" if added.length > 0
157
- puts "removed: #{removed}" if removed.length > 0
158
-
159
- Scms.build(Folders[:website], Folders[:config], options[:mode]) if modified.length > 0
160
- end
161
- listener.start # not blocking
162
- sleep unless options[:server]
135
+ ScmsWatcher.watch(settings, options, Folders[:config])
136
+ sleep unless options[:server]
163
137
  end
164
138
 
165
139
  if options[:server]
166
- ScmsServer.start(Folders[:website], options[:port])
140
+ ScmsServer.start(Folders[:website], options[:port])
167
141
  end
168
142
 
169
143
  if options[:publish]
data/lib/scms/s3deploy.rb CHANGED
@@ -4,7 +4,7 @@ module S3Deploy
4
4
 
5
5
  def S3Deploy.sync(pub, config, mimetypefile)
6
6
  #yamlpath=File.join(config, "_config.yml")
7
- #scmsSettings = ScmsUtils.getsettings(yamlpath)
7
+ #scmsSettings = ScmsUtils.readyaml(yamlpath)
8
8
 
9
9
  ENV["S3CONF"] = config
10
10
  ENV["AWS_CALLING_FORMAT"] = "SUBDOMAIN"
@@ -2,6 +2,10 @@ module ScmsHelpers
2
2
  require 'find'
3
3
 
4
4
  def ScmsHelpers.isActive(pagename, activepage)
5
+ return active = "active" if activepage == pagename
6
+ end
7
+
8
+ def ScmsHelpers.isActiveIfContains(pagename, activepage)
5
9
  return active = "active" if activepage.include? pagename
6
10
  end
7
11
 
@@ -19,8 +19,8 @@ module ScmsUtils
19
19
  false
20
20
  end
21
21
 
22
- def ScmsUtils.getsettings(yamlpath)
23
- ScmsUtils.log("Loading Config: #{ScmsUtils.uriEncode("file:///#{yamlpath}")}")
22
+ def ScmsUtils.readyaml(yamlpath)
23
+ ScmsUtils.log("Loading yaml: #{ScmsUtils.uriEncode("file:///#{yamlpath}")}")
24
24
  config = nil
25
25
 
26
26
  ##http://snk.tuxfamily.org/log/yaml-json-validation-kwalify-ruby19.html
@@ -0,0 +1,74 @@
1
+ module ScmsWatcher
2
+ require 'fileutils'
3
+ require 'filewatcher'
4
+ require 'pathname'
5
+ require 'listen'
6
+
7
+ def ScmsWatcher.watch(settings, options, configdir)
8
+ watcher = Thread.new {
9
+ configfile = File.join(configdir, "_config.yml")
10
+ FileWatcher.new([configfile]).watch do |filename|
11
+ puts ""
12
+ puts "***********************************"
13
+ puts " Config Modification (_config.yml) "
14
+ puts "***********************************"
15
+ puts ""
16
+
17
+ settings = Scms.getsettings(configdir)
18
+ Scms.bundle(settings, Folders[:website])
19
+ Scms.build(Folders[:website], settings, options[:mode])
20
+ end
21
+ }
22
+
23
+ psst = []
24
+ psst.push("_views") if File.directory? "_views" # .html .htm .md .xml .erb, etc
25
+ psst.push("_layouts") if File.directory? "_layouts" # .html .htm .erb
26
+ psst.push("_templates") if File.directory? "_templates" # .html .htm .erb
27
+ psst.push("_resources") if File.directory? "_resources" # .yml
28
+ psst.push("_source") if File.directory? "_source" # .scss .css .js
29
+
30
+ puts "Listening to #{psst}"
31
+ listener = Listen.to(psst, force_polling: true) do |modified, added, removed|
32
+ # puts "modified: #{modified}" if modified.length > 0
33
+ # puts "added: #{added}" if added.length > 0
34
+ # puts "removed: #{removed}" if removed.length > 0
35
+
36
+ if modified.length > 0
37
+ sassfile = false
38
+ bundlefile = false
39
+ buildfile = true
40
+
41
+ modified.each{|filename|
42
+ modifiedfile = Pathname.new(filename).relative_path_from(Pathname.new(Folders[:website])).to_s
43
+ ext = File.extname(modifiedfile)
44
+
45
+ puts ""
46
+ puts "***********************************************"
47
+ puts " Modified: #{modifiedfile}"
48
+ puts "***********************************************"
49
+ puts ""
50
+
51
+ if modifiedfile.start_with?('_source/')
52
+ bundlefile = true
53
+ buildfile = false
54
+ end
55
+
56
+ if ext == ".scss"
57
+ sassfile = true
58
+ bundlefile = false
59
+ buildfile = false
60
+ break
61
+ end
62
+ }
63
+
64
+ Scms.sassall(Folders[:website]) if sassfile
65
+ Scms.bundle(settings, Folders[:website]) if bundlefile
66
+ Scms.build(Folders[:website], settings, options[:mode]) if buildfile
67
+ end
68
+ end
69
+ listener.start # not blocking
70
+ listener.ignore! /\.png/
71
+ listener.ignore! /\.gif/
72
+ listener.ignore! /\.jpg/
73
+ end
74
+ end
data/lib/scms/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Scms
2
- VERSION = "3.1.1"
2
+ VERSION = "3.2.0"
3
3
  end
data/lib/scms.rb CHANGED
@@ -15,20 +15,26 @@ module Scms
15
15
 
16
16
  include YAML
17
17
 
18
- def Scms.build(website, config, mode)
19
- @website = website
18
+ def Scms.getsettings(configdir)
19
+ yamlpath=File.join(configdir, "_config.yml")
20
+ settings = ScmsUtils.readyaml(yamlpath)
21
+ if settings
22
+ return settings
23
+ else
24
+ ScmsUtils.errLog("Config is empty")
25
+ end
26
+ end
27
+
28
+ def Scms.build(website, settings, mode = "pub")
20
29
  @mode = mode
21
30
  #ScmsUtils.log("Mode: #{mode}")
22
31
 
23
- ScmsUtils.boldlog("Compiling #{@website}")
24
- Scms.sassall(File.join(@website))
32
+ ScmsUtils.boldlog("Compiling #{website}")
25
33
 
26
- yamlpath=File.join(config, "_config.yml")
27
- settings = ScmsUtils.getsettings(yamlpath)
28
34
  if settings
29
35
  #Bootstrap here
30
36
  if settings["bootstrap"] != nil
31
- bootstrap = File.join(@website, settings["bootstrap"])
37
+ bootstrap = File.join(website, settings["bootstrap"])
32
38
  #ScmsUtils.log("Bootstrap is: #{settings["bootstrap"]}")
33
39
  if File.exists?(bootstrap)
34
40
  begin
@@ -39,45 +45,33 @@ module Scms
39
45
  end
40
46
  else
41
47
  ScmsUtils.errLog("Bootstrap does not exist #{settings["bootstrap"]}")
42
- ScmsUtils.writelog("::Bootstrap does not exist #{settings["bootstrap"]}", @website)
43
- ScmsUtils.writelog("type NUL > #{bootstrap}", @website)
48
+ ScmsUtils.writelog("::Bootstrap does not exist #{settings["bootstrap"]}", website)
49
+ ScmsUtils.writelog("type NUL > #{bootstrap}", website)
44
50
  end
45
51
  end
46
-
47
- Scms.parsepages(settings)
52
+ Scms.parsepages(settings, website)
48
53
  else
49
54
  ScmsUtils.errLog("Config is empty")
50
55
  end
51
56
 
52
57
  ScmsUtils.boldlog("Built website:")
53
- ScmsUtils.log(ScmsUtils.uriEncode("file:///#{@website}"))
58
+ ScmsUtils.log(ScmsUtils.uriEncode("file:///#{website}"))
54
59
  end
55
60
 
56
- def Scms.parsepages(settings)
57
- bundles = Scms.bundle(settings["bundles"])
61
+ def Scms.parsepages(settings, website)
58
62
  # build views from templates
59
- @template = settings["template"]
60
63
 
61
64
  if settings["pages"] != nil
62
- # Build navigation
63
- navigation = Array.new
64
- settings["pages"].each do |pagedata|
65
- if pagedata != nil
66
- pagedata.each do |pageoptions|
67
- pagename = pageoptions[0]
68
- pageconfig = pageoptions[1]
69
- pageurl = "about:blank"
70
- pageurl = pageconfig["generate"]
71
- pageurl = pageconfig["url"] unless pageconfig["url"] == nil
72
- navtext = pageconfig["navigation"]
73
- navmeta = pageconfig["navigation_meta"]
74
- navigation.push({"text" => navtext, "url" => pageurl, "pagename" => pagename, "meta" => navmeta}) unless navtext == nil
75
- end
76
- end
77
- end
65
+
66
+ # Build bundle model
67
+ bundlemodel = Scms.bundlemodel(settings)
68
+ # Build navigation model
69
+ navmodel = Scms.navmodel(settings)
70
+ #puts "navmodel: #{navmodel}"
78
71
 
79
72
  ScmsUtils.log("Compiling Pages:")
80
73
  settings["pages"].each do |pagedata|
74
+ #puts "pagedata: #{pagedata}"
81
75
  if pagedata != nil
82
76
  pagedata.each do |pageoptions|
83
77
  pagename = pageoptions[0]
@@ -85,15 +79,16 @@ module Scms
85
79
  pageurl = pageconfig["generate"]
86
80
  title = pagename
87
81
  title = pageconfig["title"] unless pageconfig["title"] == nil
88
- description = pageconfig["description"]
89
- keywords = pageconfig["keywords"]
90
-
91
- skin = @template
82
+ description = ""
83
+ description = pageconfig["description"] if pageconfig["description"] != nil
84
+ keywords = ""
85
+ keywords = pageconfig["keywords"] if pageconfig["keywords"] != nil
86
+ skin = settings["template"]
92
87
  skin = pageconfig["template"] unless pageconfig["template"] == nil
93
88
 
94
89
  resource = Hash.new
95
90
  if pageconfig["resource"] != nil
96
- resourcepath = File.join(@website, pageconfig["resource"])
91
+ resourcepath = File.join(website, pageconfig["resource"])
97
92
  if File.exists?(resourcepath)
98
93
  #ScmsUtils.log( "_Resource found: #{pageconfig["resource"]}_" )
99
94
  begin
@@ -104,14 +99,14 @@ module Scms
104
99
  end
105
100
  else
106
101
  ScmsUtils.errLog("Resource not found: #{pageconfig["resource"]}")
107
- ScmsUtils.writelog("::Resource not found #{pageconfig["resource"]}", @website)
108
- ScmsUtils.writelog("type NUL > #{resourcepath}", @website)
102
+ ScmsUtils.writelog("::Resource not found #{pageconfig["resource"]}", website)
103
+ ScmsUtils.writelog("type NUL > #{resourcepath}", website)
109
104
  end
110
105
  end
111
106
 
112
107
  hasHandler = false
113
108
  if pageconfig["handler"] != nil
114
- handlerpath = File.join(@website, pageconfig["handler"])
109
+ handlerpath = File.join(website, pageconfig["handler"])
115
110
  if File.exists?(handlerpath)
116
111
  ScmsUtils.log( "Handler found: #{pageconfig["handler"]}" )
117
112
  hasHandler = true
@@ -128,8 +123,8 @@ module Scms
128
123
  end
129
124
  else
130
125
  ScmsUtils.errLog("Handler not found: #{pageconfig["handler"]}")
131
- ScmsUtils.writelog("::Handler not found #{pageconfig["handler"]}", @website)
132
- ScmsUtils.writelog("type NUL > #{handlerpath}", @website)
126
+ ScmsUtils.writelog("::Handler not found #{pageconfig["handler"]}", website)
127
+ ScmsUtils.writelog("type NUL > #{handlerpath}", website)
133
128
  end
134
129
  end
135
130
 
@@ -143,7 +138,7 @@ module Scms
143
138
 
144
139
  #puts "viewname: #{viewname}, viewqs: #{viewqs}"
145
140
 
146
- viewpath = File.join(@website, viewname)
141
+ viewpath = File.join(website, viewname)
147
142
 
148
143
 
149
144
  if File.exists?(viewpath)
@@ -167,7 +162,7 @@ module Scms
167
162
  :title => title,
168
163
  :url => pageurl,
169
164
  :data => pagedata,
170
- :rootdir => @website,
165
+ :rootdir => website,
171
166
  :resource => resource,
172
167
  :view => {
173
168
  :name => viewname,
@@ -213,8 +208,8 @@ module Scms
213
208
  end
214
209
  else
215
210
  ScmsUtils.errLog("View not found: #{view[0]} - #{view[1]} [#{viewpath}]")
216
- ScmsUtils.writelog("::View not found: #{view[0]} - #{view[1]} [#{viewpath}]", @website)
217
- ScmsUtils.writelog("type NUL > #{viewpath}", @website)
211
+ ScmsUtils.writelog("::View not found: #{view[0]} - #{view[1]} [#{viewpath}]", website)
212
+ ScmsUtils.writelog("type NUL > #{viewpath}", website)
218
213
  end
219
214
  #ScmsUtils.log( "view = #{view[0]} - #{view[1]}" )
220
215
  end
@@ -238,32 +233,32 @@ module Scms
238
233
  :views => views,
239
234
  :resource => resource,
240
235
  :config => pageconfig,
241
- :bundles => bundles,
242
- :navigation => navigation,
236
+ :bundles => bundlemodel,
237
+ :navigation => navmodel,
243
238
  :data => pagedata,
244
- :rootdir => @website,
239
+ :rootdir => website,
245
240
  :monkeyhook => monkeyhook,
246
241
  :livereload => livereload
247
242
  }
248
243
 
249
244
  break if pageconfig["generate"] == nil
250
245
 
251
- erb = File.join(@website, skin)
252
- out = File.join(@website, File.join(pageconfig["generate"].sub('~/','')))
246
+ erb = File.join(website, skin)
247
+ out = File.join(website, File.join(pageconfig["generate"].sub('~/','')))
253
248
 
254
- ScmsUtils.successLog("#{pageurl}")
249
+ #ScmsUtils.log("Generating: #{pageurl} with #{skin}")
255
250
 
256
251
  if File.exists?(erb)
257
252
  pubsubdir = File.dirname(out)
258
253
  Dir.mkdir(pubsubdir, 755) unless File::directory?(pubsubdir)
259
254
 
260
255
  erbtemplate = File.read(erb)
261
- #erbtemplate = erbtemplate.gsub('data.','page.')#lagasy fix
262
- #File.open(erb, 'w') {|f| f.write(erbtemplate) }#lagasy fix
263
256
 
257
+ #puts "pagemodel: #{pagemodel}"
258
+ #html = ""
264
259
  html = Scms.parsetemplate(erbtemplate, pagemodel)
265
260
 
266
- html = html.gsub('~/', ScmsUtils.uriEncode("file:///#{@website}/")) if @mode == "cms"
261
+ html = html.gsub('~/', ScmsUtils.uriEncode("file:///#{website}/")) if @mode == "cms"
267
262
  websiteroot = '/'
268
263
  websiteroot = settings["url"] unless settings["rooturl"] == nil
269
264
 
@@ -276,9 +271,11 @@ module Scms
276
271
  end
277
272
  else
278
273
  ScmsUtils.errLog("Template doesn't exist: #{skin}")
279
- ScmsUtils.writelog("::Template doesn't exist #{skin}", @website)
280
- ScmsUtils.writelog("type NUL > #{erb}", @website)
274
+ ScmsUtils.writelog("::Template doesn't exist #{skin}", website)
275
+ ScmsUtils.writelog("type NUL > #{erb}", website)
281
276
  end
277
+
278
+ ScmsUtils.successLog("Generated: #{pageurl}")
282
279
  end
283
280
  end
284
281
  #ScmsUtils.log( out )
@@ -288,26 +285,79 @@ module Scms
288
285
 
289
286
  def Scms.parsetemplate(template, hash = Hash.new)
290
287
  result = ""
291
- OpenStruct.new(hash)
288
+ if template != nil
289
+ begin
290
+ if hash.class == OpenStruct
291
+ page = hash
292
+ else
293
+ page = OpenStruct.new(hash)
294
+ end
295
+
296
+ erb = ERB.new(template)
297
+ result = erb.result(page.instance_eval { binding })
298
+ rescue StandardError => e
299
+ ScmsUtils.errLog("Critical Error: Could not parse template")
300
+ #ScmsUtils.errLog(e.message)
301
+ #puts e.inspect
292
302
 
293
- if hash.class == OpenStruct
294
- page = hash
303
+ result = "Invalid Keys in Template\n\n"
304
+ result += "Valid Keys are:\n"
305
+ hash.each do |key, value|
306
+ result += "- page.#{key}\n"
307
+ puts "nil value foy key: #{key}" if value == nil
308
+ singleton_class.send(:define_method, key) { value }
309
+ end
310
+
311
+ result += "\n\n"
312
+ result += template
313
+ rescue Exception => e
314
+ puts "Problem with template - check property exists"
315
+ end
295
316
  else
296
- page = OpenStruct.new(hash)
297
- end
298
-
299
- begin
300
- result = ERB.new(template).result(page.instance_eval { binding })
301
- rescue Exception => e
302
- ScmsUtils.errLog("Critical Error: Could not parse template")
303
- ScmsUtils.errLog(e.message)
317
+ ScmsUtils.log("Error: Can not parse template. Template is empty")
304
318
  end
305
319
 
306
320
  return result
307
321
  end
308
322
 
309
- def Scms.bundle(bundleConfig)
310
- bundles = Hash.new
323
+ def Scms.bundlemodel(settings)
324
+ puts "Bundeling Assets"
325
+ bundlemodel = Hash.new
326
+ bundleConfig = settings["bundles"]
327
+ if bundleConfig != nil
328
+ bundleConfig.each do |bundle|
329
+ #ScmsUtils.log( "bundle (#{bundle.class}) = #{bundle}" )
330
+ bundle.each do |option|
331
+ name = option[0]
332
+ bundleName = File.join(option[1]["generate"])
333
+ bundlemodel[name] = bundleName
334
+ end
335
+ end
336
+ end
337
+ return bundlemodel
338
+ end
339
+
340
+ def Scms.navmodel(settings)
341
+ navmodel = Array.new
342
+ settings["pages"].each do |pagedata|
343
+ if pagedata != nil
344
+ pagedata.each do |pageoptions|
345
+ pagename = pageoptions[0]
346
+ pageconfig = pageoptions[1]
347
+ pageurl = "about:blank"
348
+ pageurl = pageconfig["generate"]
349
+ pageurl = pageconfig["url"] unless pageconfig["url"] == nil
350
+ navtext = pageconfig["navigation"]
351
+ navmeta = pageconfig["navigation_meta"]
352
+ navmodel.push({"text" => navtext, "url" => pageurl, "pagename" => pagename, "meta" => navmeta}) unless navtext == nil
353
+ end
354
+ end
355
+ end
356
+ return navmodel
357
+ end
358
+
359
+ def Scms.bundle(settings, website)
360
+ bundleConfig = settings["bundles"]
311
361
  if bundleConfig != nil
312
362
 
313
363
  bundleConfig.each do |bundle|
@@ -315,7 +365,6 @@ module Scms
315
365
  bundle.each do |option|
316
366
  name = option[0]
317
367
  bundleName = File.join(option[1]["generate"])
318
- bundles[name] = bundleName
319
368
  ScmsUtils.boldlog("Bundeling:")
320
369
 
321
370
  content = ""
@@ -324,7 +373,7 @@ module Scms
324
373
  if files != nil
325
374
  files.each do |asset|
326
375
  assetList += " - #{asset}\n"
327
- assetdir = File.join(@website, asset)
376
+ assetdir = File.join(website, asset)
328
377
  if File::exists?(assetdir)
329
378
  #try catch for permisions
330
379
  begin
@@ -335,14 +384,14 @@ module Scms
335
384
  end
336
385
  else
337
386
  ScmsUtils.errLog("Asset file doesn't exists: #{asset}")
338
- ScmsUtils.writelog("::Asset file doesn't exists: #{asset}", @website)
339
- ScmsUtils.writelog("type NUL > #{assetdir}", @website)
387
+ ScmsUtils.writelog("::Asset file doesn't exists: #{asset}", website)
388
+ ScmsUtils.writelog("type NUL > #{assetdir}", website)
340
389
  end
341
390
  end
342
391
  ScmsUtils.log("#{assetList}")
343
392
 
344
- bundleFullPath = File.join(@website, bundleName)
345
- bundleDir = File.dirname(File.join(@website, bundleName))
393
+ bundleFullPath = File.join(website, bundleName)
394
+ bundleDir = File.dirname(File.join(website, bundleName))
346
395
  begin
347
396
  Dir.mkdir(bundleDir, 755) unless File::directory?(bundleDir)
348
397
  File.open(bundleFullPath, 'w') {|f| f.write(content) }
@@ -362,19 +411,18 @@ module Scms
362
411
  end
363
412
  end
364
413
  end
365
- return bundles
366
414
  end
367
415
 
368
- def Scms.sassall(crunchDir)
416
+ def Scms.sassall(website)
369
417
  ScmsUtils.log("Minimising Sass Files (.scss)")
370
- Dir.chdir(crunchDir) do
418
+ Dir.chdir(website) do
371
419
  Dir.glob("**/*.{scss}").each do |asset|
372
- Scms.sass(asset)
420
+ Scms.sass(asset, website)
373
421
  end
374
422
  end
375
423
  end
376
424
 
377
- def Scms.sass(asset)
425
+ def Scms.sass(asset, website)
378
426
  if File.exists?(asset)
379
427
  begin
380
428
  template = File.read(asset)
@@ -393,8 +441,8 @@ module Scms
393
441
  end
394
442
  else
395
443
  ScmsUtils.errLog("Sass file doesn't exists: #{asset}")
396
- ScmsUtils.writelog("::Sass file doesn't exist #{asset}", @website)
397
- ScmsUtils.writelog("type NUL > #{asset}", @website)
444
+ ScmsUtils.writelog("::Sass file doesn't exist #{asset}", website)
445
+ ScmsUtils.writelog("type NUL > #{asset}", website)
398
446
  end
399
447
  end
400
448
 
@@ -428,9 +476,4 @@ module Scms
428
476
  ScmsUtils.log("Output to: #{ScmsUtils.uriEncode("file:///#{pub}")}")
429
477
  end
430
478
  end
431
-
432
- # def Scms.upgrade(website)
433
- # File.rename("config.yml", "_config.yml") if File.exists? File.join(website, "config.yml")
434
- # File.rename("s3config.yml", "_s3config.yml") if File.exists? File.join(website, "s3config.yml")
435
- # end
436
479
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Courtenay Probert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-17 00:00:00.000000000 Z
11
+ date: 2013-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cprobert-s3sync
@@ -192,6 +192,7 @@ files:
192
192
  - lib/scms/scms-helpers.rb
193
193
  - lib/scms/scms-httpserver.rb
194
194
  - lib/scms/scms-utils.rb
195
+ - lib/scms/scms-watcher.rb
195
196
  - lib/scms/scms-xmlhandler.rb
196
197
  - lib/scms/version.rb
197
198
  - lib/scms/yui.rb