Skip to content

Commit

Permalink
Lots of things
Browse files Browse the repository at this point in the history
  • Loading branch information
gbprz committed Jul 13, 2014
1 parent 6355998 commit 0d78fad
Show file tree
Hide file tree
Showing 32 changed files with 356 additions and 645 deletions.
27 changes: 8 additions & 19 deletions Gemfile
Expand Up @@ -5,38 +5,27 @@ source 'https://rubygems.org'
gem 'rails', '4.1.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use omniauth-cas for CAS Authentication
gem 'omniauth-cas'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
gem 'bootstrap-sass', '~> 3.1.1'
gem 'font-awesome-sass'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'

# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

#gem 'acts_as_category', path: '/home/gabe/programming/WTG/acts_as_category'
gem 'acts_as_list'
gem 'spring', group: :development
55 changes: 34 additions & 21 deletions Gemfile.lock
Expand Up @@ -27,37 +27,49 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
acts_as_list (0.4.0)
activerecord (>= 3.0)
arel (5.0.0)
awesome_nested_set (2.1.6)
activerecord (>= 3.0.0)
addressable (2.3.6)
arel (5.0.1.20140414130214)
bootstrap-sass (3.1.1.1)
sass (~> 3.2)
builder (3.2.2)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.2.0)
coffee-script (2.3.0)
coffee-script-source
execjs
coffee-script-source (1.7.0)
coffee-script-source (1.7.1)
erubis (2.7.0)
execjs (2.0.2)
execjs (2.2.1)
font-awesome-sass (4.1.0)
sass (~> 3.2)
hashie (2.1.1)
hike (1.2.3)
i18n (0.6.9)
jbuilder (2.0.6)
i18n (0.6.11)
jbuilder (2.1.2)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (3.1.0)
jquery-rails (3.1.1)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
minitest (5.3.2)
multi_json (1.9.2)
polyglot (0.3.4)
mini_portile (0.6.0)
minitest (5.4.0)
multi_json (1.10.1)
nokogiri (1.6.2.1)
mini_portile (= 0.6.0)
omniauth (1.1.4)
hashie (>= 1.2, < 3)
rack
omniauth-cas (1.0.4)
addressable (~> 2.3)
nokogiri (~> 1.6)
omniauth (~> 1.1.0)
polyglot (0.3.5)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
Expand All @@ -76,7 +88,7 @@ GEM
activesupport (= 4.1.0)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.2.2)
rake (10.3.2)
rdoc (4.1.1)
json (~> 1.4)
sass (3.2.19)
Expand All @@ -88,7 +100,7 @@ GEM
sdoc (0.4.0)
json (~> 1.8)
rdoc (~> 4.0, < 5.0)
spring (1.1.2)
spring (1.1.3)
sprockets (2.11.0)
hike (~> 1.2)
multi_json (~> 1.0)
Expand All @@ -100,28 +112,29 @@ GEM
sprockets (~> 2.8)
sqlite3 (1.3.9)
thor (0.19.1)
thread_safe (0.3.3)
thread_safe (0.3.4)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
turbolinks (2.2.2)
coffee-rails
tzinfo (1.1.0)
tzinfo (1.2.1)
thread_safe (~> 0.1)
uglifier (2.5.0)
uglifier (2.5.1)
execjs (>= 0.3.0)
json (>= 1.8.0)

PLATFORMS
ruby

DEPENDENCIES
acts_as_list
awesome_nested_set
bootstrap-sass (~> 3.1.1)
coffee-rails (~> 4.0.0)
font-awesome-sass
jbuilder (~> 2.0)
jquery-rails
omniauth-cas
rails (= 4.1.0)
sass-rails (~> 4.0.3)
sdoc (~> 0.4.0)
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Expand Up @@ -12,5 +12,6 @@
//
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require_tree .
3 changes: 3 additions & 0 deletions app/assets/javascripts/bootstrap.js.coffee
@@ -0,0 +1,3 @@
jQuery ->
$("a[rel~=popover], .has-popover").popover()
$("a[rel~=tooltip], .has-tooltip").tooltip()
Expand Up @@ -11,5 +11,14 @@
* file per style scope.
*
*= require_tree .
*= require font-awesome
*= require_self
*/

$btn-default-bg: #CC0000;
$btn-default-color: #FFFFFF;

$input-border-focus: #00B200;

@import "bootstrap";
@import "bootstrap/theme";
58 changes: 58 additions & 0 deletions app/assets/stylesheets/categories.css.scss
@@ -1,3 +1,61 @@
// Place all the styles related to the categories controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

.page {
margin-left: 10px;
}

.banner {
padding-right: 100px;
}

.unstyled_link {
a {
text-decoration: none;
color: black;
&:hover {
text-decoration: none;
color: black;
}
}
}

.categories_nav {
width: 300px;
padding-right: 20px;
float: left;
.categories_list {
margin-left: 10px;
}
}

.documents_grid {
width: 800px;
float: right;
}

.upload_button_container{

.upload_button {
margin-left: auto;
margin-right: auto;
display: block;
background-color: #708EA4;
border-radius: 2px;
box-shadow: 2px 2px 1px #0A0A0A;
text-align: center;
width: 100px;
height: 35px;
line-height: 35px;
color: white;
&:hover {
background-color: #29516D;
text-decoration: none;
color: white;
}
.upload_button_text {
padding: 5px;
}
}
}
6 changes: 6 additions & 0 deletions app/controllers/application_controller.rb
Expand Up @@ -2,4 +2,10 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception

helper_method :current_user

def current_user
@current_user = User.find_by_id(session[:user_id])
end
end
4 changes: 4 additions & 0 deletions app/controllers/categories_controller.rb
Expand Up @@ -5,4 +5,8 @@ def index
@categories = Category.roots
end

def show
@category = Category.find params[:id]
end

end
23 changes: 23 additions & 0 deletions app/controllers/sessions_controller.rb
@@ -0,0 +1,23 @@
class SessionsController < ApplicationController

def new
cas_hash = request.env["omniauth.auth"]

if User.find_by_username(cas_hash[:uid]).nil?
user = User.new(username: cas_hash[:uid], is_admin: 0, full_name: cas_hash[:uid])
user.save
session[:user_id] = user.id
redirect_to "/"
else
user = User.find_by_username(cas_hash[:uid])
flash[:notice] = "You have successfully logged in."
session[:user_id] = user.id
redirect_to "/"
end
end

def destroy
session[:user_id] = nil
redirect_to "/"
end
end
9 changes: 9 additions & 0 deletions app/controllers/users_controller.rb
@@ -1,2 +1,11 @@
class UsersController < ApplicationController

def index
@users = User.all
end

def show
@user = User.find params[:id]
end

end
50 changes: 46 additions & 4 deletions app/models/category.rb
@@ -1,8 +1,50 @@
class Category < ActiveRecord::Base
include ActsAsCategory
# Based on contributions from @bamnet on the 3.1 branch

acts_as_category :order_by => 'name', :hidden => 'private'
# Build a heirarchy of categories
belongs_to :parent, class_name: 'Category'
has_many :children, class_name: 'Category', foreign_key: 'parent_id'

validates_presence_of :name, :group_id, :user_id
# Find all categories serving as a root
scope :roots, -> { where(parent_id: nil) }

end
# Is this category a root?
def is_root?
parent_id.nil?
end

# Collect a list of parent categories
# Each category the monkey stops as he climbs up the tree
# Compliments of DHH http://github.com/rails/acts_as_tree
def ancestors
node, nodes = self, []
nodes << node = node.parent while node.parent
nodes
end

# Collect a list of children categories
# Each category the monkey could stop by as he climbs down a tree
# Compliments of http://github.com/funkensturm/acts_as_category
def descendants
node, nodes = self, []
node.children.each { |child|
# Check for circular dependenciess
if !nodes.include?(child)
nodes += [child]
nodes += child.descendants
end
} unless node.children.empty?
nodes
end

# Figure out the tree's height
def depth
ancestors.count
end

# The group of category who share a common parent
def self_and_siblings
parent ? parent.children : Category.roots
end

end

0 comments on commit 0d78fad

Please sign in to comment.