story 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/README.md +33 -1
- data/lib/story/meta.rb +1 -1
- data/lib/story/router.rb +8 -15
- data/lib/story/utils.rb +13 -0
- data/lib/story.rb +3 -0
- data/story.gemspec +4 -0
- metadata +58 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ccce0cd43a669d138a50cca4c1400f3a1a6a4ec
|
4
|
+
data.tar.gz: 6eca7f7abd9308770fd22292148a6d7ca57c54cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b26b8043c9dc2f0ab26159ce7a97df16ccc262878bf681812d10270c55627002baa6e0d4977263aedde62b950260cedaed022226b8c3f6908bca9c0f95935ea
|
7
|
+
data.tar.gz: dcde24f6fcc57a30240a6ee4853882a83fb4249ae04034e490107f53d693be8ef9ab4dbbf933adf17433f2b9caf270fe94abec0fe44b5fe291acb11421cc391b
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,2 +1,34 @@
|
|
1
1
|
# Story
|
2
|
-
Gem
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/story.png)](http://badge.fury.io/rb/story) [![Code Climate](https://codeclimate.com/github/rozzy/story.png)](https://codeclimate.com/github/rozzy/story) [![Dependency Status](https://gemnasium.com/rozzy/story.png)](https://gemnasium.com/rozzy/story)
|
3
|
+
Gem for creating awesome personal blog.
|
4
|
+
|
5
|
+
[Installing](#installation)
|
6
|
+
[Setting up](#setting-up)
|
7
|
+
[Using](#using)
|
8
|
+
[API](#api)
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
Story is a RubyGem, so simply install it with `gem install story`.
|
12
|
+
Or add it to your Gemfile `gem "story"` and use `$ bundle install` in terminal pwd.
|
13
|
+
|
14
|
+
## Setting Up
|
15
|
+
Story can work “out of the box”. You don't need any complex customizations or settings.
|
16
|
+
First of all you should require all necessary gems in your **Gemfile**:
|
17
|
+
```ruby
|
18
|
+
gem 'sinatra'
|
19
|
+
gem 'story'
|
20
|
+
gem 'slim'
|
21
|
+
gem 'compass'
|
22
|
+
gem 'sass'
|
23
|
+
```
|
24
|
+
|
25
|
+
The simpliest way to start working with your blog with default settings is:
|
26
|
+
```ruby
|
27
|
+
# app.rb
|
28
|
+
require 'story'
|
29
|
+
Story::Base.run!
|
30
|
+
```
|
31
|
+
And in your terminal:
|
32
|
+
```bash
|
33
|
+
$ ruby app.rb
|
34
|
+
```
|
data/lib/story/meta.rb
CHANGED
data/lib/story/router.rb
CHANGED
@@ -6,7 +6,8 @@ module Story
|
|
6
6
|
set :views, settings.views.to_s.gsub(/views$/, '/templates/story')
|
7
7
|
set :blog_title, Meta::DEFAULT_BLOG_TITLE
|
8
8
|
set :charset, Meta::CHARSET
|
9
|
-
set :static_ext,
|
9
|
+
set :static_ext, ''
|
10
|
+
set :sass, Compass.sass_engine_options
|
10
11
|
end
|
11
12
|
|
12
13
|
before do
|
@@ -14,20 +15,12 @@ module Story
|
|
14
15
|
end
|
15
16
|
|
16
17
|
get %r{(.*\..*)} do |url|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
when "json", "pdf", "zip" then "application/#{data[2]}"
|
24
|
-
when "png", "gif", "jpg", "jpeg", "svg", "tiff" then "image/#{data[2]}"
|
25
|
-
else "text/plain"
|
26
|
-
end
|
27
|
-
File.read ".#{data[1]}.#{data[2]}"
|
28
|
-
else
|
29
|
-
raise not_found
|
30
|
-
end
|
18
|
+
user_ext = settings.static_ext
|
19
|
+
user_ext = user_ext.split '|' if user_ext.is_a? String
|
20
|
+
expr = /(.*)\.(json|zip|md|txt|mp3|mp4|ogg|mpeg|pdf|rtf|doc|slim|xml|png|gif|jpg|jpeg|svg|tiff|#{user_ext.join('|')})/
|
21
|
+
if data = url.match(expr)
|
22
|
+
parse_file data[1], data[2]
|
23
|
+
else raise not_found end
|
31
24
|
end
|
32
25
|
|
33
26
|
get '/' do
|
data/lib/story/utils.rb
CHANGED
@@ -12,5 +12,18 @@ module Story
|
|
12
12
|
.each {|lib| return i if File.readable? lib }
|
13
13
|
raise LoadError
|
14
14
|
end
|
15
|
+
|
16
|
+
def parse_file filename, extension = '', root = true
|
17
|
+
file_path = "#{'.' if root}#{filename}.#{extension}"
|
18
|
+
raise not_found if not File.exists? file_path
|
19
|
+
content_type case extension
|
20
|
+
when "xml" then "text/#{extension}"
|
21
|
+
when "mp3", "mp4", "ogg", "mpeg" then "audio/#{extension}"
|
22
|
+
when "json", "pdf", "zip" then "application/#{extension}"
|
23
|
+
when "png", "gif", "jpg", "jpeg", "svg", "tiff" then "image/#{extension}"
|
24
|
+
else "text/plain"
|
25
|
+
end
|
26
|
+
File.read file_path
|
27
|
+
end
|
15
28
|
end
|
16
29
|
end
|
data/lib/story.rb
CHANGED
data/story.gemspec
CHANGED
@@ -19,5 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'sinatra', '~> 1.0'
|
23
|
+
spec.add_development_dependency 'slim', '~> 2.3'
|
24
|
+
spec.add_development_dependency 'sass', '~> 3.2'
|
25
|
+
spec.add_development_dependency 'compass', '~> 0.12'
|
22
26
|
spec.add_development_dependency 'rake'
|
23
27
|
end
|
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.3
|
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-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,62 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sinatra
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: slim
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sass
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: compass
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.12'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.12'
|
27
83
|
- !ruby/object:Gem::Dependency
|
28
84
|
name: rake
|
29
85
|
requirement: !ruby/object:Gem::Requirement
|