Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 42b82e59747482a4177ef7b2398f1c3cd2df8ffc 1 parent 453fa2c
@adamlogic authored
View
20 MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2009 [name of plugin creator]
+
+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.
View
23 Rakefile
@@ -0,0 +1,23 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the showoff plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.libs << 'test'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the showoff plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'Showoff'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
View
48 app/controllers/mockups_controller.rb
@@ -0,0 +1,48 @@
+class MockupsController < ApplicationController
+
+ def frameset
+ render :layout => false
+ end
+
+ def index
+ @entries = ActiveSupport::OrderedHash.new
+
+ Dir.glob File.join(Rails.root, 'app', 'views', 'mockups', '**', '[^_]*.html.*') do |template|
+ parent_dir = File.dirname(template).split(/[\/]/).last
+ template_name = File.basename(template).split('.').first
+
+ if parent_dir == 'mockups'
+ @entries[template_name] = nil
+ else
+ (@entries[parent_dir] ||= []) << template_name
+ end
+ end
+
+ # @pages = template_files.map { |f| f.scan(/mockups\/([^.]+)/).flatten.first }
+
+ render :layout => false
+ end
+
+ def show
+ template_path = File.join(['mockups', params[:parent_dir], params[:template_name]].compact)
+ render :template => template_path, :layout => extract_layout(template_path)
+ end
+
+ private
+
+ def extract_layout(template_path)
+ full_path = File.join(Rails.root, 'app', 'views', template_path)
+ located_files = Dir.glob("#{full_path}*")
+
+ return true if located_files.empty?
+
+ filename_components = File.basename(located_files[0]).split('.')
+
+ if filename_components[1] == 'html'
+ true
+ else
+ filename_components[1]
+ end
+ end
+
+end
View
13 app/views/mockups/frameset.html.erb
@@ -0,0 +1,13 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+
+<head>
+ <title>Mockups</title>
+</head>
+
+<frameset cols="200,*" frameborder="1" border="1" bordercolor="#666666" framespacing="1">
+ <frame src="/mockups_index" title="List" name="list" />
+ <frame name="content" />
+</frameset>
+
+</html>
View
27 app/views/mockups/index.html.erb
@@ -0,0 +1,27 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+
+<head>
+ <%= stylesheet_link_tag 'mockups.css' %>
+</head>
+
+<body>
+ <ul id="mockups_tree">
+ <% @entries.each do |name, mockups| %>
+ <li>
+ <% if mockups.nil? %>
+ <%= link_to name.humanize, mockup_path(name), :target => 'content' %>
+ <% else %>
+ <h2><%= name.humanize.titleize %></h2>
+ <ul>
+ <% mockups.each do |mockup| %>
+ <li><%= link_to mockup.humanize, mockup_path(mockup, :parent_dir => name), :target => 'content' %></li>
+ <% end %>
+ </ul>
+ <% end %>
+ </li>
+ <% end %>
+ </ul>
+</body>
+
+</html>
View
7 config/routes.rb
@@ -0,0 +1,7 @@
+ActionController::Routing::Routes.draw do |map|
+ map.with_options :controller => 'mockups' do |mockups|
+ mockups.mockups '/mockups', :action => 'frameset'
+ mockups.mockups_index '/mockups_index', :action => 'index'
+ mockups.mockup '/mockup/:template_name', :action => 'show'
+ end
+end
View
8 generators/showoff/USAGE
@@ -0,0 +1,8 @@
+Description:
+ Explain the generator
+
+Example:
+ ./script/generate mockups Thing
+
+ This will create:
+ what/will/it/create
View
8 generators/showoff/showoff_generator.rb
@@ -0,0 +1,8 @@
+class ShowoffGenerator < Rails::Generator::NamedBase
+ def manifest
+ record do |m|
+ # m.directory "lib"
+ # m.template 'README', "README"
+ end
+ end
+end
View
5 init.rb
@@ -0,0 +1,5 @@
+
+# Since MockupsController subclasses (and thus loads) ApplicationController, we need to make sure that
+# it gets reloaded in development. Without this, things will break after the first reload.
+ActiveSupport::Dependencies.load_once_paths.delete(File.expand_path(File.dirname(__FILE__))+'/app/controllers')
+
View
8 test/showoff_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class ShowoffTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
View
3  test/test_helper.rb
@@ -0,0 +1,3 @@
+require 'rubygems'
+require 'active_support'
+require 'active_support/test_case'
Please sign in to comment.
Something went wrong with that request. Please try again.