initial commit
This commit is contained in:
commit
f91faa48f4
17
.gitignore
vendored
Normal file
17
.gitignore
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
*.gem
|
||||
*.rbc
|
||||
.bundle
|
||||
.config
|
||||
.yardoc
|
||||
Gemfile.lock
|
||||
InstalledFiles
|
||||
_yardoc
|
||||
coverage
|
||||
doc/
|
||||
lib/bundler/man
|
||||
pkg
|
||||
rdoc
|
||||
spec/reports
|
||||
test/tmp
|
||||
test/version_tmp
|
||||
tmp
|
4
Gemfile
Normal file
4
Gemfile
Normal file
@ -0,0 +1,4 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
# Specify your gem's dependencies in sharkfrown.gemspec
|
||||
gemspec
|
22
LICENSE
Normal file
22
LICENSE
Normal file
@ -0,0 +1,22 @@
|
||||
Copyright (c) 2012 John Bintz
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
29
README.md
Normal file
29
README.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Sharkfrown
|
||||
|
||||
TODO: Write a gem description
|
||||
|
||||
## Installation
|
||||
|
||||
Add this line to your application's Gemfile:
|
||||
|
||||
gem 'sharkfrown'
|
||||
|
||||
And then execute:
|
||||
|
||||
$ bundle
|
||||
|
||||
Or install it yourself as:
|
||||
|
||||
$ gem install sharkfrown
|
||||
|
||||
## Usage
|
||||
|
||||
TODO: Write usage instructions here
|
||||
|
||||
## Contributing
|
||||
|
||||
1. Fork it
|
||||
2. Create your feature branch (`git checkout -b my-new-feature`)
|
||||
3. Commit your changes (`git commit -am 'Added some feature'`)
|
||||
4. Push to the branch (`git push origin my-new-feature`)
|
||||
5. Create new Pull Request
|
77
bin/sharkfrown
Executable file
77
bin/sharkfrown
Executable file
@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'thin'
|
||||
require 'rack'
|
||||
require 'pygmentize'
|
||||
require 'redcarpet'
|
||||
|
||||
class Sharkfrown
|
||||
class PygmentizeHTML < Redcarpet::Render::HTML
|
||||
def block_code(code, language)
|
||||
require 'pygmentize'
|
||||
Pygmentize.process(code, language)
|
||||
end
|
||||
end
|
||||
|
||||
def call(env)
|
||||
dup._call(env)
|
||||
end
|
||||
|
||||
def _call(env)
|
||||
path = env['PATH_INFO']
|
||||
|
||||
if path[%r{\.(md|mdown|markdown)$}]
|
||||
file = File.join(Dir.pwd, env['PATH_INFO'])
|
||||
|
||||
if !(time = env['QUERY_STRING']).empty?
|
||||
[ 200, {}, [ (File.mtime(file).to_i > time.to_i) ? 'reload' : '' ] ]
|
||||
else
|
||||
[
|
||||
200,
|
||||
{ 'Content-Type' => 'text/html' },
|
||||
[ template(file) ]
|
||||
]
|
||||
end
|
||||
else
|
||||
Rack::Directory.new('.').call(env)
|
||||
end
|
||||
end
|
||||
|
||||
def template(file)
|
||||
<<-HTML
|
||||
<html>
|
||||
<head>
|
||||
<title>Sharkfrown - #{file}</title>
|
||||
<link rel="stylesheet" href="https://raw.github.com/gist/1082608/4cf6e61c7fb5d766861f30e98640665f464a35af/gh-like.css" type="text/css" />
|
||||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
var checker;
|
||||
checker = function() {
|
||||
$.get(document.location.href + "?#{Time.now.to_i}", {}, function(responseText) {
|
||||
if (responseText == 'reload') {
|
||||
document.location.href = document.location.href;
|
||||
} else {
|
||||
setTimeout(checker, 2000);
|
||||
}
|
||||
});
|
||||
};
|
||||
checker();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a href=".">Back</a>
|
||||
#{Redcarpet::Markdown.new(PygmentizeHTML, :fenced_code_blocks => true).render(File.read(file))}
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
end
|
||||
end
|
||||
|
||||
Thin::Server.start('0.0.0.0', 6789) do
|
||||
use Rack::CommonLogger
|
||||
use Rack::ShowExceptions
|
||||
|
||||
run Sharkfrown.new
|
||||
end
|
5
lib/sharkfrown.rb
Normal file
5
lib/sharkfrown.rb
Normal file
@ -0,0 +1,5 @@
|
||||
require "sharkfrown/version"
|
||||
|
||||
module Sharkfrown
|
||||
# Your code goes here...
|
||||
end
|
3
lib/sharkfrown/version.rb
Normal file
3
lib/sharkfrown/version.rb
Normal file
@ -0,0 +1,3 @@
|
||||
module Sharkfrown
|
||||
VERSION = "0.0.1"
|
||||
end
|
21
sharkfrown.gemspec
Normal file
21
sharkfrown.gemspec
Normal file
@ -0,0 +1,21 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
require File.expand_path('../lib/sharkfrown/version', __FILE__)
|
||||
|
||||
Gem::Specification.new do |gem|
|
||||
gem.authors = ["John Bintz"]
|
||||
gem.email = ["john@coswellproductions.com"]
|
||||
gem.description = %q{TODO: Write a gem description}
|
||||
gem.summary = %q{TODO: Write a gem summary}
|
||||
gem.homepage = ""
|
||||
|
||||
gem.files = `git ls-files`.split($\)
|
||||
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
||||
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
||||
gem.name = "sharkfrown"
|
||||
gem.require_paths = ["lib"]
|
||||
gem.version = Sharkfrown::VERSION
|
||||
|
||||
gem.add_dependency 'pygmentize'
|
||||
gem.add_dependency 'thin'
|
||||
gem.add_dependency 'redcarpet'
|
||||
end
|
Loading…
Reference in New Issue
Block a user