Skip to content

Commit

Permalink
adding the rest
Browse files Browse the repository at this point in the history
  • Loading branch information
Oren Golan committed Mar 24, 2011
1 parent 9a5ff1e commit 65610d9
Show file tree
Hide file tree
Showing 15 changed files with 137 additions and 0 deletions.
10 changes: 10 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
remove config from git and update wiki
db - change :value to :content

window.owenFunctions.foo = function(){}
window['owenVars'] = { test: 'string' }





17 changes: 17 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'sinatra'
require_relative 'routes/init'
require_relative 'helpers/init'
require_relative 'models/init'

class MyApp < Sinatra::Base
configure :development do
end

configure :qa do
end

configure :production do
end

end

4 changes: 4 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require File.join(File.dirname(__FILE__), 'app.rb')
run MyApp.new


29 changes: 29 additions & 0 deletions helpers/helper1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
def clear; '<div class="clear"><!-- --></div>' end

This comment has been minimized.

Copy link
@namelessjon

namelessjon Jun 20, 2011

Shouldn't these helpers be in a module (or at least a helpers do ... end block) so they're properly scoped to give access to the session, etc?

This comment has been minimized.

Copy link
@oren

oren Jun 20, 2011

Owner

good call! it should be in the helpers block.


def update_session
session[:path] = params['project']

comma = params['project'] =~ /,/
if comma
session[:project] = params['project'].slice(0,comma)
else
session[:project] = params['project']
end
end

# return string of kerberos user or false
def authenticate
if ENV['RACK_ENV'] == 'development' or ENV['RACK_ENV'] == 'qa'
return settings.user
end

user = request.env["HTTP_AUTHORIZATION"]

if user
user = Base64.decode64(user[6,user.length-6])[/\w+/]
return user
end

return false
end

1 change: 1 addition & 0 deletions helpers/init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require_relative 'helper1'
Empty file added models/admin.rb
Empty file.
2 changes: 2 additions & 0 deletions models/init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative 'user'
require_relative 'admin'
Empty file added models/user.rb
Empty file.
Empty file added public/css/main.css
Empty file.
Binary file added public/favicon.ico
Binary file not shown.
7 changes: 7 additions & 0 deletions routes/admin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class MyApp < Sinatra::Base

get '/admin' do
erb :admin
end

end
3 changes: 3 additions & 0 deletions routes/init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require_relative 'admin'
require_relative 'user'

7 changes: 7 additions & 0 deletions routes/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class MyApp < Sinatra::Base

get '/' do
erb :index
end

end
39 changes: 39 additions & 0 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<h2>This is a neat Sinatra template!</h2>

<pre>
app.rb # require sinatra, haml, vendor'd gems, models/init, routes/init, helpers/init
helpers/
init.rb # Requires each helper file
helper1.rb # Related helper methods

models/
init.rb # Require sequel, set up the DB; require each model, in controlled order
foo.rb # One or more Sequel models
bar.rb # One or more related models

routes/
init.rb # Require each route, in controlled order
admin.rb # One or more routes related to administration
foo.rb # One or more routes related to some feature

views/
layout.haml # Common layout
foo.haml # Specific view
bar.haml # Specific view


Install
-------
git clone git@github.com:oren/sinatra-template.git
rvm install ruby-1.9.2-p136
cd sinatra-template
rvm gemset import

Run
---
shotgun

Enjoy
-----
http://127.0.0.1:9393
</pre>
18 changes: 18 additions & 0 deletions views/layout.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<html>
<head>

<link href="/css/main.css" rel='stylesheet'>

<title>Sinatra Template</title>
</head>

<body>

<div id='container'>
<%= yield %>
</div>

</body>
</html>


0 comments on commit 65610d9

Please sign in to comment.