Commit 1d794dbe authored by Tomasz Gubała's avatar Tomasz Gubała

initial import

parent 6a7cbc80
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config.
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
/.secret
/.devise_secret
/.ruby-gemset
/config/database.yml
ruby-2.0.0
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.1'
# Use mysql as the database for Active Record
gem 'mysql2'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# 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', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
group :development do
# For better error output and diagnostics
gem 'pry-rails'
gem 'better_errors'
gem 'binding_of_caller'
# For quality/security testing
gem 'brakeman', :require => false
gem 'rails_best_practices'
# Has to use Thin as Webrick doesn't handle long PLGrid OpenId responses
gem 'thin'
end
# rbx section
# gem 'rubysl' #, platform: rbx
# gem 'racc'
# Auth stuff; openid required
gem 'devise'
gem 'omniauth'
gem 'omniauth-openid'
# Mailing runtime exceptions to admins
gem 'exception_notification'
# HAML gudy, ERB nody gudy
gem 'haml-rails'
# Let's bootstrap
gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails',
:github => 'anjlab/bootstrap-rails'
# Allows making DB foreign keys in migrations
gem 'foreigner'
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'
# Use unicorn as the app server
gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
# MY OWN! MY PRECIOUS!!
gem 'ruby-gridftp', :git => 'git@dev.cyfronet.pl:commons/ruby-gridftp.git'
GIT
remote: git://github.com/anjlab/bootstrap-rails.git
revision: 99d4f2a5cb5423a6f1ac4e10ba96bfe497dcaebe
specs:
anjlab-bootstrap-rails (3.0.3.0)
railties (>= 3.0)
sass (>= 3.2)
GIT
remote: git@dev.cyfronet.pl:commons/ruby-gridftp.git
revision: 080c1fbe44c210afb7cc39aeb3b08e2cb5c611ca
specs:
ruby-gridftp (0.0.1)
ffi (~> 1.9, >= 1.9.3)
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.0.1)
actionpack (= 4.0.1)
mail (~> 2.5.4)
actionpack (4.0.1)
activesupport (= 4.0.1)
builder (~> 3.1.0)
erubis (~> 2.7.0)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.1)
activesupport (= 4.0.1)
builder (~> 3.1.0)
activerecord (4.0.1)
activemodel (= 4.0.1)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.1)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.1)
i18n (~> 0.6, >= 0.6.4)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
arel (4.0.1)
atomic (1.1.14)
awesome_print (1.2.0)
bcrypt-ruby (3.1.2)
better_errors (1.0.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
brakeman (2.2.0)
erubis (~> 2.6)
fastercsv (~> 1.5)
haml (>= 3.0, < 5.0)
highline (~> 1.6.20)
multi_json (~> 1.2)
ruby2ruby (~> 2.0.5)
ruby_parser (~> 3.2.2)
sass (~> 3.0)
slim (>= 1.3.6, < 3.0)
terminal-table (~> 1.4)
builder (3.1.4)
code_analyzer (0.4.3)
sexp_processor
coderay (1.1.0)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.6.3)
colored (1.2)
daemons (1.1.9)
debug_inspector (0.0.2)
devise (3.2.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
thread_safe (~> 0.1)
warden (~> 1.2.3)
erubis (2.7.0)
eventmachine (1.0.3)
exception_notification (4.0.1)
actionmailer (>= 3.0.4)
activesupport (>= 3.0.4)
execjs (2.0.2)
fastercsv (1.5.5)
ffi (1.9.3)
foreigner (1.6.0)
activerecord (>= 3.0.0)
haml (4.0.4)
tilt
haml-rails (0.5.1)
actionpack (~> 4.0.0)
activesupport (~> 4.0.0)
haml (>= 3.1, < 5.0)
railties (~> 4.0.0)
hashie (2.0.5)
highline (1.6.20)
hike (1.2.3)
i18n (0.6.9)
jbuilder (1.5.3)
activesupport (>= 3.0.0)
multi_json (>= 1.2.0)
jquery-rails (3.0.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
kgio (2.8.1)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.8.2)
mime-types (1.25.1)
minitest (4.7.5)
multi_json (1.8.2)
mysql2 (0.3.14)
omniauth (1.1.4)
hashie (>= 1.2, < 3)
rack
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
orm_adapter (0.5.0)
polyglot (0.3.3)
pry (0.9.12.4)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pry-rails (0.3.2)
pry (>= 0.9.10)
rack (1.5.2)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (0.6.2)
rack (>= 1.0)
rails (4.0.1)
actionmailer (= 4.0.1)
actionpack (= 4.0.1)
activerecord (= 4.0.1)
activesupport (= 4.0.1)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.1)
sprockets-rails (~> 2.0.0)
rails_best_practices (1.14.4)
activesupport
awesome_print
code_analyzer (>= 0.4.3)
colored
erubis
i18n
require_all
ruby-progressbar
railties (4.0.1)
actionpack (= 4.0.1)
activesupport (= 4.0.1)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.12.0)
rake (10.1.0)
rdoc (3.12.2)
json (~> 1.4)
require_all (1.3.2)
ruby-openid (2.3.0)
ruby-progressbar (1.2.0)
ruby2ruby (2.0.6)
ruby_parser (~> 3.1)
sexp_processor (~> 4.0)
ruby_parser (3.2.2)
sexp_processor (~> 4.1)
sass (3.2.12)
sass-rails (4.0.1)
railties (>= 4.0.0, < 5.0)
sass (>= 3.1.10)
sprockets-rails (~> 2.0.0)
sdoc (0.3.20)
json (>= 1.1.3)
rdoc (~> 3.10)
sexp_processor (4.4.0)
slim (2.0.2)
temple (~> 0.6.6)
tilt (>= 1.3.3, < 2.1)
slop (3.4.7)
sprockets (2.10.1)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
temple (0.6.7)
terminal-table (1.4.5)
thin (1.6.1)
daemons (>= 1.0.9)
eventmachine (>= 1.0.0)
rack (>= 1.0.0)
thor (0.18.1)
thread_safe (0.1.3)
atomic
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
turbolinks (1.3.1)
coffee-rails
tzinfo (0.3.38)
uglifier (2.3.2)
execjs (>= 0.3.0)
json (>= 1.8.0)
unicorn (4.7.0)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
warden (1.2.3)
rack (>= 1.0)
PLATFORMS
ruby
DEPENDENCIES
anjlab-bootstrap-rails!
better_errors
binding_of_caller
brakeman
coffee-rails (~> 4.0.0)
devise
exception_notification
foreigner
haml-rails
jbuilder (~> 1.2)
jquery-rails
mysql2
omniauth
omniauth-openid
pry-rails
rails (= 4.0.1)
rails_best_practices
ruby-gridftp!
sass-rails (~> 4.0.0)
sdoc
thin
turbolinks
uglifier (>= 1.3.0)
unicorn
== README
This README would normally document whatever steps are necessary to get the
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...
Please feel free to use a different markup language if you do not plan to run
<tt>rake doc:app</tt>.
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Plgdata::Application.load_tasks
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
@import "twitter/bootstrap";
// Place all the styles related to the Folders controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
body {
background-color: #fff;
color: #333;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
}
p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
}
pre {
background-color: #eee;
padding: 10px;
font-size: 11px;
}
a {
color: #000;
&:visited {
color: #666;
}
&:hover {
color: #fff;
background-color: #000;
}
}
div {
&.field, &.actions {
margin-bottom: 10px;
}
}
#notice {
color: green;
}
.field_with_errors {
padding: 2px;
background-color: red;
display: table;
}
#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px;
padding-bottom: 0;
margin-bottom: 20px;
background-color: #f0f0f0;
h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px;
margin-bottom: 0px;
background-color: #c00;
color: #fff;
}
ul li {
font-size: 12px;
list-style: square;
}
}
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
private
# Remember to set the locale for future use (redirects, links etc. etc.)
before_filter :set_locale
# Keep every possible controller, besides the login screen, protected
before_filter :authenticate_user!
# Detect the used locale (the routes.rb score changes /en/ into params[:locale] => "en")
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
# Used to keep the locale from one call to another to another... throughout the entire user session
def self.default_url_options(options={})
options.merge({ :locale => I18n.locale })
end
# Where to send user after successful login
def after_sign_in_path_for(resource)
logger.debug "USER #{resource.name + ' ' + resource.surname} SIGN IN COUNT = #{resource.sign_in_count}."
cookies[:logged] = true
if resource.sign_in_count <= 1
# NOTE sets this parameter so we know the person is a first time user
folders_path(:newcomer => true)
else
folders_path
end
end
# Where to send user after logout
def after_sign_out_path_for(resource_or_scope)
cookies.delete(:logged)
new_user_session_path(:logout =>'on')
end
end
class FoldersController < ApplicationController
before_action :set_folder, only: [:show, :edit, :update, :destroy]
# GET /folders
# GET /folders.json
def index
@folders = Folder.all
vl = GFTP::VerboseList.new
vl.verbose_list '/people/plgtesttg/', current_user.proxy do |entries|
@entries = entries
end
end
# GET /folders/1
# GET /folders/1.json
def show
end
# GET /folders/new
def new
@folder = Folder.new
end
# GET /folders/1/edit
def edit
end
# POST /folders
# POST /folders.json
def create
@folder = Folder.new(folder_params)
respond_to do |format|
if @folder.save
format.html { redirect_to @folder, notice: 'Folder was successfully created.' }
format.json { render action: 'show', status: :created, location: @folder }
else
format.html { render action: 'new' }
format.json { render json: @folder.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /folders/1
# PATCH/PUT /folders/1.json
def update
respond_to do |format|
if @folder.update(folder_params)
format.html { redirect_to @folder, notice: 'Folder was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @folder.errors, status: :unprocessable_entity }
end
end
end
# DELETE /folders/1
# DELETE /folders/1.json
def destroy
@folder.destroy
respond_to do |format|
format.html { redirect_to folders_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_folder
@folder = Folder.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def folder_params
params[:folder]
end
end
class SessionsController < Devise::SessionsController
def new
if cookies[:logged]
cookies.delete(:logged)
flash[:error] = t('devise.failure.timeout')
redirect_to new_user_session_path(:logout =>'on')
else
super
end
end
end
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
skip_before_filter :verify_authenticity_token, :only => [:open_id]
def open_id
if plgrid_openid_callback?
@user = User.find_for_open_id(request.env['omniauth.auth'], current_user)
if @user.persisted?
flash[:notice] = I18n.t('devise.omniauth_callbacks.success', kind: 'PL-Grid OpenID')
sign_in_and_redirect @user, :event => :authentication
else
session['devise.google_data'] = request.env['omniauth.auth']
redirect_to new_user_registration_url
end
else
flash[:error] = I18n.t('devise.omniauth_callbacks.failure', kind: 'PL-Grid OpenID')
redirect_to root_path
end
end
protected
def plgrid_openid_callback?
begin
# checking openid server url
given_url = request.env['omniauth.auth']['extra']['response'].endpoint.server_url
if Plgdata::Application.config.plgrid_openid_url != given_url
raise 'This is not PL-Grid OpenID URL'
end
# checking necessary parameters
openid_user_info = request.env['omniauth.auth'].info
unless openid_user_info['nickname'] && openid_user_info['email'] && openid_user_info['name']
raise 'Request does not contain all required parameters'
end
true
rescue Exception => e
Rails.logger.error("Exception in OpenId handler: #{e}")
false
end
end
end
module ApplicationHelper
end
module FoldersHelper
end
class Folder < ActiveRecord::Base
end
class User < ActiveRecord::Base
devise :database_authenticatable
devise :omniauthable
has_and_belongs_to_many :user_teams, join_table: :user_team_users
def self.find_for_open_id(access_token, signed_in_resource=nil)
data = access_token.info
Rails.logger.debug("Open id data: #{data}")
if user = User.where(login: data['nickname'] || data['email']).first
user.sign_in_count += 1
else
user = User.new
user.sign_in_count = 1
end
user.login = data['nickname'] || data['email']