rack-blogengine 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rack/blogengine.rb +2 -0
- data/lib/rack/blogengine/command_line_interface.rb +23 -21
- data/lib/rack/blogengine/doc_parser.rb +15 -3
- data/lib/rack/blogengine/document.rb +22 -0
- data/lib/rack/blogengine/operator.rb +13 -0
- data/lib/rack/blogengine/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8e83d20847f61ee5f2de8dc0854604045dc93f0
|
4
|
+
data.tar.gz: 5c003d7a48d262f6cfa84bed2ec1d4d243682302
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49d1f9f0203dc2ff8f28a566aedbf963d3cac1a4dedbe5241bc44b254208747b54bf76fb1eefd24d37d13ce0674736d5ac448ba08b7045fa85db91636650c041
|
7
|
+
data.tar.gz: 512e3a2e9b03e02b754ded438656213569ed2b8e430e806a0922019527c93b109149bd9c9eec9b786283c4c642b7410d99070505ac7083e83030ad634ae76aee
|
data/lib/rack/blogengine.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require "rack/blogengine/version"
|
2
2
|
require "rack/blogengine/doc_parser"
|
3
|
+
require "rack/blogengine/document"
|
3
4
|
require "rack/blogengine/application"
|
4
5
|
require "rack/blogengine/application_router"
|
6
|
+
require "rack/blogengine/operator"
|
5
7
|
|
6
8
|
module Rack
|
7
9
|
module Blogengine
|
@@ -13,34 +13,36 @@ module Rack
|
|
13
13
|
print "\n"
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
# Method to run the cli command
|
17
|
+
# @param [String] target
|
18
|
+
def run(target)
|
19
|
+
unless target.empty?
|
20
|
+
system("cd #{target}")
|
21
|
+
$targetfolder = "#{Dir.pwd}/#{target}"
|
22
|
+
app = Rack::Builder.new do
|
23
|
+
use Rack::CommonLogger
|
24
|
+
use Rack::ShowExceptions
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
use Rack::Lint
|
30
|
-
run Rack::Blogengine::Application
|
26
|
+
map "/assets" do
|
27
|
+
run Rack::Directory.new("#{$targetfolder}/assets")
|
31
28
|
end
|
32
29
|
|
33
|
-
Rack::
|
34
|
-
|
35
|
-
puts "Specify a targetfolder!"
|
30
|
+
use Rack::Lint
|
31
|
+
run Rack::Blogengine::Application
|
36
32
|
end
|
37
|
-
end
|
38
33
|
|
39
|
-
|
40
|
-
|
34
|
+
Rack::Server.start( :app => app, :Port => 3000 )
|
35
|
+
else
|
36
|
+
puts "Specify a targetfolder!"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Command to generate the folder skeleton
|
41
|
+
# @param [String] folder
|
42
|
+
def generate(folder)
|
41
43
|
puts "Generating folder skeleton"
|
42
44
|
system("mkdir #{folder} && mkdir #{folder}/assets && mkdir #{folder}/assets/layout && mkdir #{folder}/assets/js && mkdir #{folder}/assets/style && mkdir #{folder}/assets/images")
|
43
|
-
|
45
|
+
end
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
@@ -18,20 +18,32 @@ module Rack
|
|
18
18
|
getFileContents(item)
|
19
19
|
@html = fillFileContents(@layout)
|
20
20
|
|
21
|
-
@document =
|
21
|
+
@document = Document.new
|
22
|
+
@document.path = @path
|
23
|
+
@document.html = @html
|
24
|
+
@document.title = @title
|
25
|
+
|
22
26
|
documents << @document
|
23
27
|
end
|
24
28
|
|
25
|
-
|
29
|
+
documents.each do |document|
|
30
|
+
document.exec_content_operator(documents, @target)
|
31
|
+
end
|
32
|
+
|
33
|
+
documentshashed = documents.map do |document|
|
34
|
+
document.to_hash
|
35
|
+
end
|
36
|
+
|
37
|
+
return documentshashed
|
26
38
|
end
|
27
39
|
|
28
40
|
# Get File Contents (path, title, content)
|
29
41
|
# @param file
|
30
42
|
def self.getFileContents(file)
|
31
|
-
# do work on real items
|
32
43
|
content_file = ::File.open("#{@target}/#{file}");
|
33
44
|
content = content_file.read
|
34
45
|
|
46
|
+
# Replace Closing tags
|
35
47
|
content["/path"] = "/close"
|
36
48
|
content["/title"] = "/close"
|
37
49
|
content["/content"] = "/close"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Rack
|
2
|
+
module Blogengine
|
3
|
+
class Document
|
4
|
+
attr_accessor :path, :html, :title
|
5
|
+
|
6
|
+
def to_hash
|
7
|
+
hash = {}
|
8
|
+
instance_variables.each do
|
9
|
+
|var| hash[var.to_s.delete("@").to_sym] = instance_variable_get(var) unless var.to_s == "@title"
|
10
|
+
end
|
11
|
+
hash
|
12
|
+
end
|
13
|
+
|
14
|
+
def exec_content_operator(documents, target)
|
15
|
+
@html.scan(/\{\%(.*?)\%\}/).each do |contentoperator|
|
16
|
+
operator = Operator.new(target)
|
17
|
+
operator.send(contentoperator[0].strip.to_sym, documents, @html)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Operator
|
2
|
+
def initialize(target)
|
3
|
+
Dir.foreach("#{target}operator/") do |item|
|
4
|
+
extension = item.split(".")[1]
|
5
|
+
next if item == '.' or item == '..' or extension != "rb"
|
6
|
+
require "#{target}operator/#{item}"
|
7
|
+
end
|
8
|
+
|
9
|
+
extend UserOperator # load user operators
|
10
|
+
end
|
11
|
+
|
12
|
+
# define default operators here
|
13
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-blogengine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benny1992
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,6 +85,8 @@ files:
|
|
85
85
|
- lib/rack/blogengine/application_router.rb
|
86
86
|
- lib/rack/blogengine/command_line_interface.rb
|
87
87
|
- lib/rack/blogengine/doc_parser.rb
|
88
|
+
- lib/rack/blogengine/document.rb
|
89
|
+
- lib/rack/blogengine/operator.rb
|
88
90
|
- lib/rack/blogengine/version.rb
|
89
91
|
- rack-blogengine.gemspec
|
90
92
|
homepage: ''
|
@@ -113,4 +115,3 @@ signing_key:
|
|
113
115
|
specification_version: 4
|
114
116
|
summary: Blogengine based on rack applications
|
115
117
|
test_files: []
|
116
|
-
has_rdoc:
|