diff --git a/Procfile b/Procfile
new file mode 100644
index 0000000..b1e6e3a
--- /dev/null
+++ b/Procfile
@@ -0,0 +1,2 @@
+worker: bundle exec rake jobs:work
+guard: bundle exec guard
diff --git a/app/assets/images/avatar.png b/app/assets/images/avatar.png
new file mode 100644
index 0000000..d36f1e4
Binary files /dev/null and b/app/assets/images/avatar.png differ
diff --git a/app/assets/images/en.png b/app/assets/images/en.png
new file mode 100644
index 0000000..c1e8864
Binary files /dev/null and b/app/assets/images/en.png differ
diff --git a/app/assets/images/loading.gif b/app/assets/images/loading.gif
new file mode 100644
index 0000000..3e02203
Binary files /dev/null and b/app/assets/images/loading.gif differ
diff --git a/app/assets/images/pt.png b/app/assets/images/pt.png
new file mode 100644
index 0000000..f5916d7
Binary files /dev/null and b/app/assets/images/pt.png differ
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 3885622..06170c8 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -13,5 +13,4 @@
//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
-//= require turbolinks
//= require_tree .
diff --git a/app/assets/javascripts/static/v_libras/rapid.js b/app/assets/javascripts/static/v_libras/rapid.js
new file mode 100644
index 0000000..fb8930f
--- /dev/null
+++ b/app/assets/javascripts/static/v_libras/rapid.js
@@ -0,0 +1,26 @@
+$(function() {
+ $("#service-video").click(function() {
+ console.log($(this).prop('defaultChecked'));
+
+ $("#url").show('slow');
+ $("#legend").hide('slow');
+ });
+
+ $("#service-video-subtitle").click(function() {
+ console.log($(this).prop('defaultChecked'));
+
+ $("#url").show('slow');
+ $("#legend").show('slow');
+ });
+
+ /* When user press "Back" on the browser */
+ if ($("#service-video-subtitle")[0].checked) {
+ console.log('b');
+ $("#service-video-subtitle").click();
+ }
+
+ if ($("#service-video")[0].checked) {
+ console.log('a');
+ $("#service-video").click();
+ }
+});
\ No newline at end of file
diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss
index b6614ac..a089a6d 100644
--- a/app/assets/stylesheets/application.css.scss
+++ b/app/assets/stylesheets/application.css.scss
@@ -11,5 +11,6 @@
* file per style scope.
*
*= require 'bootstrap'
+ *= require 'v_libras/videos'
*= require_self
*/
diff --git a/app/assets/stylesheets/static.css.scss b/app/assets/stylesheets/static.css.scss
deleted file mode 100644
index b96eedb..0000000
--- a/app/assets/stylesheets/static.css.scss
+++ /dev/null
@@ -1,3 +0,0 @@
-// Place all the styles related to the Static controller here.
-// They will automatically be included in application.css.
-// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/v_libras/videos.css.scss b/app/assets/stylesheets/v_libras/videos.css.scss
new file mode 100644
index 0000000..6b6b8a1
--- /dev/null
+++ b/app/assets/stylesheets/v_libras/videos.css.scss
@@ -0,0 +1,12 @@
+.breadcrumb.requests {
+ margin-top: 20px;
+ clear: both;
+}
+
+.table-requests td, .table-requests th {
+ text-align: center;
+}
+
+.table-requests .label {
+ text-transform: lowercase;
+}
\ No newline at end of file
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index d83690e..b78efb7 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -2,4 +2,14 @@ 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
+
+
+protected
+ def check_vlibras_api_status
+ unless ApiClient.check_status
+ flash[:error] = 'SEAaaS API is down :('
+ redirect_to home_path
+ end
+ end
+
end
diff --git a/app/controllers/static/v_libras_controller.rb b/app/controllers/static/v_libras_controller.rb
deleted file mode 100644
index 391f99f..0000000
--- a/app/controllers/static/v_libras_controller.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class Static::VLibrasController < ApplicationController
- def rapid
-
- end
-end
diff --git a/app/controllers/v_libras/requests_controller.rb b/app/controllers/v_libras/requests_controller.rb
new file mode 100644
index 0000000..83d8773
--- /dev/null
+++ b/app/controllers/v_libras/requests_controller.rb
@@ -0,0 +1,23 @@
+class VLibras::RequestsController < ApplicationController
+ before_filter :check_vlibras_api_status
+
+ def rapid
+ @request = VLibras::Request.new
+ end
+
+ def create
+ @request = VLibras::Request.build_from_params(params, current_user)
+
+ if @request.save
+ @request.perform_request
+
+ flash[:success] = 'Sua requisição foi submetida com sucesso!'
+ redirect_to :action => :rapid
+ else
+ flash[:error] = 'Algo deu errado com a sua requisição.'
+ render :action => :rapid
+ end
+
+
+ end
+end
diff --git a/app/controllers/v_libras/videos_controller.rb b/app/controllers/v_libras/videos_controller.rb
new file mode 100644
index 0000000..c491b8f
--- /dev/null
+++ b/app/controllers/v_libras/videos_controller.rb
@@ -0,0 +1,8 @@
+class VLibras::VideosController < ApplicationController
+ before_filter :check_vlibras_api_status
+
+ def index
+ @videos = current_user.videos
+ @requests = current_user.requests.limit(10)
+ end
+end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 3e3b181..2531728 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -12,4 +12,35 @@ module ApplicationHelper
html.html_safe
end
+ def bootstrap_class_for(flash_type)
+ case flash_type.to_s
+ when "success"
+ "alert-success" # Green
+ when "error"
+ "alert-danger" # Red
+ when "alert"
+ "alert-warning" # Yellow
+ when "notice"
+ "alert-info" # Blue
+ else
+ flash_type
+ end
+ end
+
+ def request_status_label(status)
+ classes = [ 'label' ]
+
+ case status
+ when 'created'
+ when 'processing'
+ classes << 'label-warning'
+ when 'error'
+ classes << 'label-important'
+ when 'success'
+ classes << 'label-success'
+ end
+
+ content_tag(:div, t(status, scope: 'status'), :class => classes)
+ end
+
end
diff --git a/app/helpers/v_libras/videos_helper.rb b/app/helpers/v_libras/videos_helper.rb
new file mode 100644
index 0000000..9650251
--- /dev/null
+++ b/app/helpers/v_libras/videos_helper.rb
@@ -0,0 +1,2 @@
+module VLibras::VideosHelper
+end
diff --git a/app/models/.keep b/app/models/.keep
deleted file mode 100644
index e69de29..0000000
--- a/app/models/.keep
+++ /dev/null
diff --git a/app/models/role.rb b/app/models/role.rb
index 145baa7..f62f994 100644
--- a/app/models/role.rb
+++ b/app/models/role.rb
@@ -1,3 +1,20 @@
+# == Schema Information
+#
+# Table name: roles
+#
+# id :integer not null, primary key
+# name :string(255)
+# resource_id :integer
+# resource_type :string(255)
+# created_at :datetime
+# updated_at :datetime
+#
+# Indexes
+#
+# index_roles_on_name (name)
+# index_roles_on_name_and_resource_type_and_resource_id (name,resource_type,resource_id)
+#
+
class Role < ActiveRecord::Base
has_and_belongs_to_many :users, :join_table => :users_roles
belongs_to :resource, :polymorphic => true
diff --git a/app/models/user.rb b/app/models/user.rb
index fd9e136..11668f2 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,5 +1,34 @@
+# == Schema Information
+#
+# Table name: users
+#
+# id :integer not null, primary key
+# name :string(255)
+# email :string(255) default(""), not null
+# encrypted_password :string(255) default(""), not null
+# reset_password_token :string(255)
+# reset_password_sent_at :datetime
+# remember_created_at :datetime
+# sign_in_count :integer default(0), not null
+# current_sign_in_at :datetime
+# last_sign_in_at :datetime
+# current_sign_in_ip :string(255)
+# last_sign_in_ip :string(255)
+# created_at :datetime
+# updated_at :datetime
+#
+# Indexes
+#
+# index_users_on_email (email) UNIQUE
+# index_users_on_reset_password_token (reset_password_token) UNIQUE
+#
+
class User < ActiveRecord::Base
rolify
+
+ has_many :requests, :class => VLibras::Request, :foreign_key => :owner_id
+ has_many :videos, :through => :requests, :class => VLibras::Video
+
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
diff --git a/app/models/v_libras.rb b/app/models/v_libras.rb
new file mode 100644
index 0000000..244b0a6
--- /dev/null
+++ b/app/models/v_libras.rb
@@ -0,0 +1,5 @@
+module VLibras
+ def self.table_name_prefix
+ 'v_libras_'
+ end
+end
diff --git a/app/models/v_libras/request.rb b/app/models/v_libras/request.rb
new file mode 100644
index 0000000..b337f98
--- /dev/null
+++ b/app/models/v_libras/request.rb
@@ -0,0 +1,58 @@
+# == Schema Information
+#
+# Table name: v_libras_requests
+#
+# id :integer not null, primary key
+# status :string(255)
+# service_type :string(255)
+# owner_id :integer
+# params :text
+# response :text
+# created_at :datetime
+# updated_at :datetime
+#
+
+class VLibras::Request < ActiveRecord::Base
+ serialize :params
+
+ belongs_to :owner, :class => User
+
+ has_one :video, :class => VLibras::Video
+
+ validates :service_type,
+ presence: true,
+ inclusion: { in: %w(video-subtitle video), message: "%{value} is not a valid service type" }
+
+ validates :status,
+ presence: true,
+ inclusion: { in: %w(created processing error success), message: "%{value} is not a valid service type" }
+
+ before_save :default_values
+
+ default_scope { order('created_at DESC') }
+
+ def self.build_from_params(params, user)
+ request = self.new
+
+ request.service_type = params[:service]
+ request.owner = user
+
+ request.params = params[:params]
+
+ request
+ end
+
+ def perform_request
+ logger.debug '[VLibras::Request] Starting request'
+
+ ApiClient::Client.submit(self)
+
+ logger.debug '[VLibras::Request] Request done'
+ end
+ handle_asynchronously :perform_request
+
+private
+ def default_values
+ self.status ||= 'created'
+ end
+end
diff --git a/app/models/v_libras/video.rb b/app/models/v_libras/video.rb
new file mode 100644
index 0000000..888a88b
--- /dev/null
+++ b/app/models/v_libras/video.rb
@@ -0,0 +1,14 @@
+# == Schema Information
+#
+# Table name: v_libras_videos
+#
+# id :integer not null, primary key
+# request_id :integer
+# url :string(255)
+# created_at :datetime
+# updated_at :datetime
+#
+
+class VLibras::Video < ActiveRecord::Base
+ belongs_to :request, :class => VLibras::Request
+end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index b4f4055..5004f84 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -11,12 +11,11 @@
-
- <%= link_to "GTAaaS", home_path, :target => "blank", :class => "brand" %>
+ <%= link_to "GTAaaS", home_path, :class => "brand" %>
<%- if current_user.present? %>
@@ -27,14 +26,14 @@
<%= t('shared.vlibras') %>
-
+
<%= t('shared.wikilibras') %>
-
<%= link_to t('shared.slibras') %>
+
<%= link_to t('shared.slibras') %>
<%= link_to t('shared.about'), "http://gtaaas.lavid.ufpb.br/projeto", :target => "blank" %>
@@ -74,12 +73,21 @@
+
+ <% if content_for?(:menu) %>
<%= yield :menu %>
+ <% end %>
- <%#= render_breadcrumbs %>
+ <% flash.each do |type, message| %>
+
+
+ <%= message %>
+
+ <% end %>
+
<%= yield %>