Skip to content
This repository has been archived by the owner on Jan 17, 2019. It is now read-only.

Commit

Permalink
Use the contributing guide on the landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
kytrinyx committed Mar 3, 2014
1 parent 318818c commit 681eab6
Show file tree
Hide file tree
Showing 13 changed files with 156 additions and 12 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ At this point you can navigate to an existing endpoint in your browser, e.g.
The supporting code for a given exercise can be found in language-specific
subdirectories under the `exercises` directory.

> If you're not seeing any exercises it is probably because you haven't
> updated or inititialized the submodules. Be sure to work through the
> [Getting Started](#getting-started) section.
**If you're not seeing any exercises it is probably because you haven't
updated or inititialized the submodules. Be sure to work through the
[Getting Started](#getting-started) section.**

Each language-specific directory is a git submodule. If you wish to make
changes to an exercise, look for the corresponding repository on GitHub under
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ source 'https://rubygems.org'
ruby '2.1.0'

gem 'faraday', '~> 0.9'
gem 'haml', '~> 4.0'
gem 'petroglyph', '= 0.0.7'
gem 'puma', '~> 2.7'
gem 'rack', '~> 1.4'
gem 'rake', '~> 10.1'
gem 'redcarpet', '~> 2.3'
gem 'rouge', '~> 0.3'
gem 'sinatra', '~> 1.4', require: 'sinatra/base'
gem 'tilt', '~> 1.3'

Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ GEM
docile (1.1.2)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
haml (4.0.5)
tilt
mime-types (1.25.1)
mini_portile (0.5.2)
minitest (5.3.0)
Expand All @@ -33,8 +35,11 @@ GEM
rack-test (0.6.2)
rack (>= 1.0)
rake (10.1.1)
redcarpet (2.3.0)
rest-client (1.6.7)
mime-types (>= 1.16)
rouge (0.3.2)
thor
safe_yaml (1.0.1)
simplecov (0.8.2)
docile (~> 1.1.0)
Expand Down Expand Up @@ -62,12 +67,15 @@ DEPENDENCIES
approvals (= 0.0.12)
coveralls (~> 0.7)
faraday (~> 0.9)
haml (~> 4.0)
minitest (~> 5.2)
petroglyph (= 0.0.7)
puma (~> 2.7)
rack (~> 1.4)
rack-test (~> 0.6)
rake (~> 10.1)
redcarpet (~> 2.3)
rouge (~> 0.3)
sinatra (~> 1.4)
tilt (~> 1.3)
vcr (~> 2.8)
Expand Down
1 change: 1 addition & 0 deletions lib/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class App < Sinatra::Application
:secret => ENV.fetch('SESSION_SECRET') { 'Need to know only.' }
end

use Routes::Home
use Routes::Demo
use Routes::Exercises
end
Expand Down
9 changes: 4 additions & 5 deletions lib/app/public/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -939,11 +939,6 @@ h1, h2, h3{
font-family: 'source_code_prosemibold';
}

/* Section Content */
#section-content{
margin-top: 63px;
}

/* Section Content Code */
#section-content.section-content-code{
background: #FFF;
Expand Down Expand Up @@ -1246,3 +1241,7 @@ h1, h2, h3{
}
}

code {
font-family: 'source_code_proregular';
color: #000;
}
1 change: 1 addition & 0 deletions lib/app/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Xapi
module Routes
autoload :Home, 'app/routes/home'
autoload :Core, 'app/routes/core'
autoload :Demo, 'app/routes/demo'
autoload :Exercises, 'app/routes/exercises'
Expand Down
4 changes: 0 additions & 4 deletions lib/app/routes/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ class Core < Sinatra::Application
end

helpers Helpers::Guards

get '/' do
File.read(File.join(settings.public_folder, '/index.html'))
end
end
end
end
9 changes: 9 additions & 0 deletions lib/app/routes/home.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Xapi
module Routes
class Home < Core
get '/' do
haml :markdown, locals: {markdown: Xapi::Markdown.at('./CONTRIBUTING.md')}
end
end
end
end
46 changes: 46 additions & 0 deletions lib/app/views/layout.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
!!!
/[if lt IE 7] <html class="no-js lt-ie9 lt-ie8 lt-ie7">
/[if IE 7] <html class="no-js lt-ie9 lt-ie8">
/[if IE 8] <html class="no-js lt-ie9">
/ [if gt IE 8]><!
%html.no-js
/ <![endif]
%head
%meta{:charset => "utf-8"}/
%meta{:content => "IE=edge,chrome=1", "http-equiv" => "X-UA-Compatible"}/
%title Exercism Exercises API
%meta{:content => "Interfacing with Exercism", :name => "description"}/
%meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"}/
%link{:href => "css/bootstrap.min.css", :rel => "stylesheet"}/
%link{:href => "css/bootstrap-theme.min.css", :rel => "stylesheet"}/
%link{:href => "css/main.css", :rel => "stylesheet"}/
%link{:href => "favicon.ico", :rel => "shortcut icon"}/
%body
/[if lt IE 7]
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
%section#section-content
#content-first.content-heading
.container.container-narrow
%a.sprite-logo-medium.pull-left{:href => "http://exercism.io"} Exercism
%h1.pull-left The Exercism Exercise API
#content-second
%article.first.last
.container.container-narrow

= yield

%footer#section-footer
.container.text-center
%p
%a.sprite-brand{:href => "http://exercism.io"} Exercism.io
%span.text-line
\&copy; 2013 Katrina Owen / Source:
= succeed "." do
%a{:href => "http://github.com/exercism/x-api"} github.com/exercism/x-api
%span.text-line
Report bugs and submit feedback on
= succeed "." do
%a{:href => "htp://github.com/exercism/x-api/issues"} GitHub
Email me at
= succeed "." do
%a{:href => "mailto:kytrinyx@exercism.io"} kytrinyx@exercism.io
1 change: 1 addition & 0 deletions lib/app/views/markdown.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= preserve markdown.to_html
57 changes: 57 additions & 0 deletions lib/xapi/markdown.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
require 'redcarpet'
require 'rouge'
require 'rouge/plugins/redcarpet'

module Xapi
class Renderer < Redcarpet::Render::XHTML
def lexer
Rouge::Lexers::Text
end

def formatter
@formatter ||= Rouge::Formatters::HTML.new(
:css_class => "highlight #{lexer.tag}",
:line_numbers => true
)
end

def block_code(code, _)
formatter.format(lexer.lex(code))
end
end

class Markdown
def self.at(path)
new File.read(path)
end

attr_reader :text
def initialize(text)
@text = text
end

def to_html
markdown.render(text)
end

private

def markdown
@markdown ||= Redcarpet::Markdown.new(Renderer.new(hard_wrap: true), options)
end

def options
{
fenced_code_blocks: true,
no_intra_emphasis: true,
autolink: true,
strikethrough: true,
lax_html_blocks: true,
superscript: true,
tables: true,
space_after_headers: true,
xhtml: true
}
end
end
end
7 changes: 7 additions & 0 deletions test/fixtures/TEXT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# OHAI

Watch this:

```
$ go home
```
16 changes: 16 additions & 0 deletions test/xapi/markdown_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require './test/test_helper'
require 'xapi/markdown'

class MarkdownTest < Minitest::Test
def test_html_from_markdown
md = Xapi::Markdown.at('./test/fixtures/TEXT.md')
expected = <<-HTML
<h1>OHAI</h1>
<p>Watch this:</p>
<pre class=\"highlight text\"><table><tbody><tr><td class=\"gutter gl\"><div class=\"lineno\">1</div></td><td class=\"code\">$ go home
</td></tr></tbody></table></pre>
HTML
assert_equal expected.chomp, md.to_html
end
end

0 comments on commit 681eab6

Please sign in to comment.