From ab186e5130397955e4c0ea5bf5df05f3c33dd8d5 Mon Sep 17 00:00:00 2001 From: Michael Dijkstra Date: Tue, 27 Dec 2011 17:25:33 +1100 Subject: [PATCH] First commit of ruby version --- .gitignore | 1 + Gemfile.lock | 17 ++++++++++++ README.mdown | 17 +++++++++++- application.rb | 6 ++++ config.ru | 7 +++++ gemfile | 2 ++ index.php | 51 ---------------------------------- patterns/blockquote.html | 0 patterns/feedback-error.html | 0 patterns/feedback.html | 0 patterns/form-buttons.html | 0 patterns/form-checkbox.html | 0 patterns/form-email.html | 0 patterns/form-number.html | 0 patterns/form-select.html | 0 patterns/form-text.html | 0 patterns/form-textarea.html | 0 patterns/form-url.html | 0 patterns/heading-1.html | 0 patterns/heading-2.html | 0 patterns/heading-3.html | 0 patterns/heading-4.html | 0 patterns/heading-5.html | 0 patterns/heading-6.html | 0 patterns/list-ordered.html | 0 patterns/list-unordered.html | 0 patterns/pagination-first.html | 0 patterns/pagination-last.html | 0 patterns/pagination.html | 0 patterns/text.html | 0 global.css => public/style.css | 0 views/index.erb | 37 ++++++++++++++++++++++++ 32 files changed, 86 insertions(+), 52 deletions(-) create mode 100644 .gitignore create mode 100644 Gemfile.lock create mode 100644 application.rb create mode 100644 config.ru create mode 100644 gemfile delete mode 100644 index.php mode change 100644 => 100755 patterns/blockquote.html mode change 100644 => 100755 patterns/feedback-error.html mode change 100644 => 100755 patterns/feedback.html mode change 100644 => 100755 patterns/form-buttons.html mode change 100644 => 100755 patterns/form-checkbox.html mode change 100644 => 100755 patterns/form-email.html mode change 100644 => 100755 patterns/form-number.html mode change 100644 => 100755 patterns/form-select.html mode change 100644 => 100755 patterns/form-text.html mode change 100644 => 100755 patterns/form-textarea.html mode change 100644 => 100755 patterns/form-url.html mode change 100644 => 100755 patterns/heading-1.html mode change 100644 => 100755 patterns/heading-2.html mode change 100644 => 100755 patterns/heading-3.html mode change 100644 => 100755 patterns/heading-4.html mode change 100644 => 100755 patterns/heading-5.html mode change 100644 => 100755 patterns/heading-6.html mode change 100644 => 100755 patterns/list-ordered.html mode change 100644 => 100755 patterns/list-unordered.html mode change 100644 => 100755 patterns/pagination-first.html mode change 100644 => 100755 patterns/pagination-last.html mode change 100644 => 100755 patterns/pagination.html mode change 100644 => 100755 patterns/text.html rename global.css => public/style.css (100%) create mode 100644 views/index.erb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..496ee2c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..032ba48 --- /dev/null +++ b/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 diff --git a/README.mdown b/README.mdown index f6a4c64..d164aa5 100644 --- a/README.mdown +++ b/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. \ No newline at end of file +## 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 diff --git a/application.rb b/application.rb new file mode 100644 index 0000000..8c4dfc5 --- /dev/null +++ b/application.rb @@ -0,0 +1,6 @@ +require 'sinatra' +set :public_folder, File.dirname(__FILE__) + '/public' + +get '/' do + erb :index +end \ No newline at end of file diff --git a/config.ru b/config.ru new file mode 100644 index 0000000..5b19071 --- /dev/null +++ b/config.ru @@ -0,0 +1,7 @@ +require 'rubygems' +require 'bundler/setup' +require 'sinatra' + +require './application' + +run Sinatra::Application \ No newline at end of file diff --git a/gemfile b/gemfile new file mode 100644 index 0000000..79c5baf --- /dev/null +++ b/gemfile @@ -0,0 +1,2 @@ +source :rubygems +gem 'sinatra' \ No newline at end of file diff --git a/index.php b/index.php deleted file mode 100644 index 42621e9..0000000 --- a/index.php +++ /dev/null @@ -1,51 +0,0 @@ - - - -Pattern Primer - - - - - -'; - echo '
'; - include('patterns/'.$file); - echo '
'; - echo '
'; - echo ''; - echo '

'.$file.'

'; - echo '
'; - echo ''; -endforeach; -?> - - - \ No newline at end of file diff --git a/patterns/blockquote.html b/patterns/blockquote.html old mode 100644 new mode 100755 diff --git a/patterns/feedback-error.html b/patterns/feedback-error.html old mode 100644 new mode 100755 diff --git a/patterns/feedback.html b/patterns/feedback.html old mode 100644 new mode 100755 diff --git a/patterns/form-buttons.html b/patterns/form-buttons.html old mode 100644 new mode 100755 diff --git a/patterns/form-checkbox.html b/patterns/form-checkbox.html old mode 100644 new mode 100755 diff --git a/patterns/form-email.html b/patterns/form-email.html old mode 100644 new mode 100755 diff --git a/patterns/form-number.html b/patterns/form-number.html old mode 100644 new mode 100755 diff --git a/patterns/form-select.html b/patterns/form-select.html old mode 100644 new mode 100755 diff --git a/patterns/form-text.html b/patterns/form-text.html old mode 100644 new mode 100755 diff --git a/patterns/form-textarea.html b/patterns/form-textarea.html old mode 100644 new mode 100755 diff --git a/patterns/form-url.html b/patterns/form-url.html old mode 100644 new mode 100755 diff --git a/patterns/heading-1.html b/patterns/heading-1.html old mode 100644 new mode 100755 diff --git a/patterns/heading-2.html b/patterns/heading-2.html old mode 100644 new mode 100755 diff --git a/patterns/heading-3.html b/patterns/heading-3.html old mode 100644 new mode 100755 diff --git a/patterns/heading-4.html b/patterns/heading-4.html old mode 100644 new mode 100755 diff --git a/patterns/heading-5.html b/patterns/heading-5.html old mode 100644 new mode 100755 diff --git a/patterns/heading-6.html b/patterns/heading-6.html old mode 100644 new mode 100755 diff --git a/patterns/list-ordered.html b/patterns/list-ordered.html old mode 100644 new mode 100755 diff --git a/patterns/list-unordered.html b/patterns/list-unordered.html old mode 100644 new mode 100755 diff --git a/patterns/pagination-first.html b/patterns/pagination-first.html old mode 100644 new mode 100755 diff --git a/patterns/pagination-last.html b/patterns/pagination-last.html old mode 100644 new mode 100755 diff --git a/patterns/pagination.html b/patterns/pagination.html old mode 100644 new mode 100755 diff --git a/patterns/text.html b/patterns/text.html old mode 100644 new mode 100755 diff --git a/global.css b/public/style.css similarity index 100% rename from global.css rename to public/style.css diff --git a/views/index.erb b/views/index.erb new file mode 100644 index 0000000..6cce454 --- /dev/null +++ b/views/index.erb @@ -0,0 +1,37 @@ + + + +Pattern Primer + + + + + <% Dir.foreach(Dir.pwd + '/patterns/') do |fname| %> + <% next if fname == '.' or fname == '..' or fname == '.DS_Store' %> +
+
+ <%= File.read(File.join('patterns/', fname)) %> +
+
+ +
+
+ <% end %> + + \ No newline at end of file