story 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e20e544e8cae129c302c11ab9029113f6e38d61c
4
- data.tar.gz: e770f5be0f8a24de0aae5f6fcb058a3085be5e07
3
+ metadata.gz: 8ccce0cd43a669d138a50cca4c1400f3a1a6a4ec
4
+ data.tar.gz: 6eca7f7abd9308770fd22292148a6d7ca57c54cc
5
5
  SHA512:
6
- metadata.gz: 7fa887631c3496ec20bb87258d458dcb1aaabdbdd7649fa4094ef7b4bd0ed649a1ea7ece06afb8e6705f2ea7eef7d3037b41f527a5831ee4a49d0de8fa01832b
7
- data.tar.gz: d3c9a3247ff6de5febd7ed5ba222a05f6090b05f93b0f6e0c0a5d57068fbc6b2cbdd9ab150cd81d2b7fd850c53fec99c09858bfbbb82c6dcfd80b6f552b3d5a1
6
+ metadata.gz: 9b26b8043c9dc2f0ab26159ce7a97df16ccc262878bf681812d10270c55627002baa6e0d4977263aedde62b950260cedaed022226b8c3f6908bca9c0f95935ea
7
+ data.tar.gz: dcde24f6fcc57a30240a6ee4853882a83fb4249ae04034e490107f53d693be8ef9ab4dbbf933adf17433f2b9caf270fe94abec0fe44b5fe291acb11421cc391b
data/Gemfile CHANGED
@@ -3,4 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in story.gemspec
4
4
  gemspec
5
5
  gem 'sinatra'
6
- gem 'slim'
6
+ gem 'slim'
7
+ gem 'sass'
8
+ gem 'compass'
data/README.md CHANGED
@@ -1,2 +1,34 @@
1
1
  # Story
2
- Gem for creating awesome personal blog.
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
@@ -1,7 +1,7 @@
1
1
  module Story
2
2
  module Meta
3
3
  NAME = 'story'
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  CHARSET = 'utf-8'
6
6
  DEFAULT_BLOG_TITLE = 'Personal Blog'
7
7
  end
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, false
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
- if data = url.match(/(.*)\.(css|js|json|zip|mp3|mp4|ogg|mpeg|pdf|rtf|txt|doc|slim|xml|png|gif|jpg|jpeg|svg|tiff|#{settings.static_ext})/)
18
- raise not_found if not File.exists? ".#{data[1]}.#{data[2]}"
19
- content_type case data[2]
20
- when "css", "xml" then "text/#{data[2]}"
21
- when "js" then "text/javascript"
22
- when "mp3", "mp4", "ogg", "mpeg" then "audio/#{data[2]}"
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
@@ -1,5 +1,8 @@
1
1
  # encoding: utf-8
2
2
  require 'sinatra'
3
+ require 'slim'
4
+ require 'sass'
5
+ require 'compass'
3
6
  require 'story/meta'
4
7
  require 'story/utils'
5
8
  require 'story/router'
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.2
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-08 00:00:00.000000000 Z
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