Skip to content

Commit 3a819c0

Browse files
committed
Adding programs/index.
1 parent 40fd240 commit 3a819c0

4 files changed

Lines changed: 61 additions & 0 deletions

File tree

controllers/programs.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
haml :"programs/new"
44
end
55

6+
get "/programs" do
7+
@programs = Program.all.sort{|a, b| b.updated_at <=> a.updated_at }.first(10)
8+
haml :"programs/index"
9+
end
10+
611
post "/programs" do
712
require_login_or_api! :username => params[:username], :password => params[:password]
813
params[:program]['creator_username'] = current_user.username

models/program.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class Program
1010

1111
many :comments
1212

13+
timestamps!
14+
1315
private
1416
def slug_check
1517
programs = Program.all(:creator_username => creator_username)

views/programs/index.haml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.span-9
2+
%img{:height => "64", :src => "/images/logo.png", :style => "float:left"}/
3+
%p.body{:style => "padding-top:20px;padding-left:80px"} Hackety Hack
4+
- if logged_in?
5+
.span-6.prepend-3.last
6+
%ul
7+
%li{:style => "display:inline"}
8+
%a{:href => "/download"} Download
9+
|
10+
%li{:style => "display:inline"}
11+
%a{:href => "/hackers/#{current_user.username.to_slug}"} My Page
12+
|
13+
%li{:style => "display:inline"}
14+
%a{:href => "/logout"} Log out
15+
- else
16+
.span-4.prepend-5.last
17+
%ul
18+
%li{:style => "display:inline"}
19+
%a{:href => "/download"} Download
20+
|
21+
%li{:style => "display:inline"}
22+
%a{:href => "/login"} Log in
23+
.span-18.last
24+
%h1 Explore Programs
25+
.span-9
26+
%h2 Featured Programs
27+
%ul
28+
%li
29+
%a{:href => "http://hackety-hack.com/programs/wilkie/connect_four"} Connect Four
30+
, by
31+
%a{:href => "http://hackety-hack.com/hackers/wilkie"} wilkie
32+
%li
33+
%a{:href => "http://hackety-hack.com/programs/cyber/calender_basic"} Calender basic
34+
, by
35+
%a{:href => "http://hackety-hack.com/hackers/cyber"} cyber
36+
%li
37+
%a{:href => "http://hackety-hack.com/programs/wilkie/invaders"} Space Invaders
38+
, by
39+
%a{:href => "http://hackety-hack.com/hackers/wilkie"} wilkie
40+
%li
41+
%a{:href => "http://hackety-hack.com/programs/frog/turtle_fun"} Turtle Fun
42+
, by
43+
%a{:href => "http://hackety-hack.com/hackers/frog"} frog
44+
.span-9.last
45+
%h2 Recent Programs
46+
%ul
47+
- @programs.each do |program|
48+
%li
49+
%a{:href => "/programs/#{program.creator_username}/#{program.slug}"}= program.title
50+
, by
51+
%a{:href => "/hackers/#{program.creator_username}"}= program.creator_username

views/stream.haml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
.span-18.last
2424
#infobox{:style => "border:black 1px solid;padding:10px;margin:10px;"}
2525
Hello there! This is the website for Hackety Hack. You can ask a question, share programs that you've made, or just tell everyone something. Don't forget, you should <a href="http://hackety-hack.com/download">download Hackety Hack</a>, it will teach you everything you need to get started with programming! This is just a place to participate in the Hackety Hack community.
26+
.span-18.last
27+
#infobox{:style => "border:red 1px solid;padding:10px;margin:10px;"}
28+
Check it out! The newest feature: You can visit a list of the most recent updated programs, and check out some really cool featured ones. I've added a <a href="/programs">programs page</a> to show them off!
2629
.span-18.last
2730
%ul#input_list
2831
%li{:style => "display:inline"}

0 commit comments

Comments
 (0)