Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First commit of ruby version

  • Loading branch information...
commit ab186e5130397955e4c0ea5bf5df05f3c33dd8d5 1 parent 7a293a1
@micdijkstra authored
View
1  .gitignore
@@ -0,0 +1 @@
+.DS_Store
View
17 Gemfile.lock
@@ -0,0 +1,17 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ rack (1.3.5)
+ rack-protection (1.1.4)
+ rack
+ sinatra (1.3.1)
+ rack (~> 1.3, >= 1.3.4)
+ rack-protection (~> 1.1, >= 1.1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ tilt (1.3.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ sinatra
View
17 README.mdown
@@ -1,3 +1,18 @@
+# Ruby version of Pattern-Primer by adactio
+
+See https://github.com/adactio/Pattern-Primer
+
+## Pattern Primer
+
Create little snippets of markup and save them to the "patterns folder." The pattern primer will generate a list of all the patterns in that folder. You will see the pattern rendered as HTML. You will also get the source displayed in a textarea.
-You should be able to take the whole "pattern-primer" folder and drop it into your own project (assuming you're running PHP) **BUT** make sure to update the link element in the head of pattern-primer/index.php to point to your own CSS.
+## How it works
+
+1. Clone the repo
+2. run bundle install
+3. Copy your CSS to public/style.css
+4. Run the file with 'ruby application.rb' or 'shotgun' if you have the shotgun gem installed (https://github.com/rtomayko/shotgun)
+
+## Acknowledgements
+
+Thanks to @adactio
View
6 application.rb
@@ -0,0 +1,6 @@
+require 'sinatra'
+set :public_folder, File.dirname(__FILE__) + '/public'
+
+get '/' do
+ erb :index
+end
View
7 config.ru
@@ -0,0 +1,7 @@
+require 'rubygems'
+require 'bundler/setup'
+require 'sinatra'
+
+require './application'
+
+run Sinatra::Application
View
2  gemfile
@@ -0,0 +1,2 @@
+source :rubygems
+gem 'sinatra'
View
51 index.php
@@ -1,51 +0,0 @@
-<!DOCTYPE html>
-<head>
-<meta charset="utf-8">
-<title>Pattern Primer</title>
-<link rel="stylesheet" href="global.css">
-<style>
-.pattern {
- clear: both;
- overflow: hidden;
-}
-.pattern .display {
- width: 65%;
- float: left;
-}
-.pattern .source {
- width: 30%;
- float: right;
-}
-.pattern .source textarea {
- width: 90%;
-}
-</style>
-</head>
-<body>
-
-<?php
-$files = array();
-$handle=opendir('patterns');
-while (false !== ($file = readdir($handle))):
- if(stristr($file,'.html')):
- $files[] = $file;
- endif;
-endwhile;
-sort($files);
-foreach ($files as $file):
- echo '<div class="pattern">';
- echo '<div class="display">';
- include('patterns/'.$file);
- echo '</div>';
- echo '<div class="source">';
- echo '<textarea rows="6" cols="30">';
- echo htmlspecialchars(file_get_contents('patterns/'.$file));
- echo '</textarea>';
- echo '<p><a href="patterns/'.$file.'">'.$file.'</a></p>';
- echo '</div>';
- echo '</div>';
-endforeach;
-?>
-
-</body>
-</html>
View
0  patterns/blockquote.html 100644 → 100755
File mode changed
View
0  patterns/feedback-error.html 100644 → 100755
File mode changed
View
0  patterns/feedback.html 100644 → 100755
File mode changed
View
0  patterns/form-buttons.html 100644 → 100755
File mode changed
View
0  patterns/form-checkbox.html 100644 → 100755
File mode changed
View
0  patterns/form-email.html 100644 → 100755
File mode changed
View
0  patterns/form-number.html 100644 → 100755
File mode changed
View
0  patterns/form-select.html 100644 → 100755
File mode changed
View
0  patterns/form-text.html 100644 → 100755
File mode changed
View
0  patterns/form-textarea.html 100644 → 100755
File mode changed
View
0  patterns/form-url.html 100644 → 100755
File mode changed
View
0  patterns/heading-1.html 100644 → 100755
File mode changed
View
0  patterns/heading-2.html 100644 → 100755
File mode changed
View
0  patterns/heading-3.html 100644 → 100755
File mode changed
View
0  patterns/heading-4.html 100644 → 100755
File mode changed
View
0  patterns/heading-5.html 100644 → 100755
File mode changed
View
0  patterns/heading-6.html 100644 → 100755
File mode changed
View
0  patterns/list-ordered.html 100644 → 100755
File mode changed
View
0  patterns/list-unordered.html 100644 → 100755
File mode changed
View
0  patterns/pagination-first.html 100644 → 100755
File mode changed
View
0  patterns/pagination-last.html 100644 → 100755
File mode changed
View
0  patterns/pagination.html 100644 → 100755
File mode changed
View
0  patterns/text.html 100644 → 100755
File mode changed
View
0  global.css → public/style.css
File renamed without changes
View
37 views/index.erb
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+<title>Pattern Primer</title>
+<link rel="stylesheet" href="/style.css">
+<style>
+.pattern {
+ clear: both;
+ overflow: hidden;
+}
+.pattern .display {
+ width: 65%;
+ float: left;
+}
+.pattern .source {
+ width: 30%;
+ float: right;
+}
+.pattern .source textarea {
+ width: 90%;
+}
+</style>
+</head>
+<body>
+ <% Dir.foreach(Dir.pwd + '/patterns/') do |fname| %>
+ <% next if fname == '.' or fname == '..' or fname == '.DS_Store' %>
+ <div class="pattern">
+ <div class="display">
+ <%= File.read(File.join('patterns/', fname)) %>
+ </div>
+ <div class="source">
+ <textarea rows="6" cols="30"><%= File.read(File.join('patterns/', fname)) %></textarea>
+ </div>
+ </div>
+ <% end %>
+</body>
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.