lei 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/_app/_controllers.rb +116 -0
- data/bin/_app/_helpers.rb +191 -0
- data/bin/_app/_root.rb +199 -0
- data/bin/_app/_src.rb +170 -0
- data/bin/_app/_static.rb +7 -0
- data/bin/_app/_views.rb +122 -0
- data/bin/_app/_welcome.rb +13 -0
- data/bin/_new/_content.rb +44 -0
- data/bin/_new/_custom.rb +71 -0
- data/bin/functions.rb +7 -0
- data/bin/lei +65 -0
- data/example/controllers/content.rb +67 -0
- data/example/controllers/custom.rb +33 -0
- data/example/controllers/test.rb +12 -0
- data/example/helpers/content_helpers.rb +131 -0
- data/example/helpers/global_utils.rb +44 -0
- data/example/spec/spec_helper.rb +100 -0
- data/example/spec/test/content_helper_spec.rb +176 -0
- metadata +93 -0
data/bin/_app/_src.rb
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
require_relative "../functions"
|
2
|
+
|
3
|
+
common = <<~COMMON
|
4
|
+
@center-vert: {
|
5
|
+
display: flex;
|
6
|
+
flex-direction: column;
|
7
|
+
justify-content: center;
|
8
|
+
align-items: center;
|
9
|
+
};
|
10
|
+
|
11
|
+
@fs2: {
|
12
|
+
font-size: 2em;
|
13
|
+
};
|
14
|
+
|
15
|
+
@fs5: {
|
16
|
+
font-size: 5em;
|
17
|
+
};
|
18
|
+
|
19
|
+
@fs10: {
|
20
|
+
font-size: 10em;
|
21
|
+
};
|
22
|
+
|
23
|
+
@fw300: {
|
24
|
+
font-weight: 300;
|
25
|
+
};
|
26
|
+
|
27
|
+
@full-page: {
|
28
|
+
width: 100vw;
|
29
|
+
min-height: 100vh;
|
30
|
+
};
|
31
|
+
|
32
|
+
@std-content: {
|
33
|
+
max-width: 50em;
|
34
|
+
width: 80vw;
|
35
|
+
};
|
36
|
+
|
37
|
+
@std-margin: {
|
38
|
+
margin: 0em;
|
39
|
+
};
|
40
|
+
|
41
|
+
@std-padding: {
|
42
|
+
padding: 1em;
|
43
|
+
};
|
44
|
+
|
45
|
+
.base-page {
|
46
|
+
-webkit-tap-highlight-color: transparent;
|
47
|
+
font-family: "Lato", sans-serif;
|
48
|
+
background-color: rgb(240, 240, 240);
|
49
|
+
@std-margin();
|
50
|
+
|
51
|
+
&::-webkit-scrollbar {
|
52
|
+
display: none;
|
53
|
+
}
|
54
|
+
|
55
|
+
code {
|
56
|
+
background-color: rgba(0, 0, 0, 0.1);
|
57
|
+
}
|
58
|
+
|
59
|
+
pre {
|
60
|
+
code {
|
61
|
+
display: block;
|
62
|
+
@std-padding();
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
.space-to-left {
|
67
|
+
padding-left: 1em;
|
68
|
+
}
|
69
|
+
|
70
|
+
.space-to-right {
|
71
|
+
padding-right: 1em;
|
72
|
+
}
|
73
|
+
};
|
74
|
+
COMMON
|
75
|
+
|
76
|
+
content = <<~CONTENT
|
77
|
+
@import "_common";
|
78
|
+
|
79
|
+
html, body {
|
80
|
+
.base-page;
|
81
|
+
}
|
82
|
+
|
83
|
+
h1 {
|
84
|
+
@fw300();
|
85
|
+
}
|
86
|
+
|
87
|
+
a {
|
88
|
+
outline: transparent;
|
89
|
+
text-decoration: none;
|
90
|
+
color: black;
|
91
|
+
}
|
92
|
+
|
93
|
+
.content {
|
94
|
+
padding-bottom: 8px;
|
95
|
+
padding-left: 24px;
|
96
|
+
padding-right: 24px;
|
97
|
+
padding-top: 24px;
|
98
|
+
@std-content();
|
99
|
+
}
|
100
|
+
|
101
|
+
aside.content {
|
102
|
+
display: flex;
|
103
|
+
}
|
104
|
+
CONTENT
|
105
|
+
|
106
|
+
notfound = <<~NOTFOUND
|
107
|
+
@import "_common";
|
108
|
+
|
109
|
+
html, body {
|
110
|
+
.base-page;
|
111
|
+
}
|
112
|
+
|
113
|
+
h1 {
|
114
|
+
@fw300();
|
115
|
+
}
|
116
|
+
|
117
|
+
#not-found {
|
118
|
+
@center-vert();
|
119
|
+
@full-page();
|
120
|
+
}
|
121
|
+
|
122
|
+
.fof {
|
123
|
+
@fs10();
|
124
|
+
}
|
125
|
+
NOTFOUND
|
126
|
+
|
127
|
+
welcome = <<~WELCOME
|
128
|
+
@import "_common";
|
129
|
+
|
130
|
+
html, body {
|
131
|
+
.base-page;
|
132
|
+
}
|
133
|
+
|
134
|
+
.main {
|
135
|
+
@center-vert();
|
136
|
+
@full-page();
|
137
|
+
|
138
|
+
h1 {
|
139
|
+
@fs5();
|
140
|
+
@fw300();
|
141
|
+
text-align: center;
|
142
|
+
}
|
143
|
+
|
144
|
+
h2 {
|
145
|
+
@fs2();
|
146
|
+
@fw300();
|
147
|
+
}
|
148
|
+
|
149
|
+
p {
|
150
|
+
text-align: center;
|
151
|
+
}
|
152
|
+
}
|
153
|
+
WELCOME
|
154
|
+
|
155
|
+
dirs = [ "styles" ]
|
156
|
+
|
157
|
+
dirLoc = "$(pwd)/src"
|
158
|
+
|
159
|
+
makeDirs(dirs, dirLoc)
|
160
|
+
|
161
|
+
files = {
|
162
|
+
"_common.less": common,
|
163
|
+
"content.less": content,
|
164
|
+
"notfound.less": notfound,
|
165
|
+
"welcome.less": welcome
|
166
|
+
}
|
167
|
+
|
168
|
+
filesLoc = "#{dirLoc}/styles"
|
169
|
+
|
170
|
+
makeFiles(files, filesLoc)
|
data/bin/_app/_static.rb
ADDED
data/bin/_app/_views.rb
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
require_relative "../functions"
|
2
|
+
|
3
|
+
content = <<~CONTENT
|
4
|
+
doctype html
|
5
|
+
html[amp]
|
6
|
+
== slim :"global_partials/head",
|
7
|
+
locals: { title: title, style: style, url: url }
|
8
|
+
body
|
9
|
+
h1.content = title
|
10
|
+
== slim :"content_partials/pagination",
|
11
|
+
locals: { page: page, pages: pages, pageUrls: pageUrls }
|
12
|
+
- for post in content
|
13
|
+
section.content
|
14
|
+
== post
|
15
|
+
CONTENT
|
16
|
+
|
17
|
+
head = <<~HEAD
|
18
|
+
head
|
19
|
+
== $amp_static_header
|
20
|
+
== $amp_boiler
|
21
|
+
|
22
|
+
title = title
|
23
|
+
link[rel="canonical" href="\#{url}"]
|
24
|
+
link[href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet"]
|
25
|
+
style[amp-custom]
|
26
|
+
== style
|
27
|
+
HEAD
|
28
|
+
|
29
|
+
notfound = <<~NOTFOUND
|
30
|
+
doctype html
|
31
|
+
html[amp]
|
32
|
+
== slim :"global_partials/head",
|
33
|
+
locals: { title: title, style: style, url: url }
|
34
|
+
body
|
35
|
+
div#not-found
|
36
|
+
div.fof 404
|
37
|
+
h1 Content not found.
|
38
|
+
NOTFOUND
|
39
|
+
|
40
|
+
pagination = <<~PAGINATION
|
41
|
+
aside.content
|
42
|
+
- unless pageUrls[0].nil?
|
43
|
+
div.space-to-right
|
44
|
+
a[href=pageUrls[0]] = "<<"
|
45
|
+
- unless pageUrls[1].nil?
|
46
|
+
div.space-to-right
|
47
|
+
a[href=pageUrls[1]] = "<"
|
48
|
+
div Displaying page \#{page} of \#{pages}.
|
49
|
+
- unless pageUrls[2].nil?
|
50
|
+
div.space-to-left
|
51
|
+
a[href=pageUrls[2]] = ">"
|
52
|
+
- unless pageUrls[3].nil?
|
53
|
+
div.space-to-left
|
54
|
+
a[href=pageUrls[3]] = ">>"
|
55
|
+
PAGINATION
|
56
|
+
|
57
|
+
post = <<~POST
|
58
|
+
doctype html
|
59
|
+
html[amp]
|
60
|
+
== slim :"global_partials/head",
|
61
|
+
locals: { title: title, style: style, url: url }
|
62
|
+
body
|
63
|
+
div.content
|
64
|
+
== content
|
65
|
+
POST
|
66
|
+
|
67
|
+
results = <<~RESULTS
|
68
|
+
doctype html
|
69
|
+
html[amp]
|
70
|
+
== slim :"global_partials/head",
|
71
|
+
locals: { title: title, style: style, url: url }
|
72
|
+
body
|
73
|
+
h1.content Search Results
|
74
|
+
== slim :"content_partials/pagination",
|
75
|
+
locals: { page: page, pages: pages, pageUrls: pageUrls }
|
76
|
+
- for post in content
|
77
|
+
section.content
|
78
|
+
== post
|
79
|
+
RESULTS
|
80
|
+
|
81
|
+
welcome = <<~WELCOME
|
82
|
+
doctype html
|
83
|
+
html[amp]
|
84
|
+
== slim :"global_partials/head",
|
85
|
+
locals: { title: title, style: style, url: url }
|
86
|
+
body
|
87
|
+
.main
|
88
|
+
- content.each_with_index do |part, i|
|
89
|
+
div[id="content-\#{i}"]
|
90
|
+
== part
|
91
|
+
WELCOME
|
92
|
+
|
93
|
+
dirs = [
|
94
|
+
"global_partials",
|
95
|
+
"content_partials"
|
96
|
+
]
|
97
|
+
|
98
|
+
dirLoc = "$(pwd)/views"
|
99
|
+
|
100
|
+
makeDirs(dirs, dirLoc)
|
101
|
+
|
102
|
+
files = {
|
103
|
+
"content.slim": content,
|
104
|
+
"notfound.slim": notfound,
|
105
|
+
"post.slim": post,
|
106
|
+
"search_results.slim": results,
|
107
|
+
"welcome.slim": welcome
|
108
|
+
}
|
109
|
+
|
110
|
+
makeFiles(files, dirLoc)
|
111
|
+
|
112
|
+
globalFiles = { "head.slim": head }
|
113
|
+
|
114
|
+
globalPartialsLoc = "#{dirLoc}/global_partials"
|
115
|
+
|
116
|
+
makeFiles(globalFiles, globalPartialsLoc)
|
117
|
+
|
118
|
+
contentFiles = { "pagination.slim": pagination }
|
119
|
+
|
120
|
+
contentPartialsLoc = "#{dirLoc}/content_partials"
|
121
|
+
|
122
|
+
makeFiles(contentFiles, contentPartialsLoc)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
def add_new(name)
|
4
|
+
if name.nil? || name.length == 0
|
5
|
+
puts "Invalid custom page name." and return
|
6
|
+
end
|
7
|
+
|
8
|
+
name = name.split(" ")[0]
|
9
|
+
downcasedName = name.downcase
|
10
|
+
capitalizedName = name.capitalize
|
11
|
+
controllerName = "#{capitalizedName}Controller"
|
12
|
+
|
13
|
+
contentController = <<~CONTENT
|
14
|
+
require "\#{$root}/controllers/content"
|
15
|
+
|
16
|
+
puts "\\tController: #{capitalizedName}"
|
17
|
+
|
18
|
+
class #{controllerName} < ContentController
|
19
|
+
|
20
|
+
set :content_dir, "\#{$root}/#{downcasedName}"
|
21
|
+
set :stylesheet, "content"
|
22
|
+
set :public_folder, $assets_root
|
23
|
+
set :views, $views
|
24
|
+
|
25
|
+
end
|
26
|
+
CONTENT
|
27
|
+
|
28
|
+
initialContent = "# #{capitalizedName}\nYour content goes here."
|
29
|
+
|
30
|
+
cwd = Dir.pwd
|
31
|
+
controllers = YAML.load_file("#{cwd}/controllerlist.yml")
|
32
|
+
controllers.select! { |c| c["file"] != downcasedName }
|
33
|
+
|
34
|
+
controllers << {
|
35
|
+
"file" => downcasedName,
|
36
|
+
"name" => controllerName,
|
37
|
+
"path" => "/#{downcasedName}"
|
38
|
+
}
|
39
|
+
|
40
|
+
`echo '#{controllers.to_yaml}' > #{cwd}/controllerlist.yml`
|
41
|
+
`mkdir #{cwd}/#{downcasedName}`
|
42
|
+
`echo '#{initialContent}' > #{cwd}/#{downcasedName}/#{downcasedName}.md`
|
43
|
+
`echo '#{contentController}' > #{cwd}/controllers/#{downcasedName}.rb`
|
44
|
+
end
|
data/bin/_new/_custom.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
def add_new(name)
|
4
|
+
if name.nil? || name.length == 0
|
5
|
+
puts "Invalid custom page name." and return
|
6
|
+
end
|
7
|
+
|
8
|
+
name = name.split(" ")[0]
|
9
|
+
downcasedName = name.downcase
|
10
|
+
capitalizedName = name.capitalize
|
11
|
+
|
12
|
+
cwd = Dir.pwd
|
13
|
+
custom = YAML.load_file("#{cwd}/customlist.yml")
|
14
|
+
custom.select! { |c| c["file"] != downcasedName }
|
15
|
+
|
16
|
+
custom << {
|
17
|
+
"name" => downcasedName,
|
18
|
+
"path" => "/#{downcasedName}",
|
19
|
+
"title" => capitalizedName,
|
20
|
+
"content" => [ "#{downcasedName}.md" ]
|
21
|
+
}
|
22
|
+
|
23
|
+
customView = <<~VIEW
|
24
|
+
doctype html
|
25
|
+
html[amp]
|
26
|
+
== slim :"global_partials/head",
|
27
|
+
locals: { title: title, style: style, url: url }
|
28
|
+
body
|
29
|
+
.main
|
30
|
+
- content.each_with_index do |part, i|
|
31
|
+
div[id="content-\#{i}"]
|
32
|
+
== part
|
33
|
+
VIEW
|
34
|
+
|
35
|
+
customStyle = <<~STYLE
|
36
|
+
@import "_common";
|
37
|
+
|
38
|
+
html, body {
|
39
|
+
.base-page;
|
40
|
+
}
|
41
|
+
|
42
|
+
.main {
|
43
|
+
@center-vert();
|
44
|
+
@full-page();
|
45
|
+
|
46
|
+
h1 {
|
47
|
+
@fs5();
|
48
|
+
@fw300();
|
49
|
+
text-align: center;
|
50
|
+
}
|
51
|
+
|
52
|
+
h2 {
|
53
|
+
@fs2();
|
54
|
+
@fw300();
|
55
|
+
}
|
56
|
+
|
57
|
+
p {
|
58
|
+
text-align: center;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
STYLE
|
62
|
+
|
63
|
+
initialContent = "# #{capitalizedName}\nYour content goes here."
|
64
|
+
|
65
|
+
`echo '#{custom.to_yaml}' > #{cwd}/customlist.yml`
|
66
|
+
`mkdir #{cwd}/#{downcasedName}`
|
67
|
+
`echo '#{initialContent}' > #{cwd}/#{downcasedName}/#{downcasedName}.md`
|
68
|
+
`echo '#{customView}' > #{cwd}/views/#{downcasedName}.slim`
|
69
|
+
`echo '#{customStyle}' > #{cwd}/src/styles/#{downcasedName}.less`
|
70
|
+
`gulp shrink`
|
71
|
+
end
|
data/bin/functions.rb
ADDED
data/bin/lei
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
class Lei
|
4
|
+
def initialize
|
5
|
+
@root = File.dirname(File.absolute_path(__FILE__))
|
6
|
+
@validArg0 = [
|
7
|
+
"content",
|
8
|
+
"custom",
|
9
|
+
"help",
|
10
|
+
"install"
|
11
|
+
]
|
12
|
+
end
|
13
|
+
|
14
|
+
def help
|
15
|
+
puts <<~MAN
|
16
|
+
|
17
|
+
Usage: lei @(content|custom|help|install) ?(ARG)
|
18
|
+
|
19
|
+
`content`: Generates new serial, filterable content section with pagination. `ARG`: Content subject; should be camel-case!
|
20
|
+
`custom`: Generates a single, new, custom page. `ARG`: Page subject.
|
21
|
+
`help`: Get info about Lei and its commands.
|
22
|
+
`install`: Generates a brand-new installation of Lei.
|
23
|
+
|
24
|
+
MAN
|
25
|
+
end
|
26
|
+
|
27
|
+
def install
|
28
|
+
require "#{@root}/_app/_root.rb"
|
29
|
+
|
30
|
+
Dir.glob("#{@root}/_app/_*.rb").each { |f| require f }
|
31
|
+
|
32
|
+
`bundle install`
|
33
|
+
`npm install`
|
34
|
+
`npm install -g gulp-cli`
|
35
|
+
`gulp shrink`
|
36
|
+
`chmod +x launch.sh`
|
37
|
+
end
|
38
|
+
|
39
|
+
def go
|
40
|
+
arg0 = ARGV[0]
|
41
|
+
|
42
|
+
if !@validArg0.include?(arg0)
|
43
|
+
puts "Invalid first argument: `#{arg0}`."
|
44
|
+
puts "Use argument `help` to get info about Lei and its commands."
|
45
|
+
|
46
|
+
return
|
47
|
+
end
|
48
|
+
|
49
|
+
case arg0
|
50
|
+
when "install"
|
51
|
+
install
|
52
|
+
when "content", "custom"
|
53
|
+
require "#{@root}/_new/_#{arg0}"
|
54
|
+
|
55
|
+
add_new(ARGV[1])
|
56
|
+
when "help"
|
57
|
+
help
|
58
|
+
else
|
59
|
+
puts "Not yet implemented."
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
lei = Lei.new
|
65
|
+
lei.go
|