moka 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -0
- data/Manifest +48 -0
- data/README.rdoc +9 -0
- data/Rakefile +17 -0
- data/bin/moka +21 -0
- data/lib/commands.rb +54 -0
- data/lib/commands/compile.rb +77 -0
- data/lib/commands/delete.rb +47 -0
- data/lib/commands/group/delete.rb +59 -0
- data/lib/commands/group/group_generator.rb +115 -0
- data/lib/commands/group/inspect.rb +40 -0
- data/lib/commands/group/new.rb +2 -0
- data/lib/commands/group/template/groupdir/variables.yml +1 -0
- data/lib/commands/inspect.rb +55 -0
- data/lib/commands/lib/compiler.rb +114 -0
- data/lib/commands/lib/helpers.rb +156 -0
- data/lib/commands/lib/lipsum_constants.rb +159 -0
- data/lib/commands/lib/lipsum_helpers.rb +56 -0
- data/lib/commands/lib/page_scope.rb +29 -0
- data/lib/commands/lib/partials_inclusion.rb +42 -0
- data/lib/commands/lib/site_tree.rb +274 -0
- data/lib/commands/lib/string_inflectors.rb +13 -0
- data/lib/commands/lib/utilities.rb +45 -0
- data/lib/commands/new.rb +64 -0
- data/lib/commands/order_groups.rb +115 -0
- data/lib/commands/order_pages.rb +128 -0
- data/lib/commands/page/delete.rb +47 -0
- data/lib/commands/page/inspect.rb +35 -0
- data/lib/commands/page/new.rb +2 -0
- data/lib/commands/page/page_generator.rb +130 -0
- data/lib/commands/page/template/pagedir/variables.yml +1 -0
- data/lib/commands/server.rb +125 -0
- data/lib/commands/site/inspect.rb +28 -0
- data/lib/commands/site/new.rb +10 -0
- data/lib/commands/site/site_generator.rb +93 -0
- data/lib/commands/site/template/manifest.yml +4 -0
- data/lib/commands/site/template/project/lib/helpers.rb +1 -0
- data/lib/commands/site/template/project/site/content.erb +14 -0
- data/lib/commands/site/template/project/site/header.erb +7 -0
- data/lib/commands/site/template/project/site/layout.erb +20 -0
- data/lib/commands/site/template/project/site/navigation.erb +7 -0
- data/lib/commands/site/template/project/site/variables.yml +1 -0
- data/lib/commands/site/template/project/styles/style.sass +74 -0
- data/lib/commands/site/template/script/config/boot.rb +5 -0
- data/lib/commands/site/template/script/moka +4 -0
- data/lib/script_moka_loader.rb +14 -0
- data/lib/version.rb +10 -0
- data/moka.gemspec +39 -0
- metadata +182 -0
data/lib/commands/new.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'getoptlong'
|
4
|
+
|
5
|
+
if ARGV.include? '--help' or ARGV.include? '-h'
|
6
|
+
puts <<-EOT
|
7
|
+
|
8
|
+
Usage:
|
9
|
+
|
10
|
+
moka new site site_name
|
11
|
+
|
12
|
+
or
|
13
|
+
|
14
|
+
moka new page page_name
|
15
|
+
|
16
|
+
or
|
17
|
+
|
18
|
+
moka new page group_name:page_name...
|
19
|
+
|
20
|
+
or
|
21
|
+
|
22
|
+
moka new group group_name...
|
23
|
+
|
24
|
+
Examples:
|
25
|
+
|
26
|
+
moka new site my_site_name
|
27
|
+
create a brand new moka project named 'my_site_name'
|
28
|
+
|
29
|
+
moka new page groupname:pagename -vars=var_name:var_value other_var_name:other_var_value
|
30
|
+
create a page named 'pagename' in group 'groupname' using layout 'custom_layout' that will compile in 'mydir/mypage.php' and has a custom variable 'customvar' with value 'customvalue'
|
31
|
+
|
32
|
+
moka new page groupname:pagename -t anothergroup:anotherpage
|
33
|
+
create a page named 'pagename' in group 'groupname' that replicates partials and variables used by page 'anotherpage' in group 'anothergroup'
|
34
|
+
|
35
|
+
moka new group group_name -t anothergroup
|
36
|
+
create a group named 'group_name' that replicates the same pages, partials and variables of group 'anothergroup'
|
37
|
+
|
38
|
+
Options:
|
39
|
+
|
40
|
+
-t, --template:
|
41
|
+
specify another page or group or moka site to use as a template to create the new page/group/site. The new page/group/site will have a copy of all the partials, variables and pages of the template page/group/site, apart from those variables that are explicitly set as command line arguments.
|
42
|
+
-v, --vars:
|
43
|
+
set variables in the appropriate variables.yml file. Syntax is:
|
44
|
+
-vars=var_name:var_value other_var_name:other_var_value ...
|
45
|
+
or
|
46
|
+
-v var_name:var_value other_var_name:other_var_value ...
|
47
|
+
variables are saved as strings. Other variable types can be set by editing directly the variables.yml file with a text editor.
|
48
|
+
EOT
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
|
52
|
+
thing_to_be_created = ARGV.shift
|
53
|
+
|
54
|
+
case thing_to_be_created
|
55
|
+
when 'page', 'p'
|
56
|
+
require File.expand_path('page/new', File.dirname(__FILE__))
|
57
|
+
when 'group', 'g'
|
58
|
+
require File.expand_path('group/new', File.dirname(__FILE__))
|
59
|
+
when 'site', 'project', 's'
|
60
|
+
require File.expand_path('site/new', File.dirname(__FILE__))
|
61
|
+
else
|
62
|
+
puts "ERROR: invalid option #{thing_to_be_created}. Valid options are 'site', 'page' and 'group'."
|
63
|
+
exit
|
64
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "thor"
|
5
|
+
require "thor/group"
|
6
|
+
|
7
|
+
module Moka
|
8
|
+
module OrderGivers
|
9
|
+
class GroupOrderGiver < Thor::Group
|
10
|
+
require "yaml"
|
11
|
+
require File.expand_path('lib/utilities', File.dirname(__FILE__))
|
12
|
+
require File.expand_path('lib/site_tree', File.dirname(__FILE__))
|
13
|
+
|
14
|
+
include Thor::Actions
|
15
|
+
include Moka::SiteTree
|
16
|
+
|
17
|
+
class_option :help, :type => :boolean, :aliases => "-h"
|
18
|
+
|
19
|
+
def provide_help_if_needed
|
20
|
+
if options[:help]
|
21
|
+
say <<-EOT
|
22
|
+
|
23
|
+
Usage:
|
24
|
+
|
25
|
+
moka order_groups
|
26
|
+
|
27
|
+
Examples:
|
28
|
+
moka order_groups
|
29
|
+
launch a CLI utility to display and edit the order groups
|
30
|
+
|
31
|
+
EOT
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def load_manifest
|
37
|
+
@manifest = YAML.load_file(File.expand_path("manifest.yml", MOKA_ROOT))
|
38
|
+
@site = SiteNode.new("site", @manifest["site"])
|
39
|
+
end
|
40
|
+
|
41
|
+
def ask_for_new_order
|
42
|
+
counter = 0
|
43
|
+
say ""
|
44
|
+
say "The current group order is the following:\n"
|
45
|
+
@site.groups.each do |group|
|
46
|
+
say "#{GroupOrderGiver.counter_to_letters(counter)} - #{group.name}"
|
47
|
+
counter += 1
|
48
|
+
end
|
49
|
+
say ""
|
50
|
+
@input = ask "Specify a new ordering as a string of space-separated indices, or press enter to do nothing (example: to switch the second and the third items insert 'a c b'):\n"
|
51
|
+
end
|
52
|
+
|
53
|
+
def reorder
|
54
|
+
input_array = @input.gsub(/[^a-z\s]/, "").split(/\s+/).map{|i| GroupOrderGiver.letters_to_counter(i)}.uniq.delete_if{|i| i < 0 or i > @site.groups.size - 1}
|
55
|
+
if input_array.size <= 0
|
56
|
+
exit
|
57
|
+
end
|
58
|
+
counter = 0
|
59
|
+
counter_two = 0
|
60
|
+
@site.groups.each do |group|
|
61
|
+
unless input_array.index(counter).nil?
|
62
|
+
@manifest["site"][group.name]["order"] = input_array.index(counter) + 1
|
63
|
+
else
|
64
|
+
@manifest["site"][group.name]["order"] = input_array.size + counter_two + 1
|
65
|
+
counter_two += 1
|
66
|
+
end
|
67
|
+
counter += 1
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def dump_manifest
|
72
|
+
f = File.open( File.expand_path('manifest.yml', MOKA_ROOT), 'w' ) do |out|
|
73
|
+
YAML.dump( @manifest, out )
|
74
|
+
end
|
75
|
+
say_status "update", "manifest.yml", :green
|
76
|
+
end
|
77
|
+
|
78
|
+
def notify_new_order
|
79
|
+
say ""
|
80
|
+
say "The new group order is the following:\n"
|
81
|
+
counter = 0
|
82
|
+
@site = SiteNode.new("", @manifest["site"])
|
83
|
+
@site.groups.each do |group|
|
84
|
+
say "#{GroupOrderGiver.counter_to_letters(counter)} - #{group.name}"
|
85
|
+
counter += 1
|
86
|
+
end
|
87
|
+
say ""
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.counter_to_letters(c)
|
91
|
+
letters = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z)
|
92
|
+
if c < letters.size
|
93
|
+
return letters[c]
|
94
|
+
else
|
95
|
+
return GroupOrderGiver.counter_to_letters(c/letters.size - 1) + letters[c%letters.size]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.letters_to_counter(l)
|
100
|
+
letters = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z)
|
101
|
+
l.gsub(/[^a-z]/, "")
|
102
|
+
if l.size == 0
|
103
|
+
return -1
|
104
|
+
end
|
105
|
+
unless letters.index(l).nil?
|
106
|
+
return letters.index(l)
|
107
|
+
else
|
108
|
+
return letters.index(l[-1]) + letters.size*(GroupOrderGiver.letters_to_counter(l[0..-2]))
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
Moka::OrderGivers::GroupOrderGiver.start
|
@@ -0,0 +1,128 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "thor"
|
5
|
+
require "thor/group"
|
6
|
+
|
7
|
+
module Moka
|
8
|
+
module OrderGivers
|
9
|
+
class PageOrderGiver < Thor::Group
|
10
|
+
require "yaml"
|
11
|
+
require File.expand_path('lib/utilities', File.dirname(__FILE__))
|
12
|
+
require File.expand_path('lib/site_tree', File.dirname(__FILE__))
|
13
|
+
|
14
|
+
include Thor::Actions
|
15
|
+
include Moka::SiteTree
|
16
|
+
|
17
|
+
argument :group_name, :required => false, :default => 'root'
|
18
|
+
class_option :help, :type => :boolean, :aliases => "-h"
|
19
|
+
|
20
|
+
def provide_help_if_needed
|
21
|
+
if options[:help]
|
22
|
+
say <<-EOT
|
23
|
+
|
24
|
+
Usage:
|
25
|
+
|
26
|
+
moka order_pages [group]
|
27
|
+
|
28
|
+
Examples:
|
29
|
+
moka order_pages
|
30
|
+
launch a CLI utility to display and edit the order of pages in group 'root'
|
31
|
+
|
32
|
+
moka order_pages mygroup
|
33
|
+
launch a CLI utility to display and edit the order of pages in group 'mygroup'
|
34
|
+
|
35
|
+
EOT
|
36
|
+
exit
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def load_manifest
|
41
|
+
@manifest = YAML.load_file(File.expand_path("manifest.yml", MOKA_ROOT))
|
42
|
+
@site = SiteNode.new("site", @manifest["site"])
|
43
|
+
end
|
44
|
+
|
45
|
+
def verify_group_existence
|
46
|
+
@group = @site.find_group(group_name)
|
47
|
+
if @group.nil?
|
48
|
+
say_status "ERROR:", "cannot find group '#{group_name}'", :red
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def ask_for_new_order
|
54
|
+
counter = 0
|
55
|
+
say ""
|
56
|
+
say "The current page order in group '#{group_name}' is the following:\n"
|
57
|
+
@group.pages.order_by(:order).each do |page|
|
58
|
+
say "#{PageOrderGiver.counter_to_letters(counter)} - #{page.name}"
|
59
|
+
counter += 1
|
60
|
+
end
|
61
|
+
say ""
|
62
|
+
@input = ask "Specify a new ordering as a string of space-separated indices, or press enter to do nothing (example: to switch the second and the third items insert 'a c b'):\n"
|
63
|
+
end
|
64
|
+
|
65
|
+
def reorder
|
66
|
+
input_array = @input.gsub(/[^a-z\s]/, "").split(/\s+/).map{|i| PageOrderGiver.letters_to_counter(i)}.uniq.delete_if{|i| i < 0 or i > @group.pages.size - 1}
|
67
|
+
if input_array.size <= 0
|
68
|
+
exit
|
69
|
+
end
|
70
|
+
counter = 0
|
71
|
+
counter_two = 0
|
72
|
+
@group.pages.order_by(:order).each do |page|
|
73
|
+
unless input_array.index(counter).nil?
|
74
|
+
@manifest["site"][@group.name][page.name]["order"] = input_array.index(counter) + 1
|
75
|
+
else
|
76
|
+
@manifest["site"][@group.name][page.name]["order"] = input_array.size + counter_two + 1
|
77
|
+
counter_two += 1
|
78
|
+
end
|
79
|
+
counter += 1
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def dump_manifest
|
84
|
+
f = File.open( File.expand_path('manifest.yml', MOKA_ROOT), 'w' ) do |out|
|
85
|
+
YAML.dump( @manifest, out )
|
86
|
+
end
|
87
|
+
say_status "update", "manifest.yml", :green
|
88
|
+
end
|
89
|
+
|
90
|
+
def notify_new_order
|
91
|
+
say ""
|
92
|
+
say "The new page order in group '#{group_name}' is the following:\n"
|
93
|
+
counter = 0
|
94
|
+
@site = SiteNode.new("", @manifest["site"])
|
95
|
+
@group = @site.find_group(group_name)
|
96
|
+
@group.pages.each do |page|
|
97
|
+
say "#{PageOrderGiver.counter_to_letters(counter)} - #{page.name}"
|
98
|
+
counter += 1
|
99
|
+
end
|
100
|
+
say ""
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.counter_to_letters(c)
|
104
|
+
letters = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z)
|
105
|
+
if c < letters.size
|
106
|
+
return letters[c]
|
107
|
+
else
|
108
|
+
return PageOrderGiver.counter_to_letters(c/letters.size - 1) + letters[c%letters.size]
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.letters_to_counter(l)
|
113
|
+
letters = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z)
|
114
|
+
l.gsub(/[^a-z]/, "")
|
115
|
+
if l.size == 0
|
116
|
+
return -1
|
117
|
+
end
|
118
|
+
unless letters.index(l).nil?
|
119
|
+
return letters.index(l)
|
120
|
+
else
|
121
|
+
return letters.index(l[-1]) + letters.size*(PageOrderGiver.letters_to_counter(l[0..-2]))
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
Moka::OrderGivers::PageOrderGiver.start
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require "fileutils"
|
3
|
+
require File.expand_path('../lib/utilities', File.dirname(__FILE__))
|
4
|
+
|
5
|
+
opts = GetoptLong.new(
|
6
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT ]
|
7
|
+
)
|
8
|
+
|
9
|
+
opts.each do |opt, arg|
|
10
|
+
case opt
|
11
|
+
when '--help'
|
12
|
+
RDoc::usage
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
if ARGV.first.nil?
|
17
|
+
puts "you need to specify a page name."
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
|
21
|
+
# parse ARGV[0] to support syntax groupname:pagename
|
22
|
+
page_name, group = Moka::Moka::Utilities.parse_grouppage ARGV.first
|
23
|
+
|
24
|
+
path = ""
|
25
|
+
manifest = YAML.load_file(File.expand_path("manifest.yml", MOKA_ROOT))
|
26
|
+
|
27
|
+
unless manifest["site"][group].nil? or manifest["site"][group][page_name].nil?
|
28
|
+
path = manifest["site"][group][page_name]["path"]
|
29
|
+
else
|
30
|
+
puts "ERROR: cannot find any page named '#{page_name}' in group '#{group}'"
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
|
34
|
+
manifest["site"][group].delete page_name
|
35
|
+
|
36
|
+
f = File.open( File.expand_path('manifest.yml', MOKA_ROOT), 'w' ) do |out|
|
37
|
+
YAML.dump( manifest, out )
|
38
|
+
end
|
39
|
+
|
40
|
+
FileUtils.rm_r(File.expand_path("project/site/#{group}/#{page_name}", MOKA_ROOT))
|
41
|
+
if File.exists? File.expand_path("compiled/"+path, MOKA_ROOT)
|
42
|
+
FileUtils.rm(File.expand_path("compiled/"+path, MOKA_ROOT))
|
43
|
+
end
|
44
|
+
|
45
|
+
puts ""
|
46
|
+
puts "Removed page #{group}:#{page_name}"
|
47
|
+
puts ""
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require "fileutils"
|
3
|
+
require File.expand_path('../lib/utilities', File.dirname(__FILE__))
|
4
|
+
require File.expand_path('../lib/site_tree', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
include Moka::SiteTree
|
7
|
+
|
8
|
+
if ARGV.first.nil?
|
9
|
+
puts "you need to specify a page name."
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
|
13
|
+
# parse ARGV[0] to support syntax groupname:pagename
|
14
|
+
page_name, group = Moka::Moka::Utilities.parse_grouppage ARGV.first
|
15
|
+
|
16
|
+
manifest = YAML.load_file(File.expand_path("manifest.yml", MOKA_ROOT))
|
17
|
+
@site = SiteNode.new("site", manifest["site"])
|
18
|
+
|
19
|
+
if @site.find_group(group).nil? or @site.find_group(group).find_page(page_name).nil?
|
20
|
+
puts "ERROR: cannot find page #{group}:#{page_name}"
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
|
24
|
+
puts "\nPage #{page_name}"
|
25
|
+
puts "\n Variables:"
|
26
|
+
@site.find_group(group).find_page(page_name).variables.each do |var_name, var_value|
|
27
|
+
puts " #{var_name} = #{var_value.inspect}"
|
28
|
+
end
|
29
|
+
puts "\n Parameters:"
|
30
|
+
@site.find_group(group).find_page(page_name).params.each do |par_name, par_value|
|
31
|
+
puts " #{par_name} = #{par_value.inspect}"
|
32
|
+
end
|
33
|
+
|
34
|
+
puts ""
|
35
|
+
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "thor"
|
3
|
+
require "thor/group"
|
4
|
+
|
5
|
+
module Moka
|
6
|
+
module Generators
|
7
|
+
class MokaPageGenerator < Thor::Group
|
8
|
+
|
9
|
+
require "yaml"
|
10
|
+
require File.expand_path('../lib/utilities', File.dirname(__FILE__))
|
11
|
+
require File.expand_path('../lib/site_tree', File.dirname(__FILE__))
|
12
|
+
|
13
|
+
include Thor::Actions
|
14
|
+
include Moka::SiteTree
|
15
|
+
|
16
|
+
argument :name
|
17
|
+
class_option :template, :type => :string, :aliases => "-t"
|
18
|
+
class_option :vars, :aliases => %w(-v), :type => :hash
|
19
|
+
|
20
|
+
def self.source_root
|
21
|
+
File.expand_path('template/', File.dirname(__FILE__))
|
22
|
+
end
|
23
|
+
|
24
|
+
def parse_page_group_and_name
|
25
|
+
if name.nil?
|
26
|
+
say_status "ERROR:", "you need to specify a page name.", :red
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
@page_name, @group = Moka::Utilities.parse_grouppage name
|
30
|
+
end
|
31
|
+
|
32
|
+
def load_manifest
|
33
|
+
@manifest = YAML.load_file(File.expand_path("manifest.yml", MOKA_ROOT))
|
34
|
+
@site = SiteNode.new("site", @manifest["site"])
|
35
|
+
end
|
36
|
+
|
37
|
+
def verify_if_page_exists
|
38
|
+
unless @site.find_group(@group).nil? or @site.find_group(@group).find_page(@page_name).nil?
|
39
|
+
say_status "ERROR:", "page '#{@page_name}' already exists in group '#{@group}'!", :red
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_page_dir_and_files
|
45
|
+
unless options[:template].nil?
|
46
|
+
@template_name, @template_group = Moka::Utilities.parse_grouppage options[:template]
|
47
|
+
if @site.find_group(@template_group).nil?
|
48
|
+
say_status "ERROR:", "cannot find group '#{@template_group}'", :red
|
49
|
+
exit
|
50
|
+
elsif @site.find_group(@template_group).find_page(@template_name).nil?
|
51
|
+
say_status "ERROR:", "cannot find page '#{@template_name}' in group '#{@template_group}'", :red
|
52
|
+
exit
|
53
|
+
end
|
54
|
+
directory(File.expand_path("project/site/#{@template_group}/#{@template_name}", MOKA_ROOT), File.expand_path("project/site/#{@group}/#{@page_name}", MOKA_ROOT))
|
55
|
+
else
|
56
|
+
directory("pagedir", File.expand_path("project/site/#{@group}/#{@page_name}", MOKA_ROOT))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def update_manifest
|
61
|
+
@page_params = {"order" => Time.new.utc.to_i}
|
62
|
+
unless options[:template].nil? or @manifest["site"][@template_group][@template_name]["layout"].nil?
|
63
|
+
@page_params["layout"] = @manifest["site"][@template_group][@template_name]["layout"]
|
64
|
+
end
|
65
|
+
unless @group == "root"
|
66
|
+
@page_params["path"] = File.join [@group, @page_name + "." + (@site.respond_to?(:default_extension) ? @site.default_extension : "html")]
|
67
|
+
else
|
68
|
+
@page_params["path"] = @page_name + "." + (@site.respond_to?(:default_extension) ? @site.default_extension : "html")
|
69
|
+
end
|
70
|
+
unless @site.find_group(@group).nil?
|
71
|
+
@manifest["site"][@group][@page_name] = @page_params
|
72
|
+
else
|
73
|
+
@manifest["site"][@group] = {"order" => Time.new.utc.to_i, @page_name => @page_params}
|
74
|
+
end
|
75
|
+
# dump manifest
|
76
|
+
f = File.open( File.expand_path('manifest.yml', MOKA_ROOT), 'w' ) do |out|
|
77
|
+
YAML.dump( @manifest, out )
|
78
|
+
end
|
79
|
+
say_status "update", "manifest.yml", :green
|
80
|
+
end
|
81
|
+
|
82
|
+
def delete_variables_using_reserved_name
|
83
|
+
unless options[:vars].nil?
|
84
|
+
options[:vars].each do |var_name, var_value|
|
85
|
+
if Moka::SiteTree::RESERVED_NAMES.include? var_name.to_s
|
86
|
+
say_status "WARNING:", "variable '#{var_name}' is a reserved word, and will not be set as a variable", :yellow
|
87
|
+
end
|
88
|
+
end
|
89
|
+
options[:vars].delete_if {|var_name, var_value| Moka::SiteTree::RESERVED_NAMES.include? var_name.to_s }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def dump_variables
|
94
|
+
if File.exists? File.expand_path("project/site/#{@group}/#{@page_name}/variables.yml", MOKA_ROOT)
|
95
|
+
@page_variables = YAML.load_file(File.expand_path("project/site/#{@group}/#{@page_name}/variables.yml", MOKA_ROOT))
|
96
|
+
else
|
97
|
+
@page_variables = {}
|
98
|
+
end
|
99
|
+
unless options[:vars].nil?
|
100
|
+
@page_variables.merge! options[:vars]
|
101
|
+
f = File.open( File.expand_path("project/site/#{@group}/#{@page_name}/variables.yml", MOKA_ROOT), 'w' ) do |out|
|
102
|
+
YAML.dump( @page_variables, out )
|
103
|
+
end
|
104
|
+
say_status "update", "project/site/#{@group}/#{@page_name}/variables.yml", :green
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def notify_about_creation
|
109
|
+
say ""
|
110
|
+
if options[:template].nil?
|
111
|
+
say "Generated page #{@group}:#{@page_name}"
|
112
|
+
else
|
113
|
+
say "Generated page #{@group}:#{@page_name} using page #{@template_group}:#{@template_name} as a template"
|
114
|
+
end
|
115
|
+
say ""
|
116
|
+
say " Page Parameters:"
|
117
|
+
@page_params.each do |param_name, param_value|
|
118
|
+
say " #{param_name} = #{param_value}"
|
119
|
+
end
|
120
|
+
|
121
|
+
say ""
|
122
|
+
say " Page Variables:"
|
123
|
+
@page_variables.each do |var_name, var_value|
|
124
|
+
puts " #{var_name} = #{var_value}"
|
125
|
+
end
|
126
|
+
say ""
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|