story 0.0.3 → 0.0.4
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 +4 -4
- data/README.md +3 -3
- data/lib/story/db/config.yml +2 -0
- data/lib/story/db/utils.rb +23 -0
- data/lib/story/meta.rb +1 -1
- data/lib/story/router.rb +12 -0
- data/lib/story/templates/story/error_page.slim +3 -0
- data/lib/story/utils.rb +6 -0
- data/lib/story.rb +2 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 169c4477ec511b09e0a7704c632f4601401a52f1
|
4
|
+
data.tar.gz: 8d2480c30354ccb9ff725615e90920144294c218
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94dc6f30ef38e2e035fdd7b737285ec46e49860b6538bb4f252dca998f36fd38fb88766f4914a5ccf29c69fb6e5afffcca184edb18b0c6b354ccb1ab4839a5d5
|
7
|
+
data.tar.gz: 8bf1bf2fb71743d589e4f7cc7578207af1553f1725fce7a17e20e23324e3a110d708cc2036a5525e92419b76835575d25174d7cc47ead4a2a30bc9671ebd770d
|
data/README.md
CHANGED
@@ -4,8 +4,8 @@ Gem for creating awesome personal blog.
|
|
4
4
|
|
5
5
|
[Installing](#installation)
|
6
6
|
[Setting up](#setting-up)
|
7
|
-
|
8
|
-
|
7
|
+
Using (in progress)
|
8
|
+
API (in progress)
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
Story is a RubyGem, so simply install it with `gem install story`.
|
@@ -31,4 +31,4 @@ Story::Base.run!
|
|
31
31
|
And in your terminal:
|
32
32
|
```bash
|
33
33
|
$ ruby app.rb
|
34
|
-
```
|
34
|
+
```
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Story
|
2
|
+
module DB
|
3
|
+
module Utils
|
4
|
+
def db_connected?
|
5
|
+
@errors ||= ''
|
6
|
+
begin
|
7
|
+
configuration_file = File.exists?('dbconfig.yml') ? 'dbconfig.yml' : File.join(File.dirname(__FILE__), 'config.yml')
|
8
|
+
p configuration_file
|
9
|
+
dbconfig = YAML::load File.open configuration_file
|
10
|
+
ActiveRecord::Base.logger = Logger.new STDERR
|
11
|
+
ActiveRecord::Base.establish_connection dbconfig
|
12
|
+
true
|
13
|
+
rescue Errno::ENOENT
|
14
|
+
@errors += "Database configuration file not found."
|
15
|
+
false
|
16
|
+
rescue => e
|
17
|
+
@errors += e.to_s
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/story/meta.rb
CHANGED
data/lib/story/router.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Story
|
2
2
|
class Base < Sinatra::Base
|
3
3
|
include Utils
|
4
|
+
include DB::Utils
|
4
5
|
|
5
6
|
configure do
|
6
7
|
set :views, settings.views.to_s.gsub(/views$/, '/templates/story')
|
@@ -8,9 +9,13 @@ module Story
|
|
8
9
|
set :charset, Meta::CHARSET
|
9
10
|
set :static_ext, ''
|
10
11
|
set :sass, Compass.sass_engine_options
|
12
|
+
set :title_separator, " | "
|
11
13
|
end
|
12
14
|
|
13
15
|
before do
|
16
|
+
raise error @errors if not db_connected?
|
17
|
+
@title = settings.blog_title
|
18
|
+
@header_needed = @footer_needed = true
|
14
19
|
@additional_styles ||= load_additional_styles
|
15
20
|
end
|
16
21
|
|
@@ -24,10 +29,17 @@ module Story
|
|
24
29
|
end
|
25
30
|
|
26
31
|
get '/' do
|
32
|
+
title "Posts"
|
27
33
|
slim :index
|
28
34
|
end
|
29
35
|
|
36
|
+
error do |*errors|
|
37
|
+
@errors = errors
|
38
|
+
slim :error_page
|
39
|
+
end
|
40
|
+
|
30
41
|
not_found do
|
42
|
+
title "404"
|
31
43
|
'Page not found'
|
32
44
|
end
|
33
45
|
end
|
data/lib/story/utils.rb
CHANGED
@@ -13,6 +13,12 @@ module Story
|
|
13
13
|
raise LoadError
|
14
14
|
end
|
15
15
|
|
16
|
+
def title *sections
|
17
|
+
sections.each do |section|
|
18
|
+
@title += "#{settings.title_separator}#{section.to_s}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
16
22
|
def parse_file filename, extension = '', root = true
|
17
23
|
file_path = "#{'.' if root}#{filename}.#{extension}"
|
18
24
|
raise not_found if not File.exists? file_path
|
data/lib/story.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: story
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rozzy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,8 +107,11 @@ files:
|
|
107
107
|
- README.md
|
108
108
|
- Rakefile
|
109
109
|
- lib/story.rb
|
110
|
+
- lib/story/db/config.yml
|
111
|
+
- lib/story/db/utils.rb
|
110
112
|
- lib/story/meta.rb
|
111
113
|
- lib/story/router.rb
|
114
|
+
- lib/story/templates/story/error_page.slim
|
112
115
|
- lib/story/templates/story/index.slim
|
113
116
|
- lib/story/templates/story/layout.slim
|
114
117
|
- lib/story/templates/story/meta.slim
|