Permalink
Browse files

Added the account page, added a url column to User

  • Loading branch information...
1 parent 2aac4c7 commit 967b34d20b2fbe58499c0466d5fa018cdaa9dc70 @konklone konklone committed Mar 25, 2010
Showing with 81 additions and 8 deletions.
  1. +1 −0 fixtures/users.yml
  2. +1 −1 migrations/01_create_users.rb
  3. +13 −0 ohnomymoney.rb
  4. +58 −0 views/account.erb
  5. +8 −7 views/index.erb
View
@@ -5,3 +5,4 @@
updated_at: 2010-02-14 22:04:46 -05:00
id: 1
email: jericho@example.com
+ url: http://example.com
@@ -1,7 +1,7 @@
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
- t.string :email, :name, :handle
+ t.string :email, :name, :handle, :url
t.timestamps
end
View
@@ -27,6 +27,19 @@
}
end
+get "/:handle/account/:id" do
+ halt 404 unless user = User.find_by_handle(params[:handle])
+ halt 404 unless account = user.accounts.find(params[:id])
+
+ erb :account, :locals => {
+ :user => user,
+ :account => account,
+ :oldest => account.balances.first(:order => "created_at ASC"),
+ :newest => account.balances.first(:order => "created_at DESC"),
+ :balances => account.balances.all(:limit => 180)
+ }
+end
+
get "/:handle/worth.xml" do
headers['Content-Type'] = 'application/rss+xml'
"<?xml><xml/>"
View
@@ -0,0 +1,58 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>Oh No My Money</title>
+
+ <meta content="money graphs charts" name="keywords" />
+ <meta content="<%= user.name %>'s money, on display, with graphs." name="description" />
+ <meta content="<%= user.name %>" name="author" />
+ <meta content="2008" name="copyright" />
+
+ <link charset="utf-8" href="/ohnomymoney.css" media="screen" rel="stylesheet" type="text/css" />
+ <link href="/worth.xml" rel="alternate" title="Oh No My Money" type="application/rss+xml" />
+</head>
+<body>
+
+ <div class="accounts left">
+ <div class="account oldest">
+ <h3><%= date oldest.date_of %></h3>
+ <span class="<%= direction oldest.amount %>"><%= format_amount oldest.amount %></span>
+ </div>
+ </div>
+
+ <div class="accounts right">
+ <div class="account newest">
+ <h3><%= date newest.date_of %></h3>
+ <span class="<%= direction newest.amount %>"><%= format_amount newest.amount %></span>
+ </div>
+ </div>
+
+ <div class="title">
+ <h2 class="negative"><%= account.name %></h2>
+ </div>
+
+ <div class="graph">
+ <img alt="Chart for <%= account.name %>" src="<%= double_encode chart_for(balances) %>" />
+
+ <div class="back">
+ <a href="/<%= user.handle %>">Go Back</a>
+ </div>
+ </div>
+
+ <div class="footer">
+ This is <a href="<%= user.url %>"><%= user.name %></a>'s money. This site made against the advice of everyone who loves him.
+ </div>
+
+ <script type="text/javascript">
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ </script>
+ <script type="text/javascript">
+ try {
+ var pageTracker = _gat._getTracker("UA-252618-6");
+ pageTracker._trackPageview();
+ } catch(err) {}
+ </script>
+
+</body>
+</html>
View
@@ -55,17 +55,18 @@
</div>
<div class="footer">
- This is <a href="http://mill-industries.com">Eric Mill</a>'s money. This site made against the advice of everyone who loves him.
+ This is <a href="<%= user.url %>"><%= user.name %></a>'s money. This site made against the advice of everyone who loves him.
</div>
- <script type="text/javascript">
+ <script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
- </script>
- <script type="text/javascript">
- var pageTracker = _gat._getTracker("UA-252618-6");
- pageTracker._initData();
- pageTracker._trackPageview();
+ </script>
+ <script type="text/javascript">
+ try {
+ var pageTracker = _gat._getTracker("UA-252618-6");
+ pageTracker._trackPageview();
+ } catch(err) {}
</script>
</body>

0 comments on commit 967b34d

Please sign in to comment.