sharkfrown 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sharkfrown.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 John Bintz
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # Preview ur markdowns
2
+
3
+ ```
4
+ gem install sharkfrown
5
+ cd /my/project/with/markdown/files
6
+ sharkfrown
7
+ ```
8
+
9
+ Open `http://localhost:6789/` and away you go!
10
+
11
+ ## How?!
12
+
13
+ `Rack::Directory` and a really simple Rack app that processes Markdown w/ syntax highlighting from Pygments.
14
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/sharkfrown ADDED
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thin'
4
+ require 'rack'
5
+ require 'pygmentize'
6
+ require 'redcarpet'
7
+
8
+ class Sharkfrown
9
+ class PygmentizeHTML < Redcarpet::Render::HTML
10
+ def block_code(code, language)
11
+ require 'pygmentize'
12
+ Pygmentize.process(code, language)
13
+ end
14
+ end
15
+
16
+ def call(env)
17
+ dup._call(env)
18
+ end
19
+
20
+ def _call(env)
21
+ path = env['PATH_INFO']
22
+
23
+ if path[%r{\.(md|mdown|markdown)$}]
24
+ file = File.join(Dir.pwd, env['PATH_INFO'])
25
+
26
+ if !(time = env['QUERY_STRING']).empty?
27
+ [ 200, {}, [ (File.mtime(file).to_i > time.to_i) ? 'reload' : '' ] ]
28
+ else
29
+ [
30
+ 200,
31
+ { 'Content-Type' => 'text/html' },
32
+ [ template(file) ]
33
+ ]
34
+ end
35
+ else
36
+ Rack::Directory.new('.').call(env)
37
+ end
38
+ end
39
+
40
+ def template(file)
41
+ <<-HTML
42
+ <html>
43
+ <head>
44
+ <title>Sharkfrown - #{file}</title>
45
+ <link rel="stylesheet" href="https://raw.github.com/gist/1082608/4cf6e61c7fb5d766861f30e98640665f464a35af/gh-like.css" type="text/css" />
46
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
47
+ <script type="text/javascript">
48
+ $(function() {
49
+ var checker;
50
+ checker = function() {
51
+ $.get(document.location.href + "?#{Time.now.to_i}", {}, function(responseText) {
52
+ if (responseText == 'reload') {
53
+ document.location.href = document.location.href;
54
+ } else {
55
+ setTimeout(checker, 2000);
56
+ }
57
+ });
58
+ };
59
+ checker();
60
+ });
61
+ </script>
62
+ </head>
63
+ <body>
64
+ <a href=".">Back</a>
65
+ #{Redcarpet::Markdown.new(PygmentizeHTML, :fenced_code_blocks => true).render(File.read(file))}
66
+ </body>
67
+ </html>
68
+ HTML
69
+ end
70
+ end
71
+
72
+ Thin::Server.start('0.0.0.0', 6789) do
73
+ use Rack::CommonLogger
74
+ use Rack::ShowExceptions
75
+
76
+ run Sharkfrown.new
77
+ end
@@ -0,0 +1,3 @@
1
+ module Sharkfrown
2
+ VERSION = "0.0.1"
3
+ end
data/lib/sharkfrown.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "sharkfrown/version"
2
+
3
+ module Sharkfrown
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/sharkfrown/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["John Bintz"]
6
+ gem.email = ["john@coswellproductions.com"]
7
+ gem.description = %q{Stupid-simple Rack-based Markdown browser with syntax highlighting.}
8
+ gem.summary = %q{Stupid-simple Rack-based Markdown browser with syntax highlighting.}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "sharkfrown"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Sharkfrown::VERSION
17
+
18
+ gem.add_dependency 'pygmentize'
19
+ gem.add_dependency 'thin'
20
+ gem.add_dependency 'redcarpet'
21
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sharkfrown
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - John Bintz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: pygmentize
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: thin
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: redcarpet
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Stupid-simple Rack-based Markdown browser with syntax highlighting.
63
+ email:
64
+ - john@coswellproductions.com
65
+ executables:
66
+ - sharkfrown
67
+ extensions: []
68
+ extra_rdoc_files: []
69
+ files:
70
+ - .gitignore
71
+ - Gemfile
72
+ - LICENSE
73
+ - README.md
74
+ - Rakefile
75
+ - bin/sharkfrown
76
+ - lib/sharkfrown.rb
77
+ - lib/sharkfrown/version.rb
78
+ - sharkfrown.gemspec
79
+ homepage: ''
80
+ licenses: []
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 1.8.23
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: Stupid-simple Rack-based Markdown browser with syntax highlighting.
103
+ test_files: []
104
+ has_rdoc: