DisOrder 0.0.10
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.
- data/.gitignore +17 -0
- data/.rvmrc +1 -0
- data/DisOrder.gemspec +22 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +62 -0
- data/Rakefile +2 -0
- data/bin/disorder +56 -0
- data/lib/DisOrder/build.rb +27 -0
- data/lib/DisOrder/defaults/articlesBase.md.erb +12 -0
- data/lib/DisOrder/defaults/config.yml +16 -0
- data/lib/DisOrder/defaults/themes/base.html +32 -0
- data/lib/DisOrder/defaults/themes/baseArticle.html +1 -0
- data/lib/DisOrder/defaults/themes/css/index.css +24 -0
- data/lib/DisOrder/defaults/themes/css/styles.css +61 -0
- data/lib/DisOrder/defaults/themes/indexTheme.html +10 -0
- data/lib/DisOrder/helpers.rb +58 -0
- data/lib/DisOrder/index.rb +23 -0
- data/lib/DisOrder/init.rb +61 -0
- data/lib/DisOrder/pages.rb +83 -0
- data/lib/DisOrder/server.rb +11 -0
- data/lib/DisOrder/version.rb +3 -0
- data/lib/DisOrder.rb +14 -0
- metadata +119 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3-p194@disorder --create
|
data/DisOrder.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/DisOrder/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Nick Loose"]
|
6
|
+
gem.email = ["me@nickloose.de"]
|
7
|
+
gem.description = %q{DisOrder is a small static site generator.}
|
8
|
+
gem.summary = %q{DisOrder is a small static site generator. It takes Markdown as an input but the main features is that every article and page can have custom HTML and CSS.}
|
9
|
+
gem.homepage = "http://disorder-cms.org"
|
10
|
+
gem.license = 'MIT'
|
11
|
+
|
12
|
+
|
13
|
+
gem.add_runtime_dependency('redcarpet', '~> 2.2.2')
|
14
|
+
gem.add_runtime_dependency('cli-colorize', '~> 2.0.0')
|
15
|
+
gem.add_runtime_dependency('thor', '~> 0.17.0')
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($\)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
gem.name = "DisOrder"
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
gem.version = DisOrder::VERSION
|
22
|
+
end
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Nick Loose
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# DisOrder
|
2
|
+
|
3
|
+
DisOrder is a small static site generator. It takes Markdown as an input but the main features is that every article and page can have custom HTML and CSS.
|
4
|
+
|
5
|
+
I mainly written it for [HelloDrNick.com](http://HelloDrNick.com) and so it can make a mainpage with all the headlines of the articles and some small other (more) static pages you can link manualy in your theme or in articles.
|
6
|
+
|
7
|
+
But it can also do things like [NickLoose.de](http://nickloose.de).
|
8
|
+
|
9
|
+
## Getting Started
|
10
|
+
|
11
|
+
$ gem install DisOrder
|
12
|
+
$ disorder init my_blog
|
13
|
+
$ cd my_blog
|
14
|
+
$ disorder build -s # Look at http://localhost:8000
|
15
|
+
|
16
|
+
If you want to you can now add a new Article or Page like
|
17
|
+
|
18
|
+
$ disorder generate page "About Me"
|
19
|
+
|
20
|
+
or
|
21
|
+
|
22
|
+
$ disorder generate article "First Post"
|
23
|
+
|
24
|
+
This only generates the a Article or Page Stub with a Markdown File.
|
25
|
+
If you want to have custom HTML, CSS or JS you can add them to the every Article folder.
|
26
|
+
|
27
|
+
Here is an example strucator of a DisOrder Folder
|
28
|
+
|
29
|
+
.
|
30
|
+
|-- config.yml
|
31
|
+
|-- articles
|
32
|
+
| |-- hello_world
|
33
|
+
| | |-- index.md
|
34
|
+
| |-- Freedom
|
35
|
+
| | |-- index.html
|
36
|
+
| | |-- css/
|
37
|
+
| | |-- js/
|
38
|
+
| | |-- fonts/
|
39
|
+
| | |-- images/
|
40
|
+
|-- meta
|
41
|
+
| |-- articles.yml
|
42
|
+
| |-- pages.yml
|
43
|
+
|-- static
|
44
|
+
| |-- about
|
45
|
+
| | |-- index.md
|
46
|
+
|-- themes
|
47
|
+
| |-- base.html
|
48
|
+
| |-- baseArticle.html
|
49
|
+
| |-- indexTheme.html
|
50
|
+
| |-- css
|
51
|
+
| | |-- index.css
|
52
|
+
| | |-- style.css
|
53
|
+
| |-- images/
|
54
|
+
|
55
|
+
|
56
|
+
# Templates
|
57
|
+
|
58
|
+
Every html file is a erb template so you have the full power of ruby on your hands yay.
|
59
|
+
Look a the default template to see what todo.
|
60
|
+
|
61
|
+
|
62
|
+
|
data/Rakefile
ADDED
data/bin/disorder
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require "thor"
|
5
|
+
require 'DisOrder'
|
6
|
+
|
7
|
+
class DisOrderCLI < Thor
|
8
|
+
map "-g" => :generate
|
9
|
+
map "-i" => :init
|
10
|
+
map "-b" => :build
|
11
|
+
map "-s" => :server
|
12
|
+
|
13
|
+
desc "build", "Build current Project"
|
14
|
+
method_option :server, :default => false, :aliases => "-s", :desc => "Start the server after build"
|
15
|
+
def build
|
16
|
+
return unless checkFolder()
|
17
|
+
|
18
|
+
DisOrder::Build.build()
|
19
|
+
if options.server?
|
20
|
+
DisOrder::Server.serve()
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "server", "Start local server on port 8000 for current Project"
|
25
|
+
def server
|
26
|
+
return unless checkFolder()
|
27
|
+
DisOrder::Server.serve()
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "init [NAME]", "Create a new DisOrder Project"
|
31
|
+
def init(name="")
|
32
|
+
DisOrder::Init.init(name)
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "generate TYPE NAME", "Create a new Article or Page"
|
36
|
+
def generate(type, name)
|
37
|
+
return unless checkFolder()
|
38
|
+
|
39
|
+
if type == "article"
|
40
|
+
DisOrder::Init.initArticle(name)
|
41
|
+
elsif type == "page"
|
42
|
+
DisOrder::Init.initStaticPage(name)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def checkFolder
|
48
|
+
unless DisOrder::Helpers.isDisOrderProject?
|
49
|
+
puts 'Sorry this is not a DisOrder Projects Folder try: disorder init "MyBlog"'
|
50
|
+
return false
|
51
|
+
end
|
52
|
+
|
53
|
+
return true
|
54
|
+
end
|
55
|
+
|
56
|
+
DisOrderCLI.start
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module DisOrder
|
2
|
+
class Build
|
3
|
+
extend Helpers
|
4
|
+
|
5
|
+
def self.build
|
6
|
+
if File.directory?(config("output")) == false
|
7
|
+
Dir.mkdir(config("output"))
|
8
|
+
puts "-- Created Build Folder \n".white
|
9
|
+
else
|
10
|
+
FileUtils.remove_dir(config("output"))
|
11
|
+
puts "-- Deleted Previous Build Folder".red
|
12
|
+
Dir.mkdir(config("output"))
|
13
|
+
puts "-- Created Build Folder \n".white
|
14
|
+
end
|
15
|
+
Dir.mkdir(config("output")+"/static")
|
16
|
+
FileUtils.cp_r(config("foldersToCopy"), config("output")+"/static")
|
17
|
+
puts "-- Copied Static Folders \n".white
|
18
|
+
|
19
|
+
Index.build()
|
20
|
+
|
21
|
+
puts "-- Make Static Pages \n".white
|
22
|
+
Pages.build(config("metaDataFilePages"), config("baseStaticFolder"))
|
23
|
+
puts "-- Make Article Pages \n".white
|
24
|
+
Pages.build(config("metaDataFileArticels"), config("baseArticlesFolder"))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
## <%= @name %>
|
2
|
+
|
3
|
+
Change the content in "<%= @pageFolder %>/<%= @folder %>/index.md"
|
4
|
+
|
5
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut eu metus eget lectus condimentum lobortis sed vel nunc.
|
6
|
+
Sed sed libero leo. Donec non nulla sit amet neque commodo convallis.
|
7
|
+
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
|
8
|
+
Pellentesque convallis purus quis ipsum rutrum semper. Duis justo eros, facilisis quis tempor in, ullamcorper ut quam. Duis tincidunt pharetra cursus.
|
9
|
+
Maecenas porttitor felis ac nibh rutrum ut imperdiet nunc fermentum. Ut a ipsum risus. Proin ut enim metus.
|
10
|
+
|
11
|
+
Maecenas eget tortor eu eros dapibus laoreet. Proin ut tellus et nulla suscipit scelerisque.
|
12
|
+
Fusce quis neque ut lacus auctor pretium.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"baseTemplateFolder": "themes"
|
2
|
+
"baseMetaDataFolder": "meta"
|
3
|
+
"baseArticlesFolder": "articles"
|
4
|
+
"baseStaticFolder": "static"
|
5
|
+
|
6
|
+
"foldersToCopy":
|
7
|
+
- "themes/css"
|
8
|
+
|
9
|
+
"baseTemplateFile": "base.html"
|
10
|
+
"indexCSS": "static/css/index.css"
|
11
|
+
"indexHtml": "indexTheme.html"
|
12
|
+
"articleHtml": "baseArticle.html"
|
13
|
+
"metaDataFileArticels": "articles.yml"
|
14
|
+
"metaDataFilePages": "pages.yml"
|
15
|
+
"output": "build"
|
16
|
+
"baseurl": "/"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<title>DisOrder <% if @title %>| <%= @title %><% end %></title>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
|
8
|
+
|
9
|
+
<% if @jsBlock %>
|
10
|
+
<% @jsBlock.each do |js| %>
|
11
|
+
<script src="<%= js %>"></script>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<link href="<%= config("baseurl") %>static/css/styles.css" media="screen" rel="stylesheet" type="text/css" />
|
16
|
+
<% if @cssBlock %><link href="<%= config("baseurl") + @cssBlock %>" media="screen" rel="stylesheet" type="text/css" /><% end %>
|
17
|
+
|
18
|
+
</head>
|
19
|
+
|
20
|
+
<body>
|
21
|
+
<div class="wrapper">
|
22
|
+
<header>
|
23
|
+
<h1><a href="<%= baseURL() %>">DisOrder</a></h1>
|
24
|
+
<a href="/about">About</a>
|
25
|
+
</header>
|
26
|
+
<div id="content">
|
27
|
+
<%= @contentBlock %>
|
28
|
+
</div>
|
29
|
+
<footer>©<%= Time.now.year %> • Powerd by <a href="http://www.ruby-lang.org/en/">Ruby</a> and <a href="http://disorder-cms.org">DisOrder</a></footer>
|
30
|
+
</div>
|
31
|
+
</body>
|
32
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @ArticleText %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/* @override http://localhost:8000/static/css/index.css */
|
2
|
+
|
3
|
+
#content{
|
4
|
+
|
5
|
+
}
|
6
|
+
#content ul{
|
7
|
+
list-style-image: none;
|
8
|
+
list-style-type: none;
|
9
|
+
list-style-position: inside;
|
10
|
+
padding:0;
|
11
|
+
border-top: 1px solid #000;
|
12
|
+
}
|
13
|
+
|
14
|
+
#content ul li{
|
15
|
+
padding: 15px 0;
|
16
|
+
font-size: 20px;
|
17
|
+
border-bottom: 1px solid #000;
|
18
|
+
}
|
19
|
+
|
20
|
+
.date {
|
21
|
+
float: right;
|
22
|
+
font-size: 13px;
|
23
|
+
padding:0 5px;
|
24
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
/* @override http://localhost:8000/static/css/styles.css */
|
2
|
+
|
3
|
+
body{
|
4
|
+
background: #fefefe;
|
5
|
+
color:#000;
|
6
|
+
font: 16px/24px "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
|
7
|
+
}
|
8
|
+
|
9
|
+
a{
|
10
|
+
color: #000;
|
11
|
+
text-decoration: none;
|
12
|
+
}
|
13
|
+
a:hover{
|
14
|
+
color: #BB0707;
|
15
|
+
}
|
16
|
+
|
17
|
+
h1, h2, h3, h4, h5, h6{
|
18
|
+
font-weight: normal;
|
19
|
+
font-style: normal;
|
20
|
+
}
|
21
|
+
|
22
|
+
.wrapper{
|
23
|
+
width: 600px;
|
24
|
+
margin: 0 auto;
|
25
|
+
background:#fff;
|
26
|
+
border: 3px solid #ddd;
|
27
|
+
}
|
28
|
+
|
29
|
+
header, footer, #content{
|
30
|
+
padding: 25px;
|
31
|
+
}
|
32
|
+
|
33
|
+
header{
|
34
|
+
border-bottom: 1px solid #000;
|
35
|
+
padding-bottom:15px;
|
36
|
+
}
|
37
|
+
|
38
|
+
header h1{
|
39
|
+
background:#000;
|
40
|
+
display: block;
|
41
|
+
line-height: 40px;
|
42
|
+
margin-left: -25px;
|
43
|
+
margin-top: -25px;
|
44
|
+
padding: 25px 0;
|
45
|
+
width: 600px;
|
46
|
+
border-bottom: 5px solid #ddd;
|
47
|
+
text-align: center;
|
48
|
+
}
|
49
|
+
|
50
|
+
header h1 a{
|
51
|
+
color: #fff;
|
52
|
+
}
|
53
|
+
|
54
|
+
footer{
|
55
|
+
border-top: 5px solid #ddd;
|
56
|
+
background:#000;
|
57
|
+
color: #656565;
|
58
|
+
font-size: 14px;
|
59
|
+
text-align: center;
|
60
|
+
}
|
61
|
+
footer a{color: #fff;}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div class="row">
|
2
|
+
<div class="span10 offset1">
|
3
|
+
<h2>Table of Contents</h2>
|
4
|
+
<ul class="article_list">
|
5
|
+
<% @articles.each_with_index do |f, i| %>
|
6
|
+
<li><%= i+1 %>. <a href="<%= config("baseurl") + f[1]["url"] %>"><%= f[1]["name"] %></a> <em class="date"><%= f[1]["date"] %></em></li>
|
7
|
+
<% end %>
|
8
|
+
</ul>
|
9
|
+
</div>
|
10
|
+
</div>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module DisOrder
|
2
|
+
module Helpers
|
3
|
+
|
4
|
+
def render_markdown(content)
|
5
|
+
markdown ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)
|
6
|
+
return markdown.render(content)
|
7
|
+
end
|
8
|
+
|
9
|
+
def config(parameter)
|
10
|
+
config = YAML.load_file("config.yml")
|
11
|
+
return config[parameter] if parameter
|
12
|
+
end
|
13
|
+
|
14
|
+
def baseTemplate
|
15
|
+
baseTemplate ||= File.new(config("baseTemplateFolder") + "/"+ config("baseTemplateFile"), encoding: "UTF-8").read
|
16
|
+
end
|
17
|
+
|
18
|
+
def indexTemplate
|
19
|
+
indexTemplate ||= File.new(config("baseTemplateFolder")+ "/" + config("indexHtml"), encoding: "UTF-8").read
|
20
|
+
end
|
21
|
+
|
22
|
+
def articlesData
|
23
|
+
path = config("baseMetaDataFolder") + "/" + config("metaDataFileArticels")
|
24
|
+
return YAML.load_file(path) if File.exist?(path)
|
25
|
+
end
|
26
|
+
|
27
|
+
def baseURL
|
28
|
+
return config("baseurl")
|
29
|
+
end
|
30
|
+
|
31
|
+
def outputImages
|
32
|
+
config("output") + "/static/images"
|
33
|
+
end
|
34
|
+
|
35
|
+
def outputCSS
|
36
|
+
config("output") + "/static/css"
|
37
|
+
end
|
38
|
+
|
39
|
+
def outputFonts
|
40
|
+
config("output") + "/static/fonts"
|
41
|
+
end
|
42
|
+
|
43
|
+
def outputJS
|
44
|
+
config("output") + "/static/js"
|
45
|
+
end
|
46
|
+
|
47
|
+
def sanitize_filename(filename)
|
48
|
+
filename = filename.gsub(/^.*(\\|\/)/, '')
|
49
|
+
filename = filename.gsub(/[^0-9A-Za-z.\-]/, '_')
|
50
|
+
filename = filename.downcase
|
51
|
+
return filename
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.isDisOrderProject?
|
55
|
+
return File.exist?("config.yml") ? true : false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module DisOrder
|
2
|
+
class Index
|
3
|
+
extend Helpers
|
4
|
+
|
5
|
+
def self.build
|
6
|
+
puts "-- Make Index Page".white
|
7
|
+
|
8
|
+
baseTemplate = ERB.new(baseTemplate(), 0, "%<>")
|
9
|
+
indexTemplate = ERB.new(indexTemplate(), 0, "%<>")
|
10
|
+
|
11
|
+
@articles = articlesData()
|
12
|
+
@contentBlock = indexTemplate.result(binding)
|
13
|
+
@cssBlock = config("indexCSS")
|
14
|
+
|
15
|
+
result = baseTemplate.result(binding)
|
16
|
+
|
17
|
+
File.open("#{config("output")}/index.html", mode: "w:UTF-8") do |f|
|
18
|
+
f.write result
|
19
|
+
end
|
20
|
+
puts "-- Created Index Page \n".white
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module DisOrder
|
2
|
+
class Init
|
3
|
+
extend Helpers
|
4
|
+
|
5
|
+
def self.init(name="./")
|
6
|
+
FileUtils.mkdir_p(File.join(Dir.pwd, name)) if name != "./"
|
7
|
+
Dir.chdir(name) if name != "./"
|
8
|
+
|
9
|
+
FileUtils.mkdir_p(File.join(Dir.pwd, "articles"))
|
10
|
+
FileUtils.mkdir_p(File.join(Dir.pwd, "static"))
|
11
|
+
FileUtils.mkdir_p(File.join(Dir.pwd, "meta"))
|
12
|
+
|
13
|
+
defaults_path = File.expand_path(File.dirname(__FILE__))
|
14
|
+
|
15
|
+
FileUtils.cp_r(File.join(defaults_path, 'defaults', 'themes'), File.join(Dir.pwd, "themes"))
|
16
|
+
|
17
|
+
FileUtils.copy_file(File.join(defaults_path, 'defaults', 'config.yml'), File.join(Dir.pwd, "config.yml") )
|
18
|
+
|
19
|
+
initStaticPage("About")
|
20
|
+
initArticle("Hello World")
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.initArticle(name)
|
24
|
+
generatePage(name, config("metaDataFileArticels"), config("baseArticlesFolder"))
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.initStaticPage(name)
|
28
|
+
generatePage(name, config("metaDataFilePages"), config("baseStaticFolder"))
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.generatePage(name, metaFile, pageFolder)
|
32
|
+
metaPath = config("baseMetaDataFolder") + "/" + metaFile
|
33
|
+
|
34
|
+
pages = File.exist?(metaPath) ? YAML.load_file(metaPath) : Hash.new
|
35
|
+
|
36
|
+
sanitizedName = sanitize_filename(name)
|
37
|
+
|
38
|
+
new_page = {"name" => name, "date" => Date.today, "folder" => sanitizedName, "url" =>sanitizedName}
|
39
|
+
|
40
|
+
pages[sanitizedName] = new_page
|
41
|
+
|
42
|
+
File.open(config("baseMetaDataFolder") + "/"+ metaFile, mode: "w:UTF-8") do |f|
|
43
|
+
f.write YAML.dump(pages)
|
44
|
+
end
|
45
|
+
|
46
|
+
@name = name
|
47
|
+
@folder = new_page["folder"]
|
48
|
+
@pageFolder = pageFolder
|
49
|
+
|
50
|
+
defaults_path = File.expand_path(File.dirname(__FILE__))
|
51
|
+
template = ERB.new(File.new(File.join(defaults_path, 'defaults', 'articlesBase.md.erb'), encoding: "UTF-8").read, 0, "%<>")
|
52
|
+
result = template.result(binding)
|
53
|
+
|
54
|
+
FileUtils.mkdir_p(File.join(Dir.pwd, pageFolder, @folder))
|
55
|
+
|
56
|
+
File.open("#{pageFolder}/#{@folder}/index.md", mode: "w:UTF-8") do |f|
|
57
|
+
f.write result
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module DisOrder
|
2
|
+
class Pages
|
3
|
+
extend Helpers
|
4
|
+
|
5
|
+
def self.build(file, startFolder)
|
6
|
+
return unless File.exist?(config("baseMetaDataFolder") + "/"+ file)
|
7
|
+
|
8
|
+
template = ERB.new(baseTemplate(), 0, "%<>")
|
9
|
+
|
10
|
+
@pages = YAML.load_file(config("baseMetaDataFolder") + "/"+ file)
|
11
|
+
|
12
|
+
@pages.each_with_index do |f, i|
|
13
|
+
puts "--- Make Page: #{f[1]["name"]}".white
|
14
|
+
|
15
|
+
pageDir = "#{config("output")}/#{f[1]["url"] }"
|
16
|
+
pageSource = "#{startFolder}/#{f[1]["folder"]}"
|
17
|
+
cssSource = "#{pageSource}/css/"
|
18
|
+
imageSource = "#{pageSource}/images/"
|
19
|
+
jsSource = "#{pageSource}/js/"
|
20
|
+
fontSource = "#{pageSource}/fonts/"
|
21
|
+
|
22
|
+
FileUtils.mkdir_p(pageDir)
|
23
|
+
puts "---- Created Folder: #{pageDir}".white
|
24
|
+
|
25
|
+
file_name = sanitize_filename(f[1]["folder"])
|
26
|
+
|
27
|
+
copySources(cssSource, outputCSS(), "css", file_name)
|
28
|
+
copySources(imageSource, outputImages(), "images", file_name)
|
29
|
+
copySources(jsSource, outputJS(), "js", file_name)
|
30
|
+
copySources(fontSource, outputFonts(), "fonts", file_name)
|
31
|
+
|
32
|
+
puts "---- Creating Page HTML".white
|
33
|
+
if File.exist?(startFolder+ "/" +f[1]["folder"] +"/index.md")
|
34
|
+
@ArticleText = render_markdown(File.new(startFolder+ "/" +f[1]["folder"] +"/index.md", encoding: "UTF-8").read)
|
35
|
+
article = ERB.new(File.new(config("baseTemplateFolder") + "/" + config("articleHtml"), encoding: "UTF-8").read).result(binding)
|
36
|
+
@contentBlock = ERB.new(article).result(binding)
|
37
|
+
|
38
|
+
puts "----- Convertet Markdown to HTML".white
|
39
|
+
|
40
|
+
elsif File.exist?(startFolder+ "/" +f[1]["folder"] +"/index.html")
|
41
|
+
@contentBlock = ERB.new(File.new(startFolder+ "/" +f[1]["folder"] +"/index.html", encoding: "UTF-8").read).result(binding)
|
42
|
+
|
43
|
+
puts "----- Got Page HTML ".white
|
44
|
+
end
|
45
|
+
|
46
|
+
if File.exist?(cssSource)
|
47
|
+
@cssBlock = "static/css/#{file_name}/style.css"
|
48
|
+
else
|
49
|
+
@cssBlock = config("indexCSS")
|
50
|
+
end
|
51
|
+
@title = f[1]["name"]
|
52
|
+
|
53
|
+
if File.exist?(jsSource)
|
54
|
+
jsfiles = Dir.entries(jsSource)
|
55
|
+
jsfiles.delete "."
|
56
|
+
jsfiles.delete ".."
|
57
|
+
jsfiles.map! { |file| "/static/js/#{file_name}/#{file}" }
|
58
|
+
@jsBlock = jsfiles
|
59
|
+
end
|
60
|
+
|
61
|
+
result = template.result(binding)
|
62
|
+
|
63
|
+
File.open("#{pageDir}/index.html", mode: "w:UTF-8") do |f|
|
64
|
+
f.write result
|
65
|
+
end
|
66
|
+
|
67
|
+
puts "---- Created HTML Page".white
|
68
|
+
|
69
|
+
puts "--- Finished Page: #{f[1]["name"]} \n".white
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
def self.copySources(from, to, what, name)
|
75
|
+
if File.exist?(from)
|
76
|
+
FileUtils.mkdir_p(to)
|
77
|
+
FileUtils.cp_r(from, to)
|
78
|
+
FileUtils.mv("#{to}/#{what}", "#{to}/#{name}")
|
79
|
+
puts "---- Copied #{what}".white
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/DisOrder.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'yaml'
|
4
|
+
require 'cli-colorize'
|
5
|
+
require 'redcarpet'
|
6
|
+
|
7
|
+
directory = File.expand_path(File.dirname(__FILE__))
|
8
|
+
require File.join(directory, 'DisOrder', 'version')
|
9
|
+
require File.join(directory, 'DisOrder', 'helpers')
|
10
|
+
require File.join(directory, 'DisOrder', 'build')
|
11
|
+
require File.join(directory, 'DisOrder', 'index')
|
12
|
+
require File.join(directory, 'DisOrder', 'pages')
|
13
|
+
require File.join(directory, 'DisOrder', 'init')
|
14
|
+
require File.join(directory, 'DisOrder', 'server')
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: DisOrder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.10
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nick Loose
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: redcarpet
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.2.2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.2.2
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: cli-colorize
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.0.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.0.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: thor
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.17.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.17.0
|
62
|
+
description: DisOrder is a small static site generator.
|
63
|
+
email:
|
64
|
+
- me@nickloose.de
|
65
|
+
executables:
|
66
|
+
- disorder
|
67
|
+
extensions: []
|
68
|
+
extra_rdoc_files: []
|
69
|
+
files:
|
70
|
+
- .gitignore
|
71
|
+
- .rvmrc
|
72
|
+
- DisOrder.gemspec
|
73
|
+
- Gemfile
|
74
|
+
- LICENSE
|
75
|
+
- README.md
|
76
|
+
- Rakefile
|
77
|
+
- bin/disorder
|
78
|
+
- lib/DisOrder.rb
|
79
|
+
- lib/DisOrder/build.rb
|
80
|
+
- lib/DisOrder/defaults/articlesBase.md.erb
|
81
|
+
- lib/DisOrder/defaults/config.yml
|
82
|
+
- lib/DisOrder/defaults/themes/base.html
|
83
|
+
- lib/DisOrder/defaults/themes/baseArticle.html
|
84
|
+
- lib/DisOrder/defaults/themes/css/index.css
|
85
|
+
- lib/DisOrder/defaults/themes/css/styles.css
|
86
|
+
- lib/DisOrder/defaults/themes/indexTheme.html
|
87
|
+
- lib/DisOrder/helpers.rb
|
88
|
+
- lib/DisOrder/index.rb
|
89
|
+
- lib/DisOrder/init.rb
|
90
|
+
- lib/DisOrder/pages.rb
|
91
|
+
- lib/DisOrder/server.rb
|
92
|
+
- lib/DisOrder/version.rb
|
93
|
+
homepage: http://disorder-cms.org
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 1.8.24
|
115
|
+
signing_key:
|
116
|
+
specification_version: 3
|
117
|
+
summary: DisOrder is a small static site generator. It takes Markdown as an input
|
118
|
+
but the main features is that every article and page can have custom HTML and CSS.
|
119
|
+
test_files: []
|