Created
November 25, 2009 18:39
-
-
Save djtal/242925 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <li>{{name}}</li> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {{{doctype_xhtml}}} | |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
| <head> | |
| <title>{{title}}</title> | |
| {{{css}}} | |
| </head> | |
| <body> | |
| {{{stylesheet}}} | |
| <div class="container"> | |
| <div class="column span-24"> | |
| <h1>Welcome to {{name}} ludomanager page</h1> | |
| <ul> | |
| <li>Games owned : {{games_owned}}</li> | |
| <li>Parties played : {{parties_played}}</li> | |
| </ul> | |
| <h2>Last buyed games</h2> | |
| {{#last_buyed}} | |
| <ul> | |
| {{#last_buyed_games}} | |
| <li>{{name}} - from {{min}} to {{max}} players {{#never_played}}<em>(never played)</em>{{/never_played}}</li> | |
| {{/last_buyed_games}} | |
| </ul> | |
| {{/last_buyed}} | |
| <h2>Last played games</h2> | |
| {{#last_played}} | |
| <ul> | |
| {{#last_played_games}} | |
| <li>{{name}}</li> | |
| {{/last_played_games}} | |
| </ul> | |
| {{/last_played}} | |
| with partial now | |
| {{#last_played}} | |
| <ul> | |
| {{#last_played_games}} | |
| {{partial_game}} | |
| {{/last_played_games}} | |
| </ul> | |
| {{/last_played}} | |
| </div> | |
| </div> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "view_helpers" | |
| module View | |
| class Page < Mustache | |
| include View::Helpers | |
| def initialize(user_template) | |
| self.template = user_template.template | |
| self[:title] = user_template.title | |
| end | |
| def stylesheet | |
| output = "<style type='text/css'>" | |
| self[:stylesheets].each do |style| | |
| output << style | |
| end | |
| output << "</style>" | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def show | |
| user_page = UserPage.find(params[:id]) | |
| account = user_page.account | |
| @view = View::Page.new(user_page) | |
| #fill attribute need at rendering stage | |
| @view[:stylesheets] = account.user_pages.css.map(&:template) | |
| account.user_pages.partials.each do |partial| | |
| @view["partial#{partial.to_partial_name}"] = partial.template | |
| end | |
| @view[:name] = account.login | |
| @view[:games_owned] = account.games.count | |
| @view[:parties_played] = account.parties.count | |
| @view[:last_buyed] = account.account_games.recent.count > 0 | |
| @view[:last_buyed_games] = account.account_games.recent.inject([]) do |acc, acc_games| | |
| game = acc_games.game | |
| acc << {:name => game.name, :min => game.min_player, :max => game.max_player, :never_played => !acc_games.played?} | |
| end | |
| @view[:last_played] = account.parties.last(5).count > 0 | |
| @view[:last_played_games] = account.parties.last(5).map{ |party| party.game.to_mustache_attr} | |
| render :layout => false | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment