Initial commit

This commit is contained in:
Will Bradley 2011-09-28 03:37:39 -07:00
commit b1fbb339c2
373 changed files with 52305 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
db/*.sqlite3
log/*.log
tmp/**/*

243
README Normal file
View File

@ -0,0 +1,243 @@
== Welcome to Rails
Rails is a web-application framework that includes everything needed to create
database-backed web applications according to the Model-View-Control pattern.
This pattern splits the view (also called the presentation) into "dumb" templates
that are primarily responsible for inserting pre-built data in between HTML tags.
The model contains the "smart" domain objects (such as Account, Product, Person,
Post) that holds all the business logic and knows how to persist themselves to
a database. The controller handles the incoming requests (such as Save New Account,
Update Product, Show Post) by manipulating the model and directing data to the view.
In Rails, the model is handled by what's called an object-relational mapping
layer entitled Active Record. This layer allows you to present the data from
database rows as objects and embellish these data objects with business logic
methods. You can read more about Active Record in
link:files/vendor/rails/activerecord/README.html.
The controller and view are handled by the Action Pack, which handles both
layers by its two parts: Action View and Action Controller. These two layers
are bundled in a single package due to their heavy interdependence. This is
unlike the relationship between the Active Record and Action Pack that is much
more separate. Each of these packages can be used independently outside of
Rails. You can read more about Action Pack in
link:files/vendor/rails/actionpack/README.html.
== Getting Started
1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
and your application name. Ex: rails myapp
2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!"
4. Follow the guidelines to start developing your application
== Web Servers
By default, Rails will try to use Mongrel if it's are installed when started with script/server, otherwise Rails will use WEBrick, the webserver that ships with Ruby. But you can also use Rails
with a variety of other web servers.
Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
More info at: http://mongrel.rubyforge.org
Say other Ruby web servers like Thin and Ebb or regular web servers like Apache or LiteSpeed or
Lighttpd or IIS. The Ruby web servers are run through Rack and the latter can either be setup to use
FCGI or proxy to a pack of Mongrels/Thin/Ebb servers.
== Apache .htaccess example for FCGI/CGI
# General Apache options
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI
# If you don't want Rails to look in certain directories,
# use the following rewrite rules so that Apache won't rewrite certain requests
#
# Example:
# RewriteCond %{REQUEST_URI} ^/notrails.*
# RewriteRule .* - [L]
# Redirect all requests not available on the filesystem to Rails
# By default the cgi dispatcher is used which is very slow
#
# For better performance replace the dispatcher with the fastcgi one
#
# Example:
# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
RewriteEngine On
# If your Rails application is accessed via an Alias directive,
# then you MUST also set the RewriteBase in this htaccess file.
#
# Example:
# Alias /myrailsapp /path/to/myrailsapp/public
# RewriteBase /myrailsapp
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
# In case Rails experiences terminal errors
# Instead of displaying this message you can supply a file here which will be rendered instead
#
# Example:
# ErrorDocument 500 /500.html
ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
== Debugging Rails
Sometimes your application goes wrong. Fortunately there are a lot of tools that
will help you debug it and get it back on the rails.
First area to check is the application log files. Have "tail -f" commands running
on the server.log and development.log. Rails will automatically display debugging
and runtime information to these files. Debugging info will also be shown in the
browser on requests from 127.0.0.1.
You can also log your own messages directly into the log file from your code using
the Ruby logger class from inside your controllers. Example:
class WeblogController < ActionController::Base
def destroy
@weblog = Weblog.find(params[:id])
@weblog.destroy
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
end
end
The result will be a message in your log file along the lines of:
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
More information on how to use the logger is at http://www.ruby-doc.org/core/
Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
* The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
These two online (and free) books will bring you up to speed on the Ruby language
and also on programming in general.
== Debugger
Debugger support is available through the debugger command when you start your Mongrel or
Webrick server with --debugger. This means that you can break out of execution at any point
in the code, investigate and change the model, AND then resume execution!
You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
Example:
class WeblogController < ActionController::Base
def index
@posts = Post.find(:all)
debugger
end
end
So the controller will accept the action, run the first line, then present you
with a IRB prompt in the server window. Here you can do things like:
>> @posts.inspect
=> "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
#<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
>> @posts.first.title = "hello from a debugger"
=> "hello from a debugger"
...and even better is that you can examine how your runtime objects actually work:
>> f = @posts.first
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
>> f.
Display all 152 possibilities? (y or n)
Finally, when you're ready to resume execution, you enter "cont"
== Console
You can interact with the domain model by starting the console through <tt>script/console</tt>.
Here you'll have all parts of the application configured, just like it is when the
application is running. You can inspect domain models, change values, and save to the
database. Starting the script without arguments will launch it in the development environment.
Passing an argument will specify a different environment, like <tt>script/console production</tt>.
To reload your controllers and models after launching the console run <tt>reload!</tt>
== dbconsole
You can go to the command line of your database directly through <tt>script/dbconsole</tt>.
You would be connected to the database with the credentials defined in database.yml.
Starting the script without arguments will connect you to the development database. Passing an
argument will connect you to a different database, like <tt>script/dbconsole production</tt>.
Currently works for mysql, postgresql and sqlite.
== Description of Contents
app
Holds all the code that's specific to this particular application.
app/controllers
Holds controllers that should be named like weblogs_controller.rb for
automated URL mapping. All controllers should descend from ApplicationController
which itself descends from ActionController::Base.
app/models
Holds models that should be named like post.rb.
Most models will descend from ActiveRecord::Base.
app/views
Holds the template files for the view that should be named like
weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby
syntax.
app/views/layouts
Holds the template files for layouts to be used with views. This models the common
header/footer method of wrapping views. In your views, define a layout using the
<tt>layout :default</tt> and create a file named default.html.erb. Inside default.html.erb,
call <% yield %> to render the view using this layout.
app/helpers
Holds view helpers that should be named like weblogs_helper.rb. These are generated
for you automatically when using script/generate for controllers. Helpers can be used to
wrap functionality for your views into methods.
config
Configuration files for the Rails environment, the routing map, the database, and other dependencies.
db
Contains the database schema in schema.rb. db/migrate contains all
the sequence of Migrations for your schema.
doc
This directory is where your application documentation will be stored when generated
using <tt>rake doc:app</tt>
lib
Application specific libraries. Basically, any kind of custom code that doesn't
belong under controllers, models, or helpers. This directory is in the load path.
public
The directory available for the web server. Contains subdirectories for images, stylesheets,
and javascripts. Also contains the dispatchers and the default HTML files. This should be
set as the DOCUMENT_ROOT of your web server.
script
Helper scripts for automation and generation.
test
Unit and functional tests along with fixtures. When using the script/generate scripts, template
test files will be generated for you and placed in this directory.
vendor
External libraries that the application depends on. Also includes the plugins subdirectory.
If the app has frozen rails, those gems also go here, under vendor/rails/.
This directory is in the load path.

10
Rakefile Normal file
View File

@ -0,0 +1,10 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'

View File

@ -0,0 +1,10 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
# Scrub sensitive parameters from your log
# filter_parameter_logging :password
end

View File

@ -0,0 +1,86 @@
class ContractTemplatesController < ApplicationController
# GET /contract_templates
# GET /contract_templates.xml
def index
@contract_templates = ContractTemplate.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @contract_templates }
end
end
# GET /contract_templates/1
# GET /contract_templates/1.xml
def show
@contract_template = ContractTemplate.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @contract_template }
format.text do
render :text => @contract_template.boilerplate
end
end
end
# GET /contract_templates/new
# GET /contract_templates/new.xml
def new
@contract_template = ContractTemplate.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @contract_template }
end
end
# GET /contract_templates/1/edit
def edit
@contract_template = ContractTemplate.find(params[:id])
end
# POST /contract_templates
# POST /contract_templates.xml
def create
@contract_template = ContractTemplate.new(params[:contract_template])
respond_to do |format|
if @contract_template.save
format.html { redirect_to(@contract_template, :notice => 'ContractTemplate was successfully created.') }
format.xml { render :xml => @contract_template, :status => :created, :location => @contract_template }
else
format.html { render :action => "new" }
format.xml { render :xml => @contract_template.errors, :status => :unprocessable_entity }
end
end
end
# PUT /contract_templates/1
# PUT /contract_templates/1.xml
def update
@contract_template = ContractTemplate.find(params[:id])
respond_to do |format|
if @contract_template.update_attributes(params[:contract_template])
format.html { redirect_to(@contract_template, :notice => 'ContractTemplate was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @contract_template.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /contract_templates/1
# DELETE /contract_templates/1.xml
def destroy
@contract_template = ContractTemplate.find(params[:id])
@contract_template.destroy
respond_to do |format|
format.html { redirect_to(contract_templates_url) }
format.xml { head :ok }
end
end
end

View File

@ -0,0 +1,90 @@
class ContractsController < ApplicationController
# GET /contracts
# GET /contracts.xml
def index
@contracts = Contract.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @contracts }
end
end
# GET /contracts/1
# GET /contracts/1.xml
def show
@contract = Contract.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @contract }
end
end
# GET /contracts/new
# GET /contracts/new.xml
def new
@contract = Contract.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @contract }
end
end
# GET /contracts/1/edit
def edit
@contract = Contract.find(params[:id])
end
# POST /contracts
# POST /contracts.xml
def create
@contract = Contract.new(params[:contract])
@contract_template = ContractTemplate.find(params[:boilerplateid])
@contract.name = @contract_template.name
@contract.boilerplate = @contract_template.boilerplate
@contract.datesigned = Time.current
@contract.signinghash = Digest::SHA1.hexdigest @contract.boilerplate+@contract.signature+@contract.datesigned.to_s
respond_to do |format|
if @contract.save
format.html { redirect_to(@contract, :notice => 'Contract was successfully created.') }
format.xml { render :xml => @contract, :status => :created, :location => @contract }
else
format.html { render :action => "new" }
format.xml { render :xml => @contract.errors, :status => :unprocessable_entity }
end
end
end
# PUT /contracts/1
# PUT /contracts/1.xml
def update
@contract = Contract.find(params[:id])
respond_to do |format|
# if @contract.update_attributes(params[:contract])
# format.html { redirect_to(@contract, :notice => 'Contract was successfully updated.') }
# format.xml { head :ok }
# else
format.html { redirect_to(@contract, :notice => 'Contracts cannot be edited.') }
format.xml { render :xml => @contract.errors, :status => :unprocessable_entity }
# end
end
end
# DELETE /contracts/1
# DELETE /contracts/1.xml
def destroy
@contract = Contract.find(params[:id])
@contract.destroy
respond_to do |format|
format.html { redirect_to(contracts_url) }
format.xml { head :ok }
end
end
end

View File

@ -0,0 +1,26 @@
class QuicksignController < ApplicationController
def new
@contract = Contract.new
@contract.signer = Signer.new
respond_to do |format|
format.html # new.html.erb
end
end
def create
@contract = Contract.new(params[:contract])
@contract.datesigned = Time.current
@contract.signinghash = Digest::SHA1.hexdigest @contract.boilerplate+@contract.signature+@contract.datesigned.to_s
@contract.save
respond_to do |format|
format.html { redirect_to(@contract, :notice => 'Contract was successfully created.') }
end
end
end

View File

@ -0,0 +1,83 @@
class SignersController < ApplicationController
# GET /signers
# GET /signers.xml
def index
@signers = Signer.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @signers }
end
end
# GET /signers/1
# GET /signers/1.xml
def show
@signer = Signer.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @signer }
end
end
# GET /signers/new
# GET /signers/new.xml
def new
@signer = Signer.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @signer }
end
end
# GET /signers/1/edit
def edit
@signer = Signer.find(params[:id])
end
# POST /signers
# POST /signers.xml
def create
@signer = Signer.new(params[:signer])
respond_to do |format|
if @signer.save
format.html { redirect_to(@signer, :notice => 'Signer was successfully created.') }
format.xml { render :xml => @signer, :status => :created, :location => @signer }
else
format.html { render :action => "new" }
format.xml { render :xml => @signer.errors, :status => :unprocessable_entity }
end
end
end
# PUT /signers/1
# PUT /signers/1.xml
def update
@signer = Signer.find(params[:id])
respond_to do |format|
if @signer.update_attributes(params[:signer])
format.html { redirect_to(@signer, :notice => 'Signer was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @signer.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /signers/1
# DELETE /signers/1.xml
def destroy
@signer = Signer.find(params[:id])
@signer.destroy
respond_to do |format|
format.html { redirect_to(signers_url) }
format.xml { head :ok }
end
end
end

View File

@ -0,0 +1,3 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end

View File

@ -0,0 +1,2 @@
module ContractTemplatesHelper
end

View File

@ -0,0 +1,2 @@
module ContractsHelper
end

View File

@ -0,0 +1,2 @@
module SignersHelper
end

View File

@ -0,0 +1,2 @@
module TemplatesHelper
end

4
app/models/contract.rb Normal file
View File

@ -0,0 +1,4 @@
class Contract < ActiveRecord::Base
belongs_to :signer
accepts_nested_attributes_for :signer
end

View File

@ -0,0 +1,2 @@
class ContractTemplate < ActiveRecord::Base
end

3
app/models/signer.rb Normal file
View File

@ -0,0 +1,3 @@
class Signer < ActiveRecord::Base
has_many :contracts
end

View File

@ -0,0 +1,29 @@
<!-- TinyMCE -->
<script type="text/javascript" src="/javascripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "simple"
});
</script>
<!-- /TinyMCE -->
<h1>Editing contract_template</h1>
<% form_for(@contract_template) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.label :boilerplate %><br />
<%= f.text_area :boilerplate %>
</p>
<p>
<%= f.submit 'Edit' %>
</p>
<% end %>
<%= link_to 'Back', contract_templates_path %>

View File

@ -0,0 +1,22 @@
<h1>Listing contract_templates</h1>
<table>
<tr>
<th>Name</th>
<th>Boilerplate</th>
</tr>
<% @contract_templates.each do |contract_template| %>
<tr>
<td><%=h contract_template.name %></td>
<td><%= truncate(contract_template.boilerplate, :length => 1000) %></td>
<td><%= link_to 'Show', contract_template %></td>
<td><%= link_to 'Edit', edit_contract_template_path(contract_template) %></td>
<td><%= link_to 'Destroy', contract_template, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New contract_template', new_contract_template_path %>

View File

@ -0,0 +1,29 @@
<!-- TinyMCE -->
<script type="text/javascript" src="/javascripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "simple"
});
</script>
<!-- /TinyMCE -->
<h1>New contract_template</h1>
<% form_for(@contract_template) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.label :boilerplate %><br />
<%= f.text_area :boilerplate %>
</p>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
<%= link_to 'Back', contract_templates_path %>

View File

@ -0,0 +1 @@
<%=@contract_template.boilerplate %>

View File

@ -0,0 +1,24 @@
<h1>Editing contract</h1>
<% form_for(@contract) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :boilerplate %><br />
<%= f.text_field :boilerplate %>
</p>
<p>
<%= f.label :signature %><br />
<%= f.text_field :signature %>
</p>
<p>
<%= f.label :signinghash %><br />
<%= f.text_field :signinghash %>
</p>
<p>
<%= f.submit 'Update' %>
</p>
<% end %>
<%= link_to 'Show', @contract %> |
<%= link_to 'Back', contracts_path %>

View File

@ -0,0 +1,24 @@
<h1>Listing contracts</h1>
<table>
<tr>
<th>Date</th>
<th>Name</th>
<th>Signer</th>
</tr>
<% @contracts.each do |contract| %>
<tr>
<td><%=h contract.datesigned %></td>
<td><%=h contract.name %></td>
<td><% if(!contract.signer.blank?) then %><%=h contract.signer.first_name %> <%=h contract.signer.last_name %><% end %></td>
<td><%= link_to 'Show', contract %></td>
<td><%= link_to 'Edit', edit_contract_path(contract) %></td>
<td><%= link_to 'Destroy', contract, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New contract', new_contract_path %>

View File

@ -0,0 +1,182 @@
<script language="javascript">
function showboiler(id) {
if(id>0) {
$.ajax({
url: "/contract_templates/"+id+".txt",
context: document.body,
success: function(data){
document.getElementById('boilerdisplay').innerHTML = data;
document.getElementById('contract_boilerplate').value = data;
}
});
}
else {
document.getElementById('boilerdisplay').innerHTML = "";
document.getElementById('contract_boilerplate').value = "";
}
}
function clearme() {
context.clearRect(0, 0, canvas.width, canvas.height);
context.beginPath();
}
</script>
<% form_for(@contract) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :Template %>
<%= select_tag("boilerplate_select", options_for_select(ContractTemplate.all.collect{ |c| [c.name, c.id] }.insert(0, '')), {:onchange => "showboiler(this.value)"}) %>
<%= f.hidden_field :signature %>
<%= f.hidden_field :boilerplate %>
</p>
<div id="boilerdisplay"></div>
<meta name = "viewport" content = "width = device-width">
<style type="text/css">
html, body {
margin:0;
padding:0;
}
#canvas {
border: 1px solid black;
}
</style>
<body id="body">
<input type="button" value="Clear" onclick="clearme()" />
<div id="container"> <!-- container. start -->
<canvas width="800" height="200" id="canvas">
</canvas>
</div><!-- container. end -->
<!-- <p id="debug"></p> -->
<p>
<%= f.submit 'Update' %>
</p>
<% end %>
<%= link_to 'Back', contracts_path %>
<!-- JavaScript -->
<script type="text/javascript" src="/javascripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
var oldX,oldY,sofX,sofY,down=false,drag=false;
var q = new Array;
var body = document.getElementById("body");
var canvas = document.getElementById("canvas");
var context = canvas.getContext('2d');
body.addEventListener("touchmove", touch, false);
canvas.addEventListener("touchstart", touchStart, false);
canvas.addEventListener("touchmove", touchMove, false);
canvas.addEventListener("touchend", drawEnd, false);
canvas.addEventListener("touchcancel", drawEnd, false);
body.addEventListener('mouseup', drawEnd);
canvas.addEventListener('mousedown', mouseDown);
canvas.addEventListener('mousemove', mouseMove);
canvas.addEventListener('mouseup', drawEnd);
function touch(event) {
// console.log(event);
event.preventDefault();
element = document.getElementById("debug");
element.innerHTML = event.touches.length+" touch ("+event.touches[0].pageX+","+event.touches[0].pageY+")("+$(canvas).offset().left+","+$(canvas).offset().top+") down:"+down+" drag:"+drag;
}
function touchStart(event) {
touch(event);
drawStart([event.touches[0].pageX - $(canvas).offset().left,event.touches[0].pageY - $(canvas).offset().top]);
}
function mouseDown(event) {
drawStart([event.pageX - $(canvas).offset().left,event.pageY - $(canvas).offset().top]);
element = document.getElementById("debug");
element.innerHTML = q.length+" ("+event.pageX+","+event.pageY+")("+$(canvas).offset().left+","+$(canvas).offset().top+") down:"+down+" drag:"+drag;
}
function drawStart(point) {
var x=point[0], y=point[1];
q = [point];
down = true;
context.lineWidth = 1;
context.strokeStyle = '#000000';
}
function touchMove(event) {
touch(event);
drawMove([event.touches[0].pageX - $(canvas).offset().left,event.touches[0].pageY - $(canvas).offset().top]);
};
function mouseMove(event) {
drawMove([event.pageX - $(canvas).offset().left,event.pageY - $(canvas).offset().top]);
}
function drawMove(point) {
var x=point[0], y=point[1];
drag=true;
if(down && drag && q.length>=4) {
q.push(point);
// context.fillRect(q[1][0], q[1][1], 1, 1);
// context.fillRect(q[2][0], q[2][1], 1, 1);
context.beginPath();
context.moveTo(q[0][0], q[0][1]);
context.bezierCurveTo(q[1][0], q[1][1], q[2][0], q[2][1], q[3][0], q[3][1]);
q.shift();
q.shift();
q.shift();
// context.closePath();
context.stroke();
} else if(down && drag) {
q.push(point);
}
oldX = x;
oldY = y;
sofX = oldX;
sofY = oldY;
}
// Finished drawing (mouse up)
function drawEnd(event) {
// touch(event);
if(q.length>=2) {
if(q.length==4){
context.bezierCurveTo(q[1][0], q[1][1], q[2][0], q[2][1], q[3][0], q[3][1]);
}
if(q.length==3){
context.quadraticCurveTo(q[1][0], q[1][1],q[2][0], q[2][1]);
}
if(q.length==2){
context.lineTo(q[1][0], q[1][1]);
}
context.stroke();
q=[];
}
if(down && drag==false || q.length==1) {
// context.fillRect(q[0][0],q[0][1], 2, 2);
context.beginPath();
context.arc(q[0][0],q[0][1],1,0,Math.PI*2,true);
context.closePath();
context.stroke();
context.fill();
}
down = false;
drag = false;
// Write the canvas to a data url
$("#contract_signature")[0].value = canvas.toDataURL("image/png")
}
</script>
</body>
</html>

View File

@ -0,0 +1,23 @@
<h1>New contract</h1>
<% form_for(@contract) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :boilerplate %><br />
<%= f.text_field :boilerplate %>
</p>
<p>
<%= f.label :signature %><br />
<%= f.text_field :signature %>
</p>
<p>
<%= f.label :signinghash %><br />
<%= f.text_field :signinghash %>
</p>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
<%= link_to 'Back', contracts_path %>

View File

@ -0,0 +1,27 @@
<p>
<b>Boilerplate:</b>
<%=@contract.boilerplate %>
</p>
<p>
<b>Signature:</b>
<img src="<%=@contract.signature %>" />
</p>
<p>
<b>Date Signed:</b>
<%=h @contract.datesigned %>
</p>
<p>
<b>Hash:</b>
<%=h @contract.signinghash %>
</p>
<p>
<b>Verification:</b>
<%=Digest::SHA1.hexdigest @contract.boilerplate+@contract.signature+@contract.datesigned.to_s%>
</p>
<%= link_to 'Edit', edit_contract_path(@contract) %> |
<%= link_to 'Back', contracts_path %>

View File

@ -0,0 +1,23 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title><%= controller.controller_name.capitalize %>: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold' %>
</head>
<body>
<div id="topnav">
<b><a href="/quicksign/new">Quicksign</a></b>
<a href="/signers">Signers</a>
<a href="/contracts">Contracts</a>
<a href="/contract_templates">Templates</a>
</div>
<p style="color: green"><%= notice %></p>
<%= yield %>
</body>
</html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title><%= controller.controller_name.capitalize %>: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold' %>
</head>
<body>
<div id="topnav">
<b><a href="/quicksign/new">Quicksign</a></b>
<a href="/signers">Signers</a>
<a href="/contracts">Contracts</a>
<a href="/contract_templates">Templates</a>
</div>
<p style="color: green"><%= notice %></p>
<%= yield %>
</body>
</html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Signers: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold' %>
</head>
<body>
<div id="topnav">
<b><a href="/quicksign/new">Quicksign</a></b>
<a href="/signers">Signers</a>
<a href="/contracts">Contracts</a>
<a href="/contract_templates">Templates</a>
</div>
<p style="color: green"><%= notice %></p>
<%= yield %>
</body>
</html>

View File

@ -0,0 +1,215 @@
<script language="javascript">
function showboiler(id) {
if(id>0) {
$.ajax({
url: "/contract_templates/"+id+".txt",
context: document.body,
success: function(data){
document.getElementById('boilerdisplay').innerHTML = data;
document.getElementById('boilerplateid').value = id;
}
});
}
else {
document.getElementById('boilerdisplay').innerHTML = "";
document.getElementById('boilerplateid').value = "";
}
}
function clearme() {
context.clearRect(0, 0, canvas.width, canvas.height);
context.beginPath();
}
</script>
<style type="text/css">
html, body {
margin:0;
padding:0;
font-size: 1.2em;
font-family: Arial, Helvetica, sans-serif;
}
#canvas {
border: 1px solid black;
}
#boilerdisplay {
height: 45%;
overflow: scroll;
font-size: 20pt !important;
}
input,select { width: 40%; font-size: 1.2em; }
p { margin: 0.2em 0; }
</style>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="user-scalable=no, width=device-width" />
<link rel="apple-touch-icon" href="./apple-touch-icon.png" />
<body id="body">
<% form_for(@contract) do |f| %>
<%= f.error_messages %>
<% f.fields_for :signer do |signer_fields| %>
<p>
First Name:
<%= signer_fields.text_field :first_name %>
</p>
<p>
Last Name:
<%= signer_fields.text_field :last_name %>
</p>
<p>
Minor:
<%= signer_fields.text_field :cosigner %>
(if applicable)
</p>
<% end %>
<p>
<%= f.label :Contract %>
<%= select_tag("boilerplate_select", options_for_select(ContractTemplate.all.collect{ |c| [c.name, c.id] }.insert(0, '')), {:onchange => "showboiler(this.value)"}) %>
<%= f.hidden_field :signature %>
<%= hidden_field_tag :boilerplateid %>
</p>
<div id="boilerdisplay"></div>
<div id="container"> <!-- container. start -->
<canvas width="800" height="200" id="canvas">
</canvas>
</div><!-- container. end -->
<!-- <p id="debug"></p> -->
<p>
<input type="button" value="Clear Signature" onclick="clearme()" /> <%= f.submit 'Submit' %>
</p>
<% end %>
<%= link_to 'Back', contracts_path %>
<!-- JavaScript -->
<script type="text/javascript" src="/javascripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
var oldX,oldY,sofX,sofY,down=false,drag=false;
var q = new Array;
var body = document.getElementById("body");
var canvas = document.getElementById("canvas");
var context = canvas.getContext('2d');
// body.addEventListener("touchmove", touch, false);
canvas.addEventListener("touchstart", touchStart, false);
canvas.addEventListener("touchmove", touchMove, false);
canvas.addEventListener("touchend", drawEnd, false);
canvas.addEventListener("touchcancel", drawEnd, false);
body.addEventListener('mouseup', drawEnd);
canvas.addEventListener('mousedown', mouseDown);
canvas.addEventListener('mousemove', mouseMove);
canvas.addEventListener('mouseup', drawEnd);
function touch(event) {
// console.log(event);
event.preventDefault();
// element = document.getElementById("debug");
// element.innerHTML = event.touches.length+" touch ("+event.touches[0].pageX+","+event.touches[0].pageY+")("+$(canvas).offset().left+","+$(canvas).offset().top+") down:"+down+" drag:"+drag;
}
function touchStart(event) {
touch(event);
drawStart([event.touches[0].pageX - $(canvas).offset().left,event.touches[0].pageY - $(canvas).offset().top]);
}
function mouseDown(event) {
drawStart([event.pageX - $(canvas).offset().left,event.pageY - $(canvas).offset().top]);
// element = document.getElementById("debug");
// element.innerHTML = q.length+" ("+event.pageX+","+event.pageY+")("+$(canvas).offset().left+","+$(canvas).offset().top+") down:"+down+" drag:"+drag;
}
function drawStart(point) {
var x=point[0], y=point[1];
q = [point];
down = true;
context.lineWidth = 1;
context.strokeStyle = '#000000';
}
function touchMove(event) {
touch(event);
drawMove([event.touches[0].pageX - $(canvas).offset().left,event.touches[0].pageY - $(canvas).offset().top]);
};
function mouseMove(event) {
drawMove([event.pageX - $(canvas).offset().left,event.pageY - $(canvas).offset().top]);
}
function drawMove(point) {
var x=point[0], y=point[1];
drag=true;
if(down && drag && q.length>=4) {
q.push(point);
// context.fillRect(q[1][0], q[1][1], 1, 1);
// context.fillRect(q[2][0], q[2][1], 1, 1);
context.beginPath();
context.moveTo(q[0][0], q[0][1]);
context.bezierCurveTo(q[1][0], q[1][1], q[2][0], q[2][1], q[3][0], q[3][1]);
q.shift();
q.shift();
q.shift();
// context.closePath();
context.stroke();
} else if(down && drag) {
q.push(point);
}
oldX = x;
oldY = y;
sofX = oldX;
sofY = oldY;
}
// Finished drawing (mouse up)
function drawEnd(event) {
// touch(event);
if(q.length>=2) {
if(q.length==4){
context.bezierCurveTo(q[1][0], q[1][1], q[2][0], q[2][1], q[3][0], q[3][1]);
}
if(q.length==3){
context.quadraticCurveTo(q[1][0], q[1][1],q[2][0], q[2][1]);
}
if(q.length==2){
context.lineTo(q[1][0], q[1][1]);
}
context.stroke();
q=[];
}
if(down && drag==false || q.length==1) {
// context.fillRect(q[0][0],q[0][1], 2, 2);
context.beginPath();
context.arc(q[0][0],q[0][1],1,0,Math.PI*2,true);
context.closePath();
context.stroke();
context.fill();
}
down = false;
drag = false;
// Write the canvas to a data url
$("#contract_signature")[0].value = canvas.toDataURL("image/png")
}
</script>
</body>
</html>

View File

@ -0,0 +1,24 @@
<h1>Editing signer</h1>
<% form_for(@signer) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :first_name %><br />
<%= f.text_field :first_name %>
</p>
<p>
<%= f.label :last_name %><br />
<%= f.text_field :last_name %>
</p>
<p>
<%= f.label :cosigner %><br />
<%= f.text_field :cosigner %>
</p>
<p>
<%= f.submit 'Update' %>
</p>
<% end %>
<%= link_to 'Show', @signer %> |
<%= link_to 'Back', signers_path %>

View File

@ -0,0 +1,24 @@
<h1>Listing signers</h1>
<table>
<tr>
<th>First name</th>
<th>Last name</th>
<th>Cosigner</th>
</tr>
<% @signers.each do |signer| %>
<tr>
<td><%=h signer.first_name %></td>
<td><%=h signer.last_name %></td>
<td><%=h signer.cosigner %></td>
<td><%= link_to 'Show', signer %></td>
<td><%= link_to 'Edit', edit_signer_path(signer) %></td>
<td><%= link_to 'Destroy', signer, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New signer', new_signer_path %>

View File

@ -0,0 +1,23 @@
<h1>New signer</h1>
<% form_for(@signer) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :first_name %><br />
<%= f.text_field :first_name %>
</p>
<p>
<%= f.label :last_name %><br />
<%= f.text_field :last_name %>
</p>
<p>
<%= f.label :cosigner %><br />
<%= f.text_field :cosigner %>
</p>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
<%= link_to 'Back', signers_path %>

View File

@ -0,0 +1,25 @@
<p>
<b>First name:</b>
<%=h @signer.first_name %>
</p>
<p>
<b>Last name:</b>
<%=h @signer.last_name %>
</p>
<p>
<b>Cosigner:</b>
<%=h @signer.cosigner %>
</p>
<b>Contracts:</b>
<ul>
<% @signer.contracts.each do |c| %>
<li><%= link_to c.name, contract_path(c) %> (<%= c.datesigned %>)</li>
<% end %>
</ul>
<%= link_to 'Edit', edit_signer_path(@signer) %> |
<%= link_to 'Back', signers_path %>

110
config/boot.rb Normal file
View File

@ -0,0 +1,110 @@
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
defined? Rails::Initializer
end
def pick_boot
(vendor_rails? ? VendorBoot : GemBoot).new
end
def vendor_rails?
File.exist?("#{RAILS_ROOT}/vendor/rails")
end
def preinitialize
load(preinitializer_path) if File.exist?(preinitializer_path)
end
def preinitializer_path
"#{RAILS_ROOT}/config/preinitializer.rb"
end
end
class Boot
def run
load_initializer
Rails::Initializer.run(:set_load_path)
end
end
class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
Rails::GemDependency.add_frozen_gem_path
end
end
class GemBoot < Boot
def load_initializer
self.class.load_rubygems
load_rails_gem
require 'initializer'
end
def load_rails_gem
if version = self.class.gem_version
gem 'rails', version
else
gem 'rails'
end
rescue Gem::LoadError => load_error
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
exit 1
end
class << self
def rubygems_version
Gem::RubyGemsVersion rescue nil
end
def gem_version
if defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION
elsif ENV.include?('RAILS_GEM_VERSION')
ENV['RAILS_GEM_VERSION']
else
parse_gem_version(read_environment_rb)
end
end
def load_rubygems
min_version = '1.3.2'
require 'rubygems'
unless rubygems_version >= min_version
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1
end
rescue LoadError
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
exit 1
end
def parse_gem_version(text)
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
end
private
def read_environment_rb
File.read("#{RAILS_ROOT}/config/environment.rb")
end
end
end
end
# All that for this:
Rails.boot!

22
config/database.yml Normal file
View File

@ -0,0 +1,22 @@
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000

41
config/environment.rb Normal file
View File

@ -0,0 +1,41 @@
# Be sure to restart your server when you modify this file
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{RAILS_ROOT}/extras )
# Specify gems that this application depends on and have them installed with rake gems:install
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "sqlite3-ruby", :lib => "sqlite3"
# config.gem "aws-s3", :lib => "aws/s3"
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Skip frameworks you're not going to use. To use Rails without a database,
# you must remove the Active Record framework.
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names.
config.time_zone = 'UTC'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
# config.i18n.default_locale = :de
end

View File

@ -0,0 +1,17 @@
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

View File

@ -0,0 +1,28 @@
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.action_controller.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.action_view.cache_template_loading = true
# See everything in the log (default is :info)
# config.log_level = :debug
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new