Skip to content

Commit

Permalink
Daily Commit and Push #8
Browse files Browse the repository at this point in the history
  • Loading branch information
James Alexander Shield committed Nov 17, 2009
1 parent 5bdfa44 commit 124e25e
Show file tree
Hide file tree
Showing 15 changed files with 546 additions and 463 deletions.
17 changes: 8 additions & 9 deletions extensions/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ def logout!
def self.registered(app)
app.helpers SessionAuth::Helpers

app.get '/user/logout' do
app.post '/user/logout' do
logout!
redirect request.referer
end

app.get '/user/error/:reason' do
Expand All @@ -41,13 +40,11 @@ def self.registered(app)
if user.password == params[:pass]
session[:authorized] = true
session[:uid] = user.id
redirect request.referer
else
redirect '/user/error/pass'
session[:authorized] = false
end
else
session[:authorized] = false
redirect '/user/error/user'
end
end

Expand All @@ -74,15 +71,17 @@ def self.registered(app)

end

app.get '/user/profile' do
app.get '/api/user/profile/haml/:uid' do |u|
if authorized?

@user = User.get!(u)
haml :user_profile
else
redirect request.referer

end
end
end

end
end

register SessionAuth
end
21 changes: 14 additions & 7 deletions main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
set :environment, :development
set :public, "./public"

get '/css/a' do
get '/css/theme' do
content_type 'text/css', :charset => 'utf-8'
sass :a
if authorized?
case @user.style
when 1 then sass :style_default
when 2 then sass :style_inverted
else sass :style_default
end
end
sass :style_default
end

post '/forum/post' do
Expand All @@ -57,10 +64,6 @@
end
end

get '/css/yui' do
content_type 'text/css', :charset => 'utf-8'
sass :yui_reset
end

get '/' do
@date = DateTime.now.strftime("%D")
Expand All @@ -78,7 +81,7 @@
@posts = @posts.to_a + @posts.children.to_a
haml :forum_post
else
redirect "/forum/"
redirect "/forum"
end
end

Expand Down Expand Up @@ -139,3 +142,7 @@
end
end

get '/api/userbox' do |p|
haml :userbox
end

2 changes: 2 additions & 0 deletions models/forum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class User
}
property :custom_title, Text
property :post_count, Integer
property :style, Enum[ :default, :compact ], :default => :default
property :color, Enum[ :default, :inverted ], :default => :default
property :sig, Text
property :sex, Enum[ :male, :female, :intersex, :undefined ], :default => :undefined
property :dob, Date
Expand Down
5 changes: 3 additions & 2 deletions views/forum_index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
%title
DAEDBOX: Test Forum
%meta{ :content => "no", "http-equiv" => "imagetoolbar" }
%link{ :href => "/css/a", :rel => "stylesheet", :media => "screen", :type => "text/css" }
%link{ :href => "/css/theme", :rel => "stylesheet", :media => "screen", :type => "text/css" }
%script{ :src => "http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js", :type => "text/javascript"}
= haml :userfunction
%body
= haml :mainmenu
= haml :userbox
#userbox
= haml :userbox
#mainbox
= haml :topic_list
5 changes: 3 additions & 2 deletions views/forum_post.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
%meta{ :content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type" }
%title= "DAEDBOX: " + @posts.first.title
%meta{ :content => "no", "http-equiv" => "imagetoolbar" }
%link{ :href => "/css/a", :rel => "stylesheet", :media => "screen", :type => "text/css" }
%link{ :href => "/css/theme", :rel => "stylesheet", :media => "screen", :type => "text/css" }
%script{ :src => "http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js", :type => "text/javascript"}
= haml :userfunction
%body
= haml :mainmenu
= haml :userbox
#userbox
= haml :userbox
#mainbox
= haml :post_list

32 changes: 5 additions & 27 deletions views/index.haml
Original file line number Diff line number Diff line change
@@ -1,41 +1,19 @@
!!! Strict
%html{ "xml:lang" => "en", :xmlns => "http://www.w3.org/1999/xhtml" }
%head
%meta{ :content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type" }
%title
DAEDBOX
%meta{ :content => "no", "http-equiv" => "imagetoolbar" }
%link{ :href => "/css/a", :rel => "stylesheet", :media => "screen", :type => "text/css" }
%link{ :href => "/css/theme", :rel => "stylesheet", :media => "screen", :type => "text/css" }
%script{ :src => "http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js", :type =>"text/javascript"}
= haml :userfunction
%body
#mainmenu
%h1
%a{ :href => "/" }
%b
DAED
BOX
%div
%ul
%li.cur
%a{ :href => "/" }
MAIN
%li
%a{ :href => "/projects" }
PROJECTS
%li
%a{ :href => "/blog" }
BLOG
%li
%a{ :href => "/forum" }
FORUM
= haml :mainmenu

#userbox
.box.large.left
%h2
%b= @date
#bg
%div
%table{ :cellspacing => "0", :cellpadding => "0" }
%tr
%td
#mainbox


12 changes: 3 additions & 9 deletions views/mainmenu.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#menu
#mainmenu
%h1
%a{ :href => "/" }
%b
Expand All @@ -7,14 +7,8 @@
%div
%ul
%li
%a{ :href => "/" }
%a{ :href => "#", :onclick => "loadPage('main');" }
MAIN
%li
%a{ :href => "/projects" }
PROJECTS
%li
%a{ :href => "/blog" }
BLOG
%li
%a{ :href => "/forum" }
%a{ :href => "#", :onclick => "loadPage('forum');" }
FORUM
2 changes: 1 addition & 1 deletion views/post_list.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#content.box.sml
#content.box
%a{:name =>"#top"}
%h2
%b.title= @posts.first.title
Expand Down
Loading

0 comments on commit 124e25e

Please sign in to comment.