Skip to content

Commit

Permalink
create project pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jhardy committed Apr 15, 2014
1 parent ef7cc03 commit 64a8505
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 11 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ gem 'will_paginate'
gem 'pg'
gem "tux"
gem 'sinatra-contrib'
gem 'friendly_id', '~> 5.0.3'

group :development do

Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ GEM
sass (~> 3.1)
faraday (0.8.8)
multipart-post (~> 1.2.0)
friendly_id (5.0.3)
activerecord (>= 4.0.0)
fssm (0.2.10)
haml (4.0.4)
tilt
Expand Down Expand Up @@ -97,6 +99,7 @@ PLATFORMS
DEPENDENCIES
activerecord
compass
friendly_id (~> 5.0.3)
haml
octokit
pg
Expand Down
18 changes: 8 additions & 10 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@
require 'sinatra/assetpack'
require 'will_paginate'
require 'will_paginate/active_record'
require 'friendly_id'

require './config/environments' #database configuration
require './env' if File.exists?('env.rb')


enable :sessions




module WillPaginate
module ViewHelpers
def page_entries_info(collection, options = {})
Expand All @@ -43,18 +40,14 @@ def page_entries_info(collection, options = {})
end

class Extension < ActiveRecord::Base
include FriendlyId
friendly_id :name, :use => :slugged

validates_uniqueness_of :url, {:message => 'Ooops! It looks like this extension has already been added.'}
self.per_page = 20

end

# helpers do
# def is_pjax?
# # headers['X-PJAX']
# env['HTTP_X_PJAX']
# end
# end

configure do
set :root, File.dirname(__FILE__) # You must set app root
Expand Down Expand Up @@ -158,6 +151,11 @@ class Extension < ActiveRecord::Base
haml :user
end

get '/project/:project_name' do
@extensions = Extension.friendly.find(params[:project_name])
haml :project
end




Expand Down
11 changes: 11 additions & 0 deletions db/migrate/20140415062028_add_slug_to_extensions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class AddSlugToExtensions < ActiveRecord::Migration
def up
add_column :extensions, :slug, :string
end



def down
remove_column :extensions, :slug
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20140329141012) do
ActiveRecord::Schema.define(version: 20140415062028) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -33,6 +33,7 @@
t.string "project_name"
t.integer "stars"
t.string "docs"
t.string "slug"
end

end
73 changes: 73 additions & 0 deletions views/project.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
!!! 5
/[if lt IE 7] <html class="no-js lt-ie9 lt-ie8 lt-ie7">
/[if IE 7] <html class="no-js lt-ie9 lt-ie8">
/[if IE 8] <html class="no-js lt-ie9">
/ [if gt IE 8]><!
%html.no-js
/ <![endif]
%head
%meta{charset: "utf-8"}/
%meta{content: "IE=edge", "http-equiv" => "X-UA-Compatible"}/
%title
Sache:
= params[:user]
user tag
%meta{content: "Find Sass and Compass Extensions for your next project", name: "description"}/
%meta{content: "width=device-width, initial-scale=1", name: "viewport"}/
%link{:rel => "icon", :type => "image/x-icon", :href => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAlUlEQVQ4T2M8FtzznwENiNppwUVeH7qGLg3mW64pBtOM6AaQohnDAFI1Hw/pRbiAHM1wF5CrGWzA7Ynb4IFIKMBAGkDORgZwA8jRDHcBuZqxRiPMebB4xuZsmBpQ2GGkA+REQkgzVhcQazPMFSguIFUzKOzgBpCjGe4FcjWDDfgPBDD/oCcS5NCGsdGjHG4AOZpBhgIA+uR/eG/y0GQAAAAASUVORK5CYII="}/
= haml :_head
%body
/[if lt IE 7]
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
/ Add your site or application content here
.container
.main-content
= haml :_sache_bar
%header
.title-wrapper
%a{:href => "/", :class => "to-home"} &times;
%h2{:class => "page-title"}
= @extensions.name
#main
.extensions
.extension-list
%table
%thead
%tr
%th{:width => "250", :class => 'sortable'}
= sortable "name", "Name"
%th{:width => "300"}
Description
%th{:width => "200"}
Tags
%th{:width => "150", :class => 'sortable'}
= sortable "author", "Author"
%th{:width => "100", :class => 'stars sortable'}
= sortable "stars", "Stars"
%tbody
%tr{:class => "id-#{@extensions.id}"}
%td{:class => "card-title"}
%a{:href => "https://www.github.com/#{@extensions.author}/#{@extensions.project_name}", :class => "title-link"}
= @extensions.name
%td{:class => "card-description"}
= @extensions.description
%td.tag-list
- @extensions.tags.each do |tag|
%a{:href => "/tag/#{tag}", :class => "tag"}= tag

%td{:class => "author"}
%a{:href => "/#{@extensions.author}", :class => "author-filter"}
= @extensions.author
%td{:class => "ghub-stars"}
= @extensions.stars


= haml :_footer

= haml :_modal

= haml :_bottom_assets

0 comments on commit 64a8505

Please sign in to comment.