Permalink
Browse files

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
2 parents 0cb621c + c453c2d commit 1507652360ce227af194c7c303b1df9a6bd875c3 @hoverbird hoverbird committed May 26, 2012
Showing with 40 additions and 82 deletions.
  1. +9 −1 models/game.rb
  2. +18 −28 routes/find.rb
  3. +0 −7 routes/main.rb
  4. +7 −0 views/_game_summary.haml
  5. +0 −38 views/game_edit.haml
  6. +6 −8 views/game_list.haml
View
@@ -25,4 +25,12 @@ def view_version_url(version_id)
"#{ENV['SITE_ROOT']}/game/#{urls.last.slug}/#{version_id}/view"
end
-end
+ def last_available_version
+ if author == current_user
+ versions.last
+ else
+ versions.select{|v| v.published?}.last
+ end
+ end
+
+end
View
@@ -1,20 +1,33 @@
get '/game/:slug/view' do
game = Url.first(:slug => params[:slug]).andand.game
error 404 if game.nil?
- version = game.versions.last
- show_game(game, version)
+
+ version = game.last_available_version
+ error 404 if version.nil?
+
+ haml :game_detail, :locals => { :game => game, :version => version }
end
get '/game/:slug/:version_id/view' do
game = Url.first(:slug => params[:slug]).andand.game
version = Version.get(params[:version_id])
error 404 if game.nil? or version.nil? or !game.versions.include?(version)
+ error 404 unless version.published? || game.author == current_user
- show_game(game, version)
+ haml :game_detail, :locals => { :game => game, :version => version }
end
-def show_game(game, version)
- haml :game_detail, :locals => { :game => game, :version => version }
+get '/game/:slug/src' do
+ game = Url.first(:slug => params[:slug]).andand.game
+ error 404 if game.nil?
+
+ version = game.last_available_version
+ error 404 if version.nil?
+
+ if data = game_data(game.id)
+ yaml = YAML.load data
+ yaml.to_json
+ end
end
get '/games/by/:username' do
@@ -35,26 +48,3 @@ def show_game(game, version)
haml :game_list, :locals => { :title => "Recent Games",
:games => versions.map{|v| v.game }.uniq }
end
-
-get '/game/new' do
- force_login :next => request.fullpath
-
- haml :game_edit, :locals => { :game => nil, :version => nil,
- :upload_to => "#{ENV['SITE_ROOT']}/game/new",
- :upload_method => "POST" }
-end
-
-get '/game/:slug/edit' do
- force_login :next => request.fullpath
-
- slug = params[:slug]
- game = Url.first(:slug => slug).andand.game
- error 404 if game.nil?
- error 403 if game.author != current_user
-
- latest_version = game.versions.last
-
- haml :game_edit, :locals => { :game => game, :version => latest_version,
- :upload_to => "#{ENV['SITE_ROOT']}/game/#{slug}",
- :upload_method => "POST" }
-end
View
@@ -11,10 +11,3 @@
end
erb :play
end
-
-get '/games/:game_id' do
- if data = game_data(params[:game_id])
- yaml = YAML.load data
- yaml.to_json
- end
-end
View
@@ -0,0 +1,7 @@
+#title
+ %a{:href => game.view_url}
+ = game.versions.last.title
+#author
+ = game.author.display_name
+#description
+ = game.versions.last.description
View
@@ -1,38 +0,0 @@
-%h1 Make a game
-
-%form{:action => upload_to, :method => upload_method}
- %label{:for => "title"} Title
- %input{:id => "title", :name => "title",
- :type => "text", :value => version.andand.title}
-
- %label{:for => "label"} Version Label (e.g. "v0.1" or "beta 4")
- %input{:id => "label", :name => "label",
- :type => "text"}
-
- %label{:for => "description"} Description
- %textarea{:id => "description", :name => "description"}
- = version.andand.description
-
- %label{:for => "source"} Game Code
- %textarea{:id => "source", :name => "source"}
- = version.andand.source
-
- %label{:for => "changelog"} Version changelog
- %textarea{:id => "changelog", :name => "changelog"}
-
- %h2 Remotely Hosted Game (Advanced)
-
- %label{:for => "source_url"} Remote Game URL
- %input{:id => "source_url", :name => "source_url",
- :type => "text", :value => version.andand.source_url}
-
- %h2 Game visibility
-
- %input{:id => "published", :name => "published",
- :type => "checkbox", :value => game.andand.published? || "false"}
- Make this game visible to anyone
-
- %h2 This Should Not Be Its Own Section
-
- %label But Then I Would Have To Write Some CSS
- %input{:value => "Save", :type => "submit", :class => "button"}
View
@@ -2,11 +2,9 @@
= title
- for game in games
- .game
- #title
- %a{:href => game.view_url}
- = game.versions.last.title
- #author
- = game.author.display_name
- #description
- = game.versions.last.description
+ - if game.published?
+ .game
+ = haml :_game_summary, locals: {game: game}
+ - elsif game.author == current_user
+ .game.hidden
+ = haml :_game_summary, locals: {game: game}

0 comments on commit 1507652

Please sign in to comment.