story 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ccce0cd43a669d138a50cca4c1400f3a1a6a4ec
4
- data.tar.gz: 6eca7f7abd9308770fd22292148a6d7ca57c54cc
3
+ metadata.gz: 169c4477ec511b09e0a7704c632f4601401a52f1
4
+ data.tar.gz: 8d2480c30354ccb9ff725615e90920144294c218
5
5
  SHA512:
6
- metadata.gz: 9b26b8043c9dc2f0ab26159ce7a97df16ccc262878bf681812d10270c55627002baa6e0d4977263aedde62b950260cedaed022226b8c3f6908bca9c0f95935ea
7
- data.tar.gz: dcde24f6fcc57a30240a6ee4853882a83fb4249ae04034e490107f53d693be8ef9ab4dbbf933adf17433f2b9caf270fe94abec0fe44b5fe291acb11421cc391b
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
- [Using](#using)
8
- [API](#api)
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,2 @@
1
+ adapter: sqlite3
2
+ database: blog.db
@@ -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
@@ -1,7 +1,7 @@
1
1
  module Story
2
2
  module Meta
3
3
  NAME = 'story'
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.4'
5
5
  CHARSET = 'utf-8'
6
6
  DEFAULT_BLOG_TITLE = 'Personal Blog'
7
7
  end
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
@@ -0,0 +1,3 @@
1
+ - @errors.each do |error|
2
+ p == error
3
+ br
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
@@ -3,6 +3,8 @@ require 'sinatra'
3
3
  require 'slim'
4
4
  require 'sass'
5
5
  require 'compass'
6
+ require 'yaml'
6
7
  require 'story/meta'
7
8
  require 'story/utils'
9
+ require 'story/db/utils'
8
10
  require 'story/router'
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.3
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-09 00:00:00.000000000 Z
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