Skip to content

Commit

Permalink
Handle individual level runs.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansundin committed Dec 8, 2016
1 parent 255fa7b commit af4cd30
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
8 changes: 4 additions & 4 deletions app/speedrun_party.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ def self.resolve_id(type, id)
elsif type == "category"
response = SpeedrunParty.get("/categories/#{id}")
raise SpeedrunError.new(response) if !response.success?
response.parsed_response["data"]["name"]
elsif type == "category_link"
response = SpeedrunParty.get("/categories/#{id}")
response.parsed_response["data"]["weblink"].partition("#")[2] + "|" + response.parsed_response["data"]["name"]
elsif type == "level"
response = SpeedrunParty.get("/levels/#{id}")
raise SpeedrunError.new(response) if !response.success?
response.parsed_response["data"]["weblink"].partition("#")[2]
response.parsed_response["data"]["weblink"].split("/")[-1] + "|" + response.parsed_response["data"]["name"]
elsif type == "user"
response = SpeedrunParty.get("/users/#{id}")
raise SpeedrunError.new(response) if !response.success?
Expand Down
13 changes: 10 additions & 3 deletions views/speedrun_feed.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@
else
"No video"
end
category = SpeedrunParty.resolve_id("category", run["category"])
category_link = SpeedrunParty.resolve_id("category_link", run["category"])
cat = SpeedrunParty.resolve_id("category", run["category"]).partition("|")
if run["level"]
level = SpeedrunParty.resolve_id("level", run["level"]).partition("|")
category_link = "https://www.speedrun.com/#{@abbr}/#{level[0]}"
category = "#{cat[2]}: #{level[2]}"
else
category_link = "https://www.speedrun.com/#{@abbr}##{cat[0]}"
category = cat[2]
end
platform = SpeedrunParty.resolve_id("platform", run["system"]["platform"])
platform += " (#{SpeedrunParty.resolve_id("region", run["system"]["region"])})" if run["system"]["region"]
-%>
Expand All @@ -32,7 +39,7 @@
#{run["comment"].to_paragraphs}
<p>Category: <a href="https://www.speedrun.com/#{@abbr}##{category_link}">#{category}</a></p>
<p>Category: <a href="#{category_link}">#{category}</a></p>
<p>Platform: #{platform}</p>
EOF
-%>
Expand Down

0 comments on commit af4cd30

Please sign in to comment.