scms 1.9.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/assets/{blank-template/scripts/air-monkey-hook.js → air-monkey-hook.js} +0 -0
- data/assets/blank-template/_config.yml +19 -8
- data/assets/blank-template/_templates/skin.erb.html +17 -16
- data/assets/yuicompressor/readme +1 -0
- data/bin/scms +13 -8
- data/lib/scms/s3deploy.rb +16 -13
- data/lib/scms/scms-utils.rb +28 -3
- data/lib/scms/version.rb +1 -1
- data/lib/scms/yui.rb +31 -0
- data/lib/scms.rb +152 -208
- data/scms.gemspec +0 -1
- metadata +5 -18
- data/assets/blank-template/_templates/menu.xml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdb6469369b7419d7255f4d534c74bf8b49034bf
|
4
|
+
data.tar.gz: f3c2e3658b9f75017551ef6b80b2202f52fdbce5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ace91b95b0605de4079bd3e251b8fc0b4bca076695d49dfa45110f3751b9d30ad84656d885f447e5706b0cc36bfee15ac1a86d490229ded12dfd3943d7683ca
|
7
|
+
data.tar.gz: 8ceeec4bfdb74813411668b2403ee1eec99f2336dc3876f2cca6bfa780e8ec48dd20f95d2026ab70c71eef11f5dbe28ca244c75cc8d5bd6d21e0e5a8653f3ee8
|
data/.gitignore
CHANGED
File without changes
|
@@ -1,25 +1,36 @@
|
|
1
|
-
template: _templates/skin.erb.html
|
2
|
-
|
1
|
+
template: _templates/skin.erb.html # The website skin (erb template)
|
2
|
+
#url: http://www.mywebsite.com/ #Whats the website root when published - All references in html ~/ will be replaced with this
|
3
|
+
# Define your pages here
|
3
4
|
pages:
|
4
5
|
- index:
|
5
|
-
generate: index.html
|
6
|
-
|
6
|
+
generate: ~/index.html
|
7
|
+
navigation: Home
|
8
|
+
title: My Homepage
|
9
|
+
description: Meta description
|
10
|
+
keywords: "CMS, S3, Ruby"
|
11
|
+
views:
|
7
12
|
intro: _views/home-intro.html
|
8
13
|
main: _views/home-main.html
|
9
14
|
- about:
|
10
|
-
generate: about.html
|
11
|
-
|
15
|
+
generate: ~/about.html
|
16
|
+
navigation: About
|
17
|
+
views:
|
12
18
|
intro: _views/about-intro.html
|
13
19
|
main: _views/about-main.html
|
20
|
+
- contact: #Pageless for nav only
|
21
|
+
navigation: contact
|
22
|
+
navigation_meta: contactform
|
23
|
+
url: about:blank
|
14
24
|
|
25
|
+
# Define your bundles here (versioning is recomended if your caching assets)
|
15
26
|
bundles:
|
16
27
|
- script:
|
17
28
|
generate: scripts/bootstrap.min-v2.1.1.js
|
18
|
-
|
29
|
+
files:
|
19
30
|
- scripts/bootstrap.js
|
20
31
|
- style:
|
21
32
|
generate: stylesheets/style-1.0.css
|
22
|
-
|
33
|
+
files:
|
23
34
|
- stylesheets/bootstrap.css
|
24
35
|
- stylesheets/bootstrap-responsive.css
|
25
36
|
- stylesheets/style.css
|
@@ -2,14 +2,15 @@
|
|
2
2
|
<html lang="en">
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8">
|
5
|
-
<title
|
5
|
+
<title><%= page.title %></title>
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7
|
-
<meta name="description" content="">
|
8
|
-
<meta name="
|
7
|
+
<meta name="description" content="<%= page.description %>">
|
8
|
+
<meta name="keywords" content="<%= page.keywords %>">
|
9
|
+
<meta name="author" content="Courtenay Probert">
|
9
10
|
|
10
|
-
<script src='scripts/jquery-1.8.2.min.js'></script>
|
11
|
-
|
12
|
-
|
11
|
+
<script src='~/scripts/jquery-1.8.2.min.js'></script>
|
12
|
+
<!-- Le styles -->
|
13
|
+
<link href='~/<%= page.bundles["style"] %>' rel="stylesheet">
|
13
14
|
<style type="text/css">
|
14
15
|
body {
|
15
16
|
padding-top: 60px;
|
@@ -38,15 +39,15 @@
|
|
38
39
|
<ul class="nav">
|
39
40
|
|
40
41
|
<%
|
41
|
-
@currentpagename =
|
42
|
+
@currentpagename = page.name
|
42
43
|
def isActive(pagename)
|
43
44
|
return active = "active" if @currentpagename == pagename
|
44
45
|
end
|
45
|
-
|
46
|
+
page.navigation.each do |nav|
|
46
47
|
%>
|
47
|
-
<li class='<%=isActive(nav[
|
48
|
-
<a href='<%= nav[
|
49
|
-
<%= nav[
|
48
|
+
<li class='<%=isActive(nav["pagename"])%> <%= nav["meta"]%>'>
|
49
|
+
<a href='<%= nav["url"] %>'>
|
50
|
+
<%= nav["text"] %>
|
50
51
|
</a>
|
51
52
|
</li>
|
52
53
|
<% end %>
|
@@ -78,18 +79,19 @@
|
|
78
79
|
|
79
80
|
<!-- Main hero unit for a primary marketing message or call to action -->
|
80
81
|
<div class="hero-unit">
|
81
|
-
|
82
|
+
<%= page.views["intro"] %>
|
82
83
|
</div>
|
83
84
|
|
84
85
|
<!-- Example row of columns -->
|
85
86
|
<div class="row">
|
86
|
-
|
87
|
+
<%= page.views["main"] %>
|
87
88
|
</div>
|
88
89
|
|
89
90
|
<hr>
|
90
91
|
|
91
92
|
<footer>
|
92
93
|
<p>© Company <%= Time.now.strftime("%Y") %></p>
|
94
|
+
<p>Built with <a href="http://cprobert.github.io/Static-CMS/">Static-CMS</a></p>
|
93
95
|
</footer>
|
94
96
|
|
95
97
|
</div> <!-- /container -->
|
@@ -97,8 +99,7 @@
|
|
97
99
|
<!-- Le javascript
|
98
100
|
================================================== -->
|
99
101
|
<!-- Placed at the end of the document so the pages load faster -->
|
100
|
-
<script src='
|
101
|
-
|
102
|
-
<%= data.monkeyhook %>
|
102
|
+
<script src='~/<%= page.bundles["script"] %>'></script>
|
103
|
+
<%= page.monkeyhook %>
|
103
104
|
</body>
|
104
105
|
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
Add yuicompressor-2.4.7.jar here to able to use the Yui minimise
|
data/bin/scms
CHANGED
@@ -55,17 +55,15 @@ end
|
|
55
55
|
optparse.parse!
|
56
56
|
|
57
57
|
#Set globals
|
58
|
-
$website = (options[:website].nil?) ? Dir.pwd : options[:website]
|
59
|
-
$html = (ENV["SCMS_HTML_OUT"] or "false")
|
60
|
-
#puts "html mode: #{$html}"
|
61
58
|
$stdout.sync = true
|
62
59
|
root_folder = File.expand_path("../", File.dirname(__FILE__))
|
60
|
+
website = (options[:website].nil?) ? Dir.pwd : options[:website]
|
63
61
|
Folders = {
|
64
62
|
:root => root_folder,
|
65
|
-
:website => File.join(
|
63
|
+
:website => File.join(website),
|
66
64
|
:pub => (ENV["SCMS_PUBLISH_FOLDER"] or options[:pub]),
|
67
65
|
:assets => File.join(root_folder, "assets"),
|
68
|
-
:config => (ENV["SCMS_CONFIG_FOLDER"] or File.join(
|
66
|
+
:config => (ENV["SCMS_CONFIG_FOLDER"] or File.join(website))
|
69
67
|
}
|
70
68
|
|
71
69
|
if options[:action] == "create"
|
@@ -79,6 +77,13 @@ if options[:action] == "create"
|
|
79
77
|
exit
|
80
78
|
end
|
81
79
|
|
80
|
+
monkeyhook = File.join(Folders[:website], "scripts", "air-monkey-hook.js")
|
81
|
+
if options[:mode] == "cms"
|
82
|
+
FileUtils.cp(File.join(Folders[:assets], "air-monkey-hook.js"), monkeyhook)
|
83
|
+
else
|
84
|
+
FileUtils.rm(monkeyhook) if File.exist?(monkeyhook)
|
85
|
+
end
|
86
|
+
|
82
87
|
#puts "System root folder = #{Folders[:root]}"
|
83
88
|
#puts "Website folder = #{Folders[:website]}"
|
84
89
|
#puts "Pub dir = #{Folders[:pub]}"
|
@@ -86,7 +91,7 @@ end
|
|
86
91
|
#puts "Mode = #{options[:mode]}"
|
87
92
|
|
88
93
|
raise "No website in folder #{Folders[:website]}" if !File::directory?(Folders[:website])
|
89
|
-
Scms.
|
90
|
-
|
91
|
-
|
94
|
+
Scms.upgrade(Folders[:website])
|
95
|
+
Scms.build(Folders[:website], Folders[:pub], Folders[:config], options[:mode])
|
96
|
+
Scms.copywebsite(Folders[:website], Folders[:pub]) if Folders[:pub] != nil
|
92
97
|
Scms.deploy(deployDir, Folders[:config]) if options[:action] == "deploy"
|
data/lib/scms/s3deploy.rb
CHANGED
@@ -3,25 +3,28 @@ module S3Deploy
|
|
3
3
|
require "scms/scms-utils.rb"
|
4
4
|
|
5
5
|
def S3Deploy.sync(pub, config)
|
6
|
-
|
6
|
+
yamlpath=File.join(config, "_config.yml")
|
7
|
+
settings = ScmsUtils.getsettings(yamlpath)
|
8
|
+
|
9
|
+
ScmsUtils.log( "Syncing with Amazon S3: #{settings['bucket']}" )
|
7
10
|
@pub = pub
|
8
11
|
ENV["S3CONF"] = config
|
9
12
|
ENV["AWS_CALLING_FORMAT"] = "SUBDOMAIN"
|
10
13
|
ENV["S3SYNC_MIME_TYPES_FILE"] = File.join(Folders[:root], "assets", "mime.types")
|
11
14
|
|
12
15
|
yamlpath=File.join(config, "_s3config.yml")
|
13
|
-
|
16
|
+
settings = YAML.load_file(yamlpath)
|
14
17
|
|
15
18
|
removeold = "--delete"
|
16
|
-
if
|
17
|
-
unless
|
19
|
+
if settings['clean'] != nil
|
20
|
+
unless settings['clean']
|
18
21
|
removeold = ""
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
22
25
|
exclude = "(\\.svn$)|(^_)"
|
23
|
-
if
|
24
|
-
exclude = "#{exclude}|(#{
|
26
|
+
if settings['ignore'] != nil
|
27
|
+
exclude = "#{exclude}|(#{settings["ignore"]})"
|
25
28
|
end
|
26
29
|
|
27
30
|
cmd = "s3sync"
|
@@ -31,27 +34,27 @@ module S3Deploy
|
|
31
34
|
Dir.glob("#{@pub}/_*/").each do |f|
|
32
35
|
privatedir = File.basename(f)
|
33
36
|
ScmsUtils.log( "Backing up #{privatedir} (private)" )
|
34
|
-
privateparams = "#{params} \"#{@pub}/#{privatedir}/\" #{
|
37
|
+
privateparams = "#{params} \"#{@pub}/#{privatedir}/\" #{settings['bucket']}:#{privatedir}/"
|
35
38
|
ScmsUtils.run(cmd, privateparams)
|
36
39
|
end
|
37
40
|
|
38
41
|
#Them deploy publid dir with caching
|
39
|
-
if
|
40
|
-
|
42
|
+
if settings['cache'] != nil
|
43
|
+
settings['cache'].each do |folder|
|
41
44
|
ScmsUtils.log( "Syncing #{folder}(public: caching: 1 year)" )
|
42
|
-
cacheparams = "#{params} --public-read --cache-control='max-age=31449600' \"#{@pub}/#{folder}/\" #{
|
45
|
+
cacheparams = "#{params} --public-read --cache-control='max-age=31449600' \"#{@pub}/#{folder}/\" #{settings['bucket']}:#{folder}/"
|
43
46
|
ScmsUtils.run(cmd, cacheparams)
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
47
50
|
ScmsUtils.log( "Syncing root (public)" )
|
48
|
-
roorparams = "#{params} --public-read \"#{@pub}/\" #{
|
51
|
+
roorparams = "#{params} --public-read \"#{@pub}/\" #{settings['bucket']}:/"
|
49
52
|
#Finnaly deploy all remaining files (except excludes)
|
50
53
|
ScmsUtils.run(cmd, roorparams)
|
51
54
|
ScmsUtils.successLog("Deployed :)")
|
52
55
|
|
53
|
-
if
|
54
|
-
ScmsUtils.log(
|
56
|
+
if settings['uri'] != nil
|
57
|
+
ScmsUtils.log(settings['uri'])
|
55
58
|
end
|
56
59
|
end
|
57
60
|
end
|
data/lib/scms/scms-utils.rb
CHANGED
@@ -3,6 +3,31 @@ module ScmsUtils
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'open-uri'
|
5
5
|
|
6
|
+
def ScmsUtils.getsettings(yamlpath)
|
7
|
+
ScmsUtils.log("Loading Config: #{ScmsUtils.uriEncode("file:///#{yamlpath}")}")
|
8
|
+
config = nil
|
9
|
+
|
10
|
+
if File.exist?(yamlpath)
|
11
|
+
tree = File.read(yamlpath)
|
12
|
+
begin
|
13
|
+
myconfig = ERB.new(tree).result()
|
14
|
+
#puts "Conf = #{myconfig}"
|
15
|
+
config = YAML.load(myconfig)
|
16
|
+
#config = YAML.load_file(yamlpath)
|
17
|
+
rescue Exception => e
|
18
|
+
ScmsUtils.errLog("Error Loading _config.yml (check there are no tabs in the file)")
|
19
|
+
ScmsUtils.log( "Verify your config")
|
20
|
+
ScmsUtils.log( "http://yaml-online-parser.appspot.com/")
|
21
|
+
ScmsUtils.errLog( e.message )
|
22
|
+
ScmsUtils.errLog( e.backtrace.inspect )
|
23
|
+
end
|
24
|
+
else
|
25
|
+
ScmsUtils.errLog("Config file does not exist: #{yamlpath}")
|
26
|
+
end
|
27
|
+
|
28
|
+
return config
|
29
|
+
end
|
30
|
+
|
6
31
|
def ScmsUtils.run(cmd, params)
|
7
32
|
if system("#{cmd} #{params}")
|
8
33
|
ScmsUtils.successLog( "#{cmd} ran successfully" )
|
@@ -13,7 +38,7 @@ module ScmsUtils
|
|
13
38
|
|
14
39
|
def ScmsUtils.errLog(msg)
|
15
40
|
if !msg.nil?
|
16
|
-
if
|
41
|
+
if ENV["SCMS_HTML_OUT"] == "true"
|
17
42
|
puts "<div style='color: red;'>#{ScmsUtils.txt_2_html(msg)}</div>"
|
18
43
|
else
|
19
44
|
puts msg
|
@@ -23,7 +48,7 @@ module ScmsUtils
|
|
23
48
|
|
24
49
|
def ScmsUtils.successLog(msg)
|
25
50
|
if !msg.nil?
|
26
|
-
if
|
51
|
+
if ENV["SCMS_HTML_OUT"] == "true"
|
27
52
|
puts "<div style='color: green;'>#{ScmsUtils.txt_2_html(msg)}</div>"
|
28
53
|
else
|
29
54
|
puts msg
|
@@ -33,7 +58,7 @@ module ScmsUtils
|
|
33
58
|
|
34
59
|
def ScmsUtils.log(msg)
|
35
60
|
if !msg.nil?
|
36
|
-
if
|
61
|
+
if ENV["SCMS_HTML_OUT"] == "true"
|
37
62
|
puts "<div>#{ScmsUtils.txt_2_html(msg)}</div>"
|
38
63
|
else
|
39
64
|
puts msg
|
data/lib/scms/version.rb
CHANGED
data/lib/scms/yui.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Yui
|
2
|
+
def Yui.eatall(crunchDir)
|
3
|
+
ScmsUtils.log( "Starting crunching CSS and JavaScript in:\n#{crunchDir}\n\n" )
|
4
|
+
Dir.chdir(crunchDir) do
|
5
|
+
Dir.glob("**/*.{css, js}").each do |asset|
|
6
|
+
#fullFileName = File.basename(asset)
|
7
|
+
#ScmsUtils.log( "Crunching #{fullFileName}" )
|
8
|
+
ext = File.extname(asset)
|
9
|
+
Yui.compress(asset, ext)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def Yui.compress(asset, ext)
|
15
|
+
if File.exists?(asset)
|
16
|
+
#ScmsUtils.log( " Encoding: #{asset.encoding}" )
|
17
|
+
enc = "--charset utf-8"
|
18
|
+
enc = ""
|
19
|
+
cmd = "java"
|
20
|
+
params = "-jar \"#{File.join(Folders[:assets], "yuicompressor", "yuicompressor-2.4.7.jar")}\" #{enc} --type #{ext.gsub(".","")} \"#{asset}\" -o \"#{asset}\""
|
21
|
+
##Need to check if asset exists
|
22
|
+
if system("#{cmd} #{params}")
|
23
|
+
ScmsUtils.log( "_Crunched #{File.basename(asset)}_" )
|
24
|
+
else
|
25
|
+
ScmsUtils.errLog( "Error crunching: #{asset}" )
|
26
|
+
end
|
27
|
+
else
|
28
|
+
ScmsUtils.errLog( "#{asset} does not exist" )
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/scms.rb
CHANGED
@@ -13,53 +13,21 @@ module Scms
|
|
13
13
|
|
14
14
|
include YAML
|
15
15
|
|
16
|
-
def Scms.build(pub, config, mode)
|
17
|
-
@
|
18
|
-
@cleanpub = false
|
19
|
-
if pub != nil
|
20
|
-
@pub = pub
|
21
|
-
@cleanpub = true
|
22
|
-
end
|
23
|
-
|
24
|
-
@configdir = config
|
16
|
+
def Scms.build(website, pub, config, mode)
|
17
|
+
@website = website
|
25
18
|
@mode = mode
|
26
19
|
#ScmsUtils.log("Mode: #{mode}")
|
27
20
|
|
28
|
-
|
29
|
-
|
30
|
-
if (Dir.exists? File.join($website, "public"))
|
31
|
-
@source = File.join($website, "public")
|
32
|
-
@pub = File.join($website, "_site") if pub == nil
|
33
|
-
end
|
34
|
-
|
35
|
-
ScmsUtils.log("Source #{@source}")
|
36
|
-
Scms.sassall(@source)
|
21
|
+
ScmsUtils.log("Website #{@website}")
|
22
|
+
Scms.sassall(File.join(@website))
|
37
23
|
|
38
|
-
yamlpath=File.join(
|
39
|
-
|
40
|
-
|
41
|
-
if $settings
|
42
|
-
if $settings["options"] != nil
|
43
|
-
# Don't overwrite environment settings
|
44
|
-
if ENV["SCMS_PUBLISH_FOLDER"] == nil && $settings["options"]["build_dir"] != nil
|
45
|
-
ScmsUtils.log("_Getting pub dir from _config.yml_")
|
46
|
-
@pub = $settings["options"]["build_dir"]
|
47
|
-
end
|
48
|
-
if $settings["options"]["clean_build_dir"] == true
|
49
|
-
ScmsUtils.log("Cleaning build dir")
|
50
|
-
@cleanpub = true
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
if @cleanpub
|
55
|
-
Scms.cleanpubdir(@pub)
|
56
|
-
@cleanpub = false
|
57
|
-
end
|
58
|
-
|
24
|
+
yamlpath=File.join(config, "_config.yml")
|
25
|
+
@settings = ScmsUtils.getsettings(yamlpath)
|
26
|
+
if @settings
|
59
27
|
#Bootstrap here
|
60
|
-
if
|
61
|
-
bootstrap = File.join(
|
62
|
-
#ScmsUtils.log("Bootstrap is: #{
|
28
|
+
if @settings["bootstrap"] != nil
|
29
|
+
bootstrap = File.join(@website, @settings["bootstrap"])
|
30
|
+
#ScmsUtils.log("Bootstrap is: #{@settings["bootstrap"]}")
|
63
31
|
if File.exists?(bootstrap)
|
64
32
|
begin
|
65
33
|
require_relative bootstrap
|
@@ -67,76 +35,59 @@ module Scms
|
|
67
35
|
ScmsUtils.errLog( e )
|
68
36
|
end
|
69
37
|
else
|
70
|
-
ScmsUtils.log("
|
38
|
+
ScmsUtils.log("Bootstrap does not exist #{bootstrap}")
|
71
39
|
end
|
72
40
|
end
|
73
41
|
|
74
|
-
|
75
|
-
|
76
|
-
stylesheets = Scms.bundle($settings["stylesheets"], ".css")
|
77
|
-
bundles = Scms.bundle($settings["bundles"])
|
78
|
-
#Generate pages
|
79
|
-
Scms.parsepages(scripts, stylesheets, bundles)
|
42
|
+
bundles = Scms.bundle(@settings["bundles"])
|
43
|
+
Scms.parsepages(bundles)
|
80
44
|
else
|
81
45
|
ScmsUtils.errLog("Config is empty")
|
82
46
|
end
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
Scms.cleanpubdir(@pub) if @cleanpub
|
88
|
-
FileUtils.mkdir @pub unless Dir.exists? @pub
|
89
|
-
Dir.chdir(@source) do
|
90
|
-
#files = Dir.glob('*')
|
91
|
-
#FileUtils.cp_r files, @pub
|
92
|
-
|
93
|
-
Dir.glob("**/*").reject{|f| f['.svn']}.each do |oldfile|
|
94
|
-
newfile = File.join(@pub, oldfile.sub(@source, ''))
|
95
|
-
#puts newfile
|
96
|
-
File.file?(oldfile) ? FileUtils.copy(oldfile, newfile) : FileUtils.mkdir(newfile) unless File.exist? newfile
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
ScmsUtils.log(ScmsUtils.uriEncode("file:///#{@pub}"))
|
102
|
-
return @pub
|
47
|
+
|
48
|
+
ScmsUtils.log("Built website:")
|
49
|
+
ScmsUtils.log(ScmsUtils.uriEncode("file:///#{@website}"))
|
103
50
|
end
|
104
|
-
|
105
|
-
def Scms.parsepages(
|
51
|
+
|
52
|
+
def Scms.parsepages(bundles)
|
106
53
|
# build views from templates
|
107
|
-
@template =
|
54
|
+
@template = @settings["template"]
|
108
55
|
|
109
|
-
if
|
56
|
+
if @settings["pages"] != nil
|
110
57
|
# Build navigation
|
111
58
|
navigation = Array.new
|
112
|
-
|
113
|
-
if
|
114
|
-
|
59
|
+
@settings["pages"].each do |pagedata|
|
60
|
+
if pagedata != nil
|
61
|
+
pagedata.each do |pageoptions|
|
115
62
|
pagename = pageoptions[0]
|
116
63
|
pageconfig = pageoptions[1]
|
117
64
|
pageurl = pageconfig["generate"]
|
118
|
-
|
65
|
+
pageurl = pageconfig["url"] unless pageconfig["url"] == nil
|
66
|
+
navtext = pageconfig["navigation"]
|
67
|
+
navmeta = pageconfig["navigation_meta"]
|
68
|
+
navigation.push({"text" => navtext, "url" => pageurl, "pagename" => pagename, "meta" => navmeta}) unless navtext == nil
|
119
69
|
end
|
120
70
|
end
|
121
71
|
end
|
122
72
|
|
123
73
|
ScmsUtils.log("Compiling Pages:")
|
124
|
-
|
125
|
-
if
|
126
|
-
|
74
|
+
@settings["pages"].each do |pagedata|
|
75
|
+
if pagedata != nil
|
76
|
+
pagedata.each do |pageoptions|
|
127
77
|
pagename = pageoptions[0]
|
128
78
|
pageconfig = pageoptions[1]
|
129
79
|
pageurl = pageconfig["generate"]
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
80
|
+
title = pagename
|
81
|
+
title = pageconfig["title"] unless pageconfig["title"] == nil
|
82
|
+
description = pageconfig["description"]
|
83
|
+
keywords = pageconfig["keywords"]
|
84
|
+
|
85
|
+
skin = @template
|
86
|
+
skin = pageconfig["template"] unless pageconfig["template"] == nil
|
136
87
|
|
137
88
|
resource = Hash.new
|
138
89
|
if pageconfig["resource"] != nil
|
139
|
-
resourcepath = File.join(
|
90
|
+
resourcepath = File.join(@website, pageconfig["resource"])
|
140
91
|
if File.exists?(resourcepath)
|
141
92
|
#ScmsUtils.log( "_Resource found: #{pageconfig["resource"]}_" )
|
142
93
|
resource = YAML.load_file(resourcepath)
|
@@ -145,15 +96,15 @@ module Scms
|
|
145
96
|
end
|
146
97
|
end
|
147
98
|
|
148
|
-
hasHandler =
|
99
|
+
hasHandler = false
|
149
100
|
if pageconfig["handler"] != nil
|
150
|
-
handlerpath = File.join(
|
101
|
+
handlerpath = File.join(@website, pageconfig["handler"])
|
151
102
|
if File.exists?(handlerpath)
|
152
103
|
#ScmsUtils.log( "Handler found: #{pageconfig["handler"]}" )
|
153
104
|
require handlerpath
|
154
105
|
funDefined = defined? Handler.render
|
155
106
|
if funDefined != nil
|
156
|
-
hasHandler =
|
107
|
+
hasHandler = true
|
157
108
|
else
|
158
109
|
ScmsUtils.errLog( "Handler doesnt have a render method" )
|
159
110
|
end
|
@@ -163,79 +114,93 @@ module Scms
|
|
163
114
|
end
|
164
115
|
|
165
116
|
views = Hash.new
|
166
|
-
pageconfig["views"]
|
167
|
-
views
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
117
|
+
if pageconfig["views"] != nil
|
118
|
+
pageconfig["views"].each do |view|
|
119
|
+
views[view[0]] = ""
|
120
|
+
viewpath = File.join(@website, view[1])
|
121
|
+
if File.exists?(viewpath)
|
122
|
+
htmlsnipet = File.read(viewpath)
|
123
|
+
if !htmlsnipet.empty?
|
124
|
+
viewmodel = Hash.new
|
125
|
+
viewmodel = {
|
126
|
+
:page => pagedata,
|
127
|
+
:sitedir => @website,
|
128
|
+
:resource => resource
|
129
|
+
}
|
130
|
+
|
131
|
+
if hasHandler
|
132
|
+
ScmsUtils.log("Rendering with handler")
|
133
|
+
viewSnippet = Handler.render(viewpath)
|
134
|
+
else
|
135
|
+
snnipetCode = File.read(viewpath)
|
136
|
+
case File.extname(view[1])
|
137
|
+
when ".md"
|
138
|
+
begin
|
139
|
+
doc = Maruku.new(snnipetCode)
|
140
|
+
viewSnippet = doc.to_html
|
141
|
+
rescue Exception => e
|
142
|
+
viewSnippet = snnipetCode
|
143
|
+
puts e.message
|
144
|
+
puts e.backtrace.inspect
|
145
|
+
end
|
146
|
+
else
|
147
|
+
viewSnippet = snnipetCode
|
188
148
|
end
|
149
|
+
end
|
150
|
+
|
151
|
+
if @mode == "cms"
|
152
|
+
views[view[0]] = "<div class='cms' data-view='#{view[1]}' data-page='#{pagedata}'>#{Scms.parsetemplate(viewSnippet, viewmodel)}</div>"
|
189
153
|
else
|
190
|
-
|
154
|
+
views[view[0]] = Scms.parsetemplate(viewSnippet, viewmodel)
|
191
155
|
end
|
192
|
-
end
|
193
|
-
|
194
|
-
if @mode == "cms"
|
195
|
-
views[view[0]] = "<div class='cms' data-view='#{view[1]}' data-page='#{page}'>#{Scms.parsetemplate(viewSnippet, model)}</div>"
|
196
156
|
else
|
197
|
-
|
157
|
+
ScmsUtils.writelog("Empty file: #{viewpath}")
|
198
158
|
end
|
199
159
|
else
|
200
|
-
ScmsUtils.
|
160
|
+
ScmsUtils.errLog("View not found: #{view[0]} - #{view[1]} [#{viewpath}]")
|
161
|
+
ScmsUtils.writelog("View not found: #{view[0]} - #{view[1]} [#{viewpath}]")
|
201
162
|
end
|
202
|
-
|
203
|
-
ScmsUtils.errLog("View not found: #{view[0]} - #{view[1]} [#{viewpath}]")
|
204
|
-
ScmsUtils.writelog(@pub, "View not found: #{view[0]} - #{view[1]} [#{viewpath}]")
|
163
|
+
#ScmsUtils.log( "view = #{view[0]} - #{view[1]}" )
|
205
164
|
end
|
206
|
-
#ScmsUtils.log( "view = #{view[0]} - #{view[1]}" )
|
207
165
|
end
|
208
166
|
|
209
167
|
monkeyhook = "";
|
210
|
-
if @mode == "cms"
|
211
|
-
monkeyhook = "<script src='scripts/air-monkey-hook.js'></script>"
|
212
|
-
end
|
168
|
+
monkeyhook = "<script src='scripts/air-monkey-hook.js'></script>" if @mode == "cms"
|
213
169
|
|
214
|
-
|
215
|
-
|
216
|
-
:
|
217
|
-
:
|
170
|
+
pagemodel = Hash.new
|
171
|
+
pagemodel = {
|
172
|
+
:name => pagename,
|
173
|
+
:title => title,
|
174
|
+
:description => description,
|
175
|
+
:keywords => keywords,
|
176
|
+
:url => pageurl,
|
218
177
|
:views => views,
|
219
178
|
:resource => resource,
|
220
179
|
:config => pageconfig,
|
221
|
-
:scripts => scripts,
|
222
|
-
:stylesheets => stylesheets,
|
223
180
|
:bundles => bundles,
|
224
|
-
:
|
225
|
-
:
|
226
|
-
:
|
181
|
+
:navigation => navigation,
|
182
|
+
:data => pagedata,
|
183
|
+
:rootdir => @website,
|
184
|
+
:monkeyhook => monkeyhook
|
227
185
|
}
|
228
186
|
|
229
|
-
erb = File.join(
|
230
|
-
out = File.join(@
|
187
|
+
erb = File.join(@website, skin)
|
188
|
+
out = File.join(@website, File.join(pageconfig["generate"].sub('~/',''))) unless pageconfig["generate"] == nil
|
231
189
|
|
232
|
-
|
190
|
+
ScmsUtils.successLog("#{pageurl}")
|
191
|
+
ScmsUtils.errLog("Template doesn't exist: #{erb}") unless File.exists?(erb)
|
192
|
+
if File.exists?(erb) && out != nil
|
233
193
|
pubsubdir = File.dirname(out)
|
234
194
|
Dir.mkdir(pubsubdir, 755) unless File::directory?(pubsubdir)
|
235
|
-
html = Scms.parsetemplate(File.read(erb),
|
195
|
+
html = Scms.parsetemplate(File.read(erb), pagemodel)
|
196
|
+
|
197
|
+
html = html.gsub('~/', ScmsUtils.uriEncode("file:///#{@website}/")) if @mode == "cms"
|
198
|
+
websiteroot = ''
|
199
|
+
websiteroot = @settings["url"] unless @settings["url"] == nil
|
200
|
+
|
201
|
+
html = html.gsub('~/', websiteroot)
|
202
|
+
|
236
203
|
File.open(out, 'w') {|f| f.write(html) }
|
237
|
-
else
|
238
|
-
ScmsUtils.errLog("Template doesn't exist: #{erb}")
|
239
204
|
end
|
240
205
|
end
|
241
206
|
end
|
@@ -244,30 +209,42 @@ module Scms
|
|
244
209
|
end
|
245
210
|
end
|
246
211
|
|
247
|
-
def Scms.
|
248
|
-
|
212
|
+
def Scms.parsetemplate(template, hash)
|
213
|
+
#lagasy fix
|
214
|
+
template = template.gsub('data.','page.')
|
215
|
+
|
216
|
+
page = OpenStruct.new(hash)
|
217
|
+
result = ""
|
218
|
+
|
219
|
+
begin
|
220
|
+
result = ERB.new(template).result(page.instance_eval { binding })
|
221
|
+
rescue Exception => e
|
222
|
+
ScmsUtils.errLog("Critical Error: Could not parse template")
|
223
|
+
ScmsUtils.log( "(if your using resources make sure their not empty)" )
|
224
|
+
ScmsUtils.errLog( e.message )
|
225
|
+
end
|
226
|
+
|
227
|
+
return result
|
228
|
+
end
|
229
|
+
|
230
|
+
def Scms.bundle(bundleConfig)
|
231
|
+
bundles = Hash.new
|
249
232
|
if bundleConfig != nil
|
250
233
|
ScmsUtils.log("Bundeling:")
|
251
234
|
bundleConfig.each do |bundle|
|
252
235
|
#ScmsUtils.log( "bundle (#{bundle.class}) = #{bundle}" )
|
253
236
|
bundle.each do |option|
|
254
237
|
name = option[0]
|
255
|
-
|
256
|
-
|
257
|
-
else
|
258
|
-
bundleVersion = 1
|
259
|
-
end
|
260
|
-
bundleName = File.join("scripts", "#{name}-v#{bundleVersion}.#{defaultExt}") #Legasy name filename from root and version
|
261
|
-
bundleName = File.join(option[1]["generate"]) if option[1]["generate"] != nil #just use the generate
|
262
|
-
scripts[name] = bundleName
|
238
|
+
bundleName = File.join(option[1]["generate"])
|
239
|
+
bundles[name] = bundleName
|
263
240
|
ScmsUtils.successLog("#{bundleName}")
|
264
241
|
|
265
242
|
content = ""
|
266
243
|
assetList = ""
|
267
|
-
|
268
|
-
|
244
|
+
files = option[1]["files"]
|
245
|
+
files.each do |asset|
|
269
246
|
assetList += "\t#{asset}\n"
|
270
|
-
assetname = File.join(@
|
247
|
+
assetname = File.join(@website, asset)
|
271
248
|
if File::exists?(assetname)
|
272
249
|
content = content + "\n" + File.read(assetname)
|
273
250
|
else
|
@@ -286,55 +263,7 @@ module Scms
|
|
286
263
|
end
|
287
264
|
end
|
288
265
|
end
|
289
|
-
return
|
290
|
-
end
|
291
|
-
|
292
|
-
def Scms.parsetemplate(template, hash)
|
293
|
-
data = OpenStruct.new(hash)
|
294
|
-
result = ""
|
295
|
-
|
296
|
-
begin
|
297
|
-
result = ERB.new(template).result(data.instance_eval { binding })
|
298
|
-
rescue Exception => e
|
299
|
-
ScmsUtils.errLog("Critical Error: Could not parse template")
|
300
|
-
ScmsUtils.log( "(if your using resources make sure their not empty)" )
|
301
|
-
ScmsUtils.errLog( e.message )
|
302
|
-
end
|
303
|
-
|
304
|
-
return result
|
305
|
-
end
|
306
|
-
|
307
|
-
def Scms.getsettings(yamlpath)
|
308
|
-
config = nil
|
309
|
-
|
310
|
-
if File.exist?(yamlpath)
|
311
|
-
tree = File.read(yamlpath)
|
312
|
-
begin
|
313
|
-
myconfig = ERB.new(tree).result()
|
314
|
-
#puts "Conf = #{myconfig}"
|
315
|
-
config = YAML.load(myconfig)
|
316
|
-
#config = YAML.load_file(yamlpath)
|
317
|
-
rescue Exception => e
|
318
|
-
ScmsUtils.errLog("Error Loading _config.yml (check there are no tabs in the file)")
|
319
|
-
ScmsUtils.log( "Verify your config")
|
320
|
-
ScmsUtils.log( "http://yaml-online-parser.appspot.com/")
|
321
|
-
ScmsUtils.errLog( e.message )
|
322
|
-
ScmsUtils.errLog( e.backtrace.inspect )
|
323
|
-
end
|
324
|
-
else
|
325
|
-
ScmsUtils.errLog("Config file does not exist: #{yamlpath}")
|
326
|
-
end
|
327
|
-
|
328
|
-
return config
|
329
|
-
end
|
330
|
-
|
331
|
-
def Scms.cleanpubdir(pub)
|
332
|
-
ScmsUtils.log("_Cleaning pub folder #{pub}_")
|
333
|
-
FileUtils.rm_rf pub
|
334
|
-
#FileUtils.remove_dir(pub, force = true)
|
335
|
-
sleep 0.5 # seconds
|
336
|
-
FileUtils.mkdir_p(pub) unless File.exist? pub
|
337
|
-
FileUtils.chmod 0755, pub
|
266
|
+
return bundles
|
338
267
|
end
|
339
268
|
|
340
269
|
def Scms.sassall(crunchDir)
|
@@ -380,17 +309,32 @@ module Scms
|
|
380
309
|
end
|
381
310
|
end
|
382
311
|
|
383
|
-
def Scms.deploy(
|
312
|
+
def Scms.deploy(website, config)
|
384
313
|
yamlpath=File.join(config, "_s3config.yml")
|
385
314
|
if File.exists?(yamlpath)
|
386
|
-
S3Deploy.sync(
|
315
|
+
S3Deploy.sync(website, config)
|
387
316
|
else
|
388
317
|
raise "The following file doesn't exist #{yamlpath}"
|
389
318
|
end
|
390
319
|
end
|
391
320
|
|
392
|
-
def Scms.
|
393
|
-
|
394
|
-
|
321
|
+
def Scms.copywebsite(website, pub)
|
322
|
+
if pub != nil
|
323
|
+
FileUtils.mkdir pub unless Dir.exists? pub
|
324
|
+
source = File.join(website)
|
325
|
+
Dir.chdir(source) do
|
326
|
+
Dir.glob("**/*").reject{|f| f['.svn']}.each do |oldfile|
|
327
|
+
newfile = File.join(pub, oldfile.sub(source, ''))
|
328
|
+
#puts newfile
|
329
|
+
File.file?(oldfile) ? FileUtils.copy(oldfile, newfile) : FileUtils.mkdir(newfile) unless File.exist? newfile
|
330
|
+
end
|
331
|
+
end
|
332
|
+
ScmsUtils.log("Output to: #{ScmsUtils.uriEncode("file:///#{pub}")}")
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
def Scms.upgrade(website)
|
337
|
+
File.rename("config.yml", "_config.yml") if File.exists? File.join(website, "config.yml")
|
338
|
+
File.rename("s3config.yml", "_s3config.yml") if File.exists? File.join(website, "s3config.yml")
|
395
339
|
end
|
396
340
|
end
|
data/scms.gemspec
CHANGED
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:
|
4
|
+
version: 2.0.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-07-
|
11
|
+
date: 2013-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cprobert-s3sync
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: nokogiri
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ! '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ! '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: maruku
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,9 +108,9 @@ files:
|
|
122
108
|
- LICENSE.txt
|
123
109
|
- README.md
|
124
110
|
- Rakefile
|
111
|
+
- assets/air-monkey-hook.js
|
125
112
|
- assets/blank-template/_config.yml
|
126
113
|
- assets/blank-template/_s3config.template.yml
|
127
|
-
- assets/blank-template/_templates/menu.xml
|
128
114
|
- assets/blank-template/_templates/skin.erb.html
|
129
115
|
- assets/blank-template/_views/about-intro.html
|
130
116
|
- assets/blank-template/_views/about-main.html
|
@@ -133,7 +119,6 @@ files:
|
|
133
119
|
- assets/blank-template/images/glyphicons-halflings-white.png
|
134
120
|
- assets/blank-template/images/glyphicons-halflings.png
|
135
121
|
- assets/blank-template/robots.txt
|
136
|
-
- assets/blank-template/scripts/air-monkey-hook.js
|
137
122
|
- assets/blank-template/scripts/bootstrap.js
|
138
123
|
- assets/blank-template/scripts/jquery-1.8.2.min.js
|
139
124
|
- assets/blank-template/scripts/script.js
|
@@ -141,12 +126,14 @@ files:
|
|
141
126
|
- assets/blank-template/stylesheets/bootstrap.css
|
142
127
|
- assets/blank-template/stylesheets/style.css
|
143
128
|
- assets/mime.types
|
129
|
+
- assets/yuicompressor/readme
|
144
130
|
- bin/scms
|
145
131
|
- build commands.txt
|
146
132
|
- lib/scms.rb
|
147
133
|
- lib/scms/s3deploy.rb
|
148
134
|
- lib/scms/scms-utils.rb
|
149
135
|
- lib/scms/version.rb
|
136
|
+
- lib/scms/yui.rb
|
150
137
|
- scms.gemspec
|
151
138
|
homepage: http://cprobert.github.io/Static-CMS/
|
152
139
|
licenses:
|