sinatra-hexacta 0.1.0 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57e2b70893a33833d923a230a2efc0112358d81961b1897b6894bde81c49672a
4
- data.tar.gz: 9eb2b5cce23ac52c1bb105df09c4543b7291ad047f0150762ae13303a2bf1a97
3
+ metadata.gz: 88ea51caa7a52f637935c32abc1f7afa106c04edaa2272883fbae5e893f97d63
4
+ data.tar.gz: fd772074d655d5a9d1e3c4b55f946e26ce48c7ba11c9d5e53595d33da1e795fd
5
5
  SHA512:
6
- metadata.gz: 4e9c5a79fe2a7b4e33c3b37ec4b732f7306ae7f5402528dedce8e7f26f80e6b5e7ce13b3d5f86cbd6899fded25ee380c027c12570189475882e7567624783d76
7
- data.tar.gz: 8fd1274ede9d5e51882f02f7fdbda786d8a8f1f05d1346a422ae68435ca3f818d85e7586d40b4a2443e95fc6ee2a6bd998c06ce704463ad5a37a86a27c309f54
6
+ metadata.gz: d74e7e326295bcaf359eb3dba3e9e1c272d29d49d3b1dda7996b43c7b72ebf23e4179afa37b4be7b8e468e7f4065bc3fef49c6a8529d263d1b737d4ca8dfca07
7
+ data.tar.gz: f7dc72f4b88e48dcebce5a626de936f291b5e0eaf9e6a8b1aa02ae443a588d4cfb7f873d53a1b80f3898737102a586a43d06eda17714c58444c7d5f5332d504d
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ class GeneralMail < Mail
3
+
4
+ def initialize(args)
5
+ super(args)
6
+ @subject = args[:subject]
7
+ @description = args[:description]
8
+ @link = args[:link]
9
+ end
10
+
11
+ def template
12
+ 'general'
13
+ end
14
+
15
+ def subject
16
+ @subject
17
+ end
18
+
19
+ def values
20
+ data = {}
21
+ data["{description}"] = @description
22
+ data["{link}"] = @link
23
+ data
24
+ end
25
+
26
+ end
@@ -2,3 +2,7 @@
2
2
  require_relative 'date'
3
3
  require_relative 'antiquity'
4
4
  require_relative 'notification'
5
+ require_relative 'mailsender'
6
+ require_relative 'mail'
7
+ require_relative 'generalmail'
8
+ require_relative 'mailbuilder'
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ class Mail
3
+
4
+ def initialize(args)
5
+ @receivers = args[:to]
6
+ @sender = args[:from]
7
+ end
8
+
9
+ def template
10
+ raise Exception, "You have to override 'template' method in #{self.class}"
11
+ end
12
+
13
+ def subject
14
+ raise Exception, "You have to override 'subject' method in #{self.class}"
15
+ end
16
+
17
+ def values
18
+ raise Exception, "You have to override 'values' method in #{self.class}"
19
+ end
20
+
21
+ def to
22
+ _receivers = {}
23
+ @receivers.each { |user| _receivers[user.full_name] = "Persons" }
24
+ _receivers
25
+ end
26
+
27
+ def from
28
+ @sender ||= "apps@hexacta.com"
29
+ end
30
+
31
+ def send
32
+ MailSender.perform_async(self)
33
+ end
34
+
35
+ end
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+ class MailBuilder
3
+
4
+ def to(receivers)
5
+ @to = receivers
6
+ return self
7
+ end
8
+
9
+ def from(sender)
10
+ @from = "#{sender.hxt_id}@hexacta.com"
11
+ return self
12
+ end
13
+
14
+ def subject(a_subject)
15
+ @subject = a_subject
16
+ return self
17
+ end
18
+
19
+ def description(a_description)
20
+ @description = a_description
21
+ return self
22
+ end
23
+
24
+ def link(a_link)
25
+ @link = a_link
26
+ return self
27
+ end
28
+
29
+ def send
30
+ @from ||= "apps@hexacta.com"
31
+ GeneralMail.new({ :to => @to,
32
+ :from => @from,
33
+ :subject => @subject,
34
+ :description => @description,
35
+ :link => @link
36
+ }).send
37
+ end
38
+ end
@@ -0,0 +1,88 @@
1
+ # encoding: utf-8
2
+ require 'singleton'
3
+ require 'sucker_punch'
4
+
5
+ class MailSender
6
+ include SuckerPunch::Job
7
+
8
+ attr_reader :access_token, :expire, :refresh_token
9
+
10
+ def _do_connect(uri, form={},token=nil)
11
+ url = URI.parse("#{uri}")
12
+ http = Net::HTTP.new(url.host, url.port)
13
+ http.read_timeout = 1000
14
+ http.use_ssl = (url.scheme == 'https')
15
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
16
+ header = { 'Content-Type' => 'application/x-www-form-urlencoded' }
17
+ header["Authorization"] = "Bearer #{token}" unless token.nil?
18
+ request = Net::HTTP::Post.new(url, header)
19
+ request.form_data = form
20
+ http.start { |http| http.request(request) }
21
+ end
22
+
23
+ def _authorize_mail
24
+ params = [ [ "grant_type", "password" ], [ "client_id", "MailApp" ], [ "client_secret", "MailAppPRD2018!" ] ]
25
+ response = _do_connect("https://comunicacion.hexacta.com:4443/apptoken",params)
26
+ if( response.is_a?( Net::HTTPSuccess ) )
27
+ token = JSON.parse(response.body)
28
+ @access_token = token["access_token"]
29
+ @refresh_token = token["refresh_token"]
30
+ @expire = DateTime.parse(token[".expires"])
31
+ else
32
+ NotificationSender.instance.send_error(nil,'Authorize mail failed',response.body)
33
+ end
34
+ end
35
+
36
+ def _build_map_values(mail_values)
37
+ values = []
38
+ for key in mail_values.keys
39
+ index = mail_values.keys.index(key)
40
+ values << ["MailValues[#{index}].Key", key]
41
+ values << ["MailValues[#{index}].Value", mail_values[key]]
42
+ end
43
+ values
44
+ end
45
+
46
+ def _build_to_map(to_map)
47
+ values = []
48
+ for key in to_map.keys
49
+ index = to_map.keys.index(key)
50
+ values << ["ResourcesRequest[#{index}].TypeGroup", to_map[key]]
51
+ values << ["ResourcesRequest[#{index}].Name", key]
52
+ end
53
+ values
54
+ end
55
+
56
+ def _expired?
57
+ expire.nil? || DateTime.now < expire
58
+ end
59
+
60
+ def do_send(mail)
61
+ begin
62
+ if _expired?
63
+ _authorize_mail
64
+ end
65
+
66
+ params = [ [ "ApplicationCode", 2009 ], [ "Name", mail.template ], [ "Subject", mail.subject ], [ "EmailAddress", mail.from ] ]
67
+ params = params + _build_map_values(mail.values) + _build_to_map(mail.to)
68
+
69
+ response = _do_connect("https://comunicacion.hexacta.com:4444/api/app/TemplateNotification/SendMail",params,@access_token)
70
+
71
+ if( !response.is_a?( Net::HTTPSuccess ) )
72
+ NotificationSender.instance.send_error(nil,'Send mail failed',response.body)
73
+ end
74
+ rescue StandardError => error
75
+ message = error.backtrace.join(',');
76
+ NotificationSender.instance.send_error(nil,"Mail send error",message)
77
+ end
78
+ end
79
+
80
+ def send(mail)
81
+ run(mail) #Async call
82
+ end
83
+
84
+ #For async method call
85
+ def perform(mail)
86
+ do_send(mail)
87
+ end
88
+ end
@@ -1,7 +1,10 @@
1
1
  # encoding: utf-8
2
+ require 'singleton'
3
+
2
4
  class NotificationSender
5
+ include Singleton
3
6
 
4
- def self.send_to(user,creator,title,message,label,link=nil)
7
+ def send_to(user,creator,title,message,label,link=nil)
5
8
  notification = Notification.find_or_create(:user_id => user.id,
6
9
  :creator_id => creator.id,
7
10
  :title => title,
@@ -16,13 +19,13 @@ class NotificationSender
16
19
  notification
17
20
  end
18
21
 
19
- def self.send_to_subscriptors(creator,title,message,label,link=nil)
22
+ def send_to_subscriptors(creator,title,message,label,link=nil)
20
23
  Subscription.where(:label => label).all.each do |subscription|
21
- notification = NotificationSender.send_to(subscription.user,creator,title,message,label,link)
24
+ notification = send_to(subscription.user,creator,title,message,label,link)
22
25
  end
23
26
  end
24
27
 
25
- def self.send_error(creator,title,message)
28
+ def send_error(creator,title,message)
26
29
  Subscription.where(:label => 'error').all.each do |subscription|
27
30
  creator = subscription.user if creator.nil?
28
31
  notification = Notification.find(:user_id => subscription.user_id,
@@ -32,7 +35,7 @@ class NotificationSender
32
35
  :label => 'error',
33
36
  :read_date => nil)
34
37
  if notification.nil?
35
- notification = NotificationSender.send_to(subscription.user,creator,title,message,'error')
38
+ notification = send_to(subscription.user,creator,title,message,'error')
36
39
  end
37
40
  end
38
41
 
@@ -13,12 +13,12 @@ module Sinatra
13
13
  end
14
14
 
15
15
  def error_template(code)
16
- ErrorHandler.symlink("/lib/sinatra/views/errors/#{code}.slim","/app/views/#{Hexacta::GEM_FILE_DIR}/errors/#{code}.slim")
16
+ ErrorHandler.copy_file("/lib/sinatra/views/errors/#{code}.slim","/app/views/#{Hexacta::GEM_FILE_DIR}/errors/#{code}.slim")
17
17
  error code do
18
18
  if code == 500
19
19
  title = env['sinatra.error'].message.split(':')[0].gsub('#<','');
20
20
  message = (["in #{request.url}"] + env['sinatra.error'].backtrace).join(',');
21
- NotificationSender.send_error(authenticated(User),title,message)
21
+ NotificationSender.instance.send_error(authenticated(User),title,message)
22
22
  end
23
23
  slim "#{Hexacta::GEM_FILE_DIR}/errors/#{code}".to_sym, locals: { :params => params }
24
24
  end
@@ -6,15 +6,15 @@ module Sinatra
6
6
  def enable_notifications
7
7
  p "Enabling notifications..."
8
8
  NotificationHandler.setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/notifications")
9
- NotificationHandler.symlink("/lib/sinatra/views/notifications.slim","/app/views/#{Hexacta::GEM_FILE_DIR}/notifications.slim")
10
- NotificationHandler.symlink_all("/lib/sinatra/views/notifications","/app/views/#{Hexacta::GEM_FILE_DIR}/notifications")
9
+ NotificationHandler.copy_file("/lib/sinatra/views/notifications.slim","/app/views/#{Hexacta::GEM_FILE_DIR}/notifications.slim")
10
+ NotificationHandler.copy_all_files("/lib/sinatra/views/notifications","/app/views/#{Hexacta::GEM_FILE_DIR}/notifications")
11
11
 
12
12
  post '/notification' do
13
13
  if params[:user_ids].blank?
14
- NotificationSender.send_to_subscriptors(authenticated(User),params[:title],params[:message],params[:label])
14
+ NotificationSender.instance.send_to_subscriptors(authenticated(User),params[:title],params[:message],params[:label])
15
15
  else
16
16
  for id in params[:user_ids]
17
- NotificationSender.send_to(User.find(:id => id),authenticated(User),params[:title],params[:message],params[:label])
17
+ NotificationSender.instance.send_to(User.find(:id => id),authenticated(User),params[:title],params[:message],params[:label])
18
18
  end
19
19
  end
20
20
  redirect back
@@ -14,7 +14,7 @@ module Sinatra
14
14
  end
15
15
 
16
16
  get '/reports/:report_name' do |report_name|
17
- date = Date.parse(params["date"]) unless params["date"].nil?
17
+ date = Date.parse(params[:date]) unless params[:date].nil?
18
18
  date ||= Date.today
19
19
  headers "Content-Disposition" => "attachment;filename=#{report_name}.#{date}.xls",
20
20
  "Content-Type" => "application/octet-stream"
@@ -20,7 +20,7 @@ module Sinatra
20
20
  end
21
21
 
22
22
  setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/alerts")
23
- symlink_all("/lib/sinatra/views/alerts","/app/views/#{Hexacta::GEM_FILE_DIR}/alerts")
23
+ copy_all_files("/lib/sinatra/views/alerts","/app/views/#{Hexacta::GEM_FILE_DIR}/alerts")
24
24
  end
25
25
 
26
26
  helpers AlertHelper
@@ -24,7 +24,7 @@ module Sinatra
24
24
  end
25
25
 
26
26
  setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/charts")
27
- symlink_all("/lib/sinatra/views/charts","/app/views/#{Hexacta::GEM_FILE_DIR}/charts")
27
+ copy_all_files("/lib/sinatra/views/charts","/app/views/#{Hexacta::GEM_FILE_DIR}/charts")
28
28
  end
29
29
 
30
30
  helpers ChartsHelper
@@ -40,7 +40,7 @@ module Sinatra
40
40
  end
41
41
 
42
42
  setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/inputs")
43
- symlink_all("/lib/sinatra/views/inputs","/app/views/#{Hexacta::GEM_FILE_DIR}/inputs")
43
+ copy_all_files("/lib/sinatra/views/inputs","/app/views/#{Hexacta::GEM_FILE_DIR}/inputs")
44
44
  end
45
45
 
46
46
  helpers InputHelper
@@ -18,7 +18,7 @@ module Sinatra
18
18
  p "Setting up libraries directory..."
19
19
  copy_dir_structure("/lib/sinatra/public","/app/public/#{Hexacta::GEM_FILE_DIR}")
20
20
  setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/libraries")
21
- symlink_all("/lib/sinatra/views/libraries","/app/views/#{Hexacta::GEM_FILE_DIR}/libraries")
21
+ copy_all_files("/lib/sinatra/views/libraries","/app/views/#{Hexacta::GEM_FILE_DIR}/libraries")
22
22
  end
23
23
 
24
24
  helpers LibrariesHelper
@@ -20,7 +20,7 @@ module Sinatra
20
20
  end
21
21
 
22
22
  setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/reports")
23
- symlink_all("/lib/sinatra/views/reports","/app/views/#{Hexacta::GEM_FILE_DIR}/reports")
23
+ copy_all_files("/lib/sinatra/views/reports","/app/views/#{Hexacta::GEM_FILE_DIR}/reports")
24
24
  end
25
25
 
26
26
  helpers ReportHelper
@@ -21,7 +21,7 @@ module Sinatra
21
21
  rescue StandardError => error
22
22
  title = error.message.split(':')[0].gsub('#<','');
23
23
  message = error.backtrace.join(',');
24
- NotificationSender.send_error(nil,title,message)
24
+ NotificationSender.instance.send_error(nil,title,message)
25
25
  end
26
26
 
27
27
  end
@@ -50,7 +50,7 @@ module Sinatra
50
50
  rescue error
51
51
  title = error.message.split(':')[0].gsub('#<','');
52
52
  message = error.backtrace.join(',');
53
- NotificationSender.send_error(nil,title,message)
53
+ NotificationSender.instance.send_error(nil,title,message)
54
54
  end
55
55
 
56
56
  end
@@ -9,28 +9,26 @@ module Sinatra
9
9
  module Hexacta
10
10
  GEM_FILE_DIR = "sinatra-hexacta"
11
11
 
12
- def symlink(original_path, link_path)
13
- File.symlink "#{Gem.loaded_specs["sinatra-hexacta"].gem_dir}#{original_path}", "#{link_path}" unless Gem.loaded_specs["sinatra-hexacta"].nil? || File.exist?("#{link_path}")
12
+ def gem_path
13
+ File.expand_path("../..",__dir__)
14
14
  end
15
15
 
16
- def symlink_all(original_path, link_path)
17
- Dir.foreach("#{Gem.loaded_specs["sinatra-hexacta"].gem_dir}#{original_path}") do |child|
18
- symlink("#{original_path}/#{child}","#{link_path}/#{child}") unless child == '.' || child == '..'
19
- end unless Gem.loaded_specs["sinatra-hexacta"].nil?
16
+ def copy_file(original_path, link_path)
17
+ IO.copy_stream("#{gem_path}#{original_path}",link_path) unless File.exist?(link_path) && FileUtils.compare_file("#{gem_path}#{original_path}",link_path)
20
18
  end
21
19
 
22
- def setup_dir(path)
23
- unless Gem.loaded_specs["sinatra-hexacta"].nil?
24
- FileUtils.remove_dir path if Dir.exist? path
25
- FileUtils.mkdir_p path
20
+ def copy_all_files(original_path, link_path)
21
+ Dir.foreach("#{gem_path}#{original_path}") do |child|
22
+ copy_file("#{original_path}/#{child}","#{link_path}/#{child}") unless child == '.' || child == '..'
26
23
  end
27
24
  end
28
25
 
26
+ def setup_dir(path)
27
+ FileUtils.mkdir_p path
28
+ end
29
+
29
30
  def copy_dir_structure(original_path, destination_path)
30
- unless Gem.loaded_specs["sinatra-hexacta"].nil?
31
- FileUtils.remove_dir destination_path if Dir.exist? destination_path
32
- FileUtils.copy_entry("#{Gem.loaded_specs["sinatra-hexacta"].gem_dir}#{original_path}", destination_path)
33
- end
31
+ FileUtils.copy_entry("#{gem_path}#{original_path}", destination_path)
34
32
  end
35
33
  end
36
34
  end
@@ -10567,6 +10567,14 @@ h6 small,
10567
10567
  left: 0;
10568
10568
  width: 100%;
10569
10569
  height: 70px;
10570
+ background: #fff;
10571
+ -webkit-transition: all;
10572
+ -o-transition: all;
10573
+ transition: all;
10574
+ -webkit-transition-duration: 300ms;
10575
+ transition-duration: 300ms;
10576
+ opacity: 0;
10577
+ filter: alpha(opacity=0);
10570
10578
  z-index: 10;
10571
10579
  }
10572
10580
 
@@ -10582,8 +10590,8 @@ h6 small,
10582
10590
  color: white;
10583
10591
  }
10584
10592
 
10585
- #header input[type="text"]::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
10586
- color: rgba(255,255,255,0.6);;
10593
+ #header input[type="text"]::placeholder {
10594
+ color: rgba(255,255,255,0.6);;
10587
10595
  }
10588
10596
 
10589
10597
  #top-search-wrap input[type="text"] {
@@ -39,6 +39,7 @@ $(document).ready(function(){
39
39
  $(this).find('#submit').attr('disabled','disabled');
40
40
  }
41
41
  });
42
+
42
43
  $('.chosen[required]').on('change', function(change, deselected) { //selected OR deselected
43
44
  if ($(this).val() == "" || $(this).val() == null) {
44
45
  $(this).parent().removeClass("success");
@@ -48,36 +49,6 @@ $(document).ready(function(){
48
49
  $(this).parent().addClass("success");
49
50
  }
50
51
  });
51
- /* --------------------------------------------------------
52
- Layout
53
- -----------------------------------------------------------*/
54
- (function () {
55
-
56
- //Get saved layout type from LocalStorage
57
- var layoutStatus = localStorage.getItem('ma-layout-status');
58
- $('#header').attr('data-current-skin', "pink");
59
- if(!$('#header-2')[0]) { //Make it work only on normal headers
60
- if (layoutStatus == 1) {
61
- $('body').addClass('sw-toggled');
62
- $('#tw-switch').prop('checked', true);
63
- }
64
- }
65
-
66
- $('body').on('change', '#toggle-width input:checkbox', function () {
67
- if ($(this).is(':checked')) {
68
- setTimeout(function () {
69
- $('body').addClass('toggled sw-toggled');
70
- localStorage.setItem('ma-layout-status', 1);
71
- }, 250);
72
- }
73
- else {
74
- setTimeout(function () {
75
- $('body').removeClass('toggled sw-toggled');
76
- localStorage.setItem('ma-layout-status', 0);
77
- }, 250);
78
- }
79
- });
80
- })();
81
52
 
82
53
  //Hack for modal to work on dropdown menu
83
54
  $('header .lv-item').click(function(e) {
@@ -110,30 +81,12 @@ $(document).ready(function(){
110
81
  }
111
82
  }
112
83
 
113
- /*
114
- * Top Search
115
- */
116
- (function(){
117
- $('body').on('click', '#top-search > a', function(e){
118
- e.preventDefault();
119
-
120
- $('#header').addClass('search-toggled');
121
- $('#top-search-wrap input').focus();
122
- });
123
-
124
- $('body').on('click', '#top-search-close', function(e){
125
- e.preventDefault();
126
-
127
- $('#header').removeClass('search-toggled');
128
- });
129
- })();
130
-
131
84
  /*
132
85
  * Sidebar
133
86
  */
134
87
  (function(){
135
88
  //Toggle
136
- $('body').on('click', '#menu-trigger, #chat-trigger', function(e){
89
+ $('body').on('click', '#menu-trigger', function(e){
137
90
  e.preventDefault();
138
91
  var x = $(this).data('trigger');
139
92
 
@@ -146,58 +99,42 @@ $(document).ready(function(){
146
99
  $(this).find('ul').hide();
147
100
  });
148
101
 
102
+ $('.profile-menu .main-menu').hide();
149
103
 
104
+ if (x == '#sidebar') {
150
105
 
151
- $('.profile-menu .main-menu').hide();
152
-
153
- if (x == '#sidebar') {
154
-
155
- $elem = '#sidebar';
156
- $elem2 = '#menu-trigger';
157
-
158
- $('#chat-trigger').removeClass('open');
159
-
160
- if (!$('#chat').hasClass('toggled')) {
161
- $('#header').toggleClass('sidebar-toggled');
162
- }
163
- else {
164
- $('#chat').removeClass('toggled');
165
- }
166
- }
106
+ $elem = '#sidebar';
107
+ $elem2 = '#menu-trigger';
167
108
 
168
- if (x == '#chat') {
169
- $elem = '#chat';
170
- $elem2 = '#chat-trigger';
109
+ $('#chat-trigger').removeClass('open');
171
110
 
172
- $('#menu-trigger').removeClass('open');
173
-
174
- if (!$('#sidebar').hasClass('toggled')) {
175
- $('#header').toggleClass('sidebar-toggled');
176
- }
177
- else {
178
- $('#sidebar').removeClass('toggled');
179
- }
180
- }
111
+ if (!$('#chat').hasClass('toggled')) {
112
+ $('#header').toggleClass('sidebar-toggled');
113
+ }
114
+ else {
115
+ $('#chat').removeClass('toggled');
116
+ }
117
+ }
181
118
 
182
- //When clicking outside
183
- if ($('#header').hasClass('sidebar-toggled')) {
184
- $(document).on('click', function (e) {
185
- if (($(e.target).closest($elem).length === 0) && ($(e.target).closest($elem2).length === 0)) {
186
- setTimeout(function(){
187
- $($elem).removeClass('toggled');
188
- $('#header').removeClass('sidebar-toggled');
189
- $($elem2).removeClass('open');
190
- });
191
- }
192
- });
193
- }
119
+ //When clicking outside
120
+ if ($('#header').hasClass('sidebar-toggled')) {
121
+ $(document).on('click', function (e) {
122
+ if (($(e.target).closest($elem).length === 0) && ($(e.target).closest($elem2).length === 0)) {
123
+ setTimeout(function(){
124
+ $($elem).removeClass('toggled');
125
+ $('#header').removeClass('sidebar-toggled');
126
+ $($elem2).removeClass('open');
127
+ });
128
+ }
129
+ });
130
+ }
194
131
  })
195
132
 
196
133
  //Submenu
197
134
  $('body').on('click', '.sub-menu > a', function(e){
198
- e.preventDefault();
199
- $(this).next().slideToggle(200);
200
- $(this).parent().toggleClass('toggled');
135
+ e.preventDefault();
136
+ $(this).next().slideToggle(200);
137
+ $(this).parent().toggleClass('toggled');
201
138
  });
202
139
  })();
203
140
 
@@ -229,7 +166,7 @@ $(document).ready(function(){
229
166
 
230
167
  //Popup empty message
231
168
  setTimeout(function(){
232
- $('#notifications').addClass('empty');
169
+ $('#notifications').addClass('empty');
233
170
  }, (z*150)+200);
234
171
  });
235
172
 
@@ -380,9 +317,9 @@ $(document).ready(function(){
380
317
  * Waves Animation
381
318
  */
382
319
  (function(){
383
- Waves.attach('.btn:not(.btn-icon):not(.btn-float)');
384
- Waves.attach('.btn-icon, .btn-float', ['waves-circle', 'waves-float']);
385
- Waves.init();
320
+ Waves.attach('.btn:not(.btn-icon):not(.btn-float)');
321
+ Waves.attach('.btn-icon, .btn-float', ['waves-circle', 'waves-float']);
322
+ Waves.init();
386
323
  })();
387
324
 
388
325
  /*
@@ -462,87 +399,6 @@ $(document).ready(function(){
462
399
  });
463
400
  }
464
401
 
465
- /*
466
- * Login
467
- */
468
- if ($('.login-content')[0]) {
469
- //Add class to HTML. This is used to center align the logn box
470
- $('html').addClass('login-content');
471
-
472
- $('body').on('click', '.login-navigation > li', function(){
473
- var z = $(this).data('block');
474
- var t = $(this).closest('.lc-block');
475
-
476
- t.removeClass('toggled');
477
-
478
- setTimeout(function(){
479
- $(z).addClass('toggled');
480
- });
481
-
482
- })
483
- }
484
-
485
- /*
486
- * Fullscreen Browsing
487
- */
488
- if ($('[data-action="fullscreen"]')[0]) {
489
- var fs = $("[data-action='fullscreen']");
490
- fs.on('click', function(e) {
491
- e.preventDefault();
492
-
493
- //Launch
494
- function launchIntoFullscreen(element) {
495
- if(element.requestFullscreen) {
496
- element.requestFullscreen();
497
- } else if(element.mozRequestFullScreen) {
498
- element.mozRequestFullScreen();
499
- } else if(element.webkitRequestFullscreen) {
500
- element.webkitRequestFullscreen();
501
- } else if(element.msRequestFullscreen) {
502
- element.msRequestFullscreen();
503
- }
504
- }
505
-
506
- //Exit
507
- function exitFullscreen() {
508
- if(document.exitFullscreen) {
509
- document.exitFullscreen();
510
- } else if(document.mozCancelFullScreen) {
511
- document.mozCancelFullScreen();
512
- } else if(document.webkitExitFullscreen) {
513
- document.webkitExitFullscreen();
514
- }
515
- }
516
-
517
- launchIntoFullscreen(document.documentElement);
518
- fs.closest('.dropdown').removeClass('open');
519
- });
520
- }
521
-
522
- /*
523
- * Clear Local Storage
524
- */
525
- if ($('[data-action="clear-localstorage"]')[0]) {
526
- var cls = $('[data-action="clear-localstorage"]');
527
-
528
- cls.on('click', function(e) {
529
- e.preventDefault();
530
-
531
- swal({
532
- title: "¿Estás seguro?",
533
- text: "Todos tus datos locales serán borrados.",
534
- type: "warning",
535
- showCancelButton: true,
536
- confirmButtonColor: "#DD6B55",
537
- confirmButtonText: "Borrar",
538
- cancelButtonText: "Cancelar",
539
- closeOnConfirm: false
540
- }, function(){
541
- localStorage.clear();
542
- swal("Hecho!", "Cache borrada", "success");
543
- });
544
- });
545
- }
546
402
 
547
403
  /*
548
404
  * Profile Edit Toggle
@@ -785,10 +641,6 @@ function advance_search(url,offset,format) {
785
641
  }
786
642
  };
787
643
 
788
- $(document).ready(function(){
789
- $( ".paginator" ).clone().appendTo( "#content" );
790
- });
791
-
792
644
  function read_notify(id,url) {
793
645
  $.ajax({
794
646
  url: '/notifications/' + id,
@@ -4,5 +4,4 @@
4
4
  * Copyright 2013-2015 Twitter, Inc. and other contributors; Licensed MIT
5
5
  */
6
6
 
7
- !function(a,b){"function"==typeof define&&define.amd?define("bloodhound",["jquery"],function(c){return a.Bloodhound=b(c)}):"object"==typeof exports?module.exports=b(require("jquery")):a.Bloodhound=b(jQuery)}(this,function(a){var b=function(){"use strict";return{isMsie:function(){return/(msie|trident)/i.test(navigator.userAgent)?navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2]:!1},isBlankString:function(a){return!a||/^\s*$/.test(a)},escapeRegExChars:function(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},isString:function(a){return"string"==typeof a},isNumber:function(a){return"number"==typeof a},isArray:a.isArray,isFunction:a.isFunction,isObject:a.isPlainObject,isUndefined:function(a){return"undefined"==typeof a},isElement:function(a){return!(!a||1!==a.nodeType)},isJQuery:function(b){return b instanceof a},toStr:function(a){return b.isUndefined(a)||null===a?"":a+""},bind:a.proxy,each:function(b,c){function d(a,b){return c(b,a)}a.each(b,d)},map:a.map,filter:a.grep,every:function(b,c){var d=!0;return b?(a.each(b,function(a,e){return(d=c.call(null,e,a,b))?void 0:!1}),!!d):d},some:function(b,c){var d=!1;return b?(a.each(b,function(a,e){return(d=c.call(null,e,a,b))?!1:void 0}),!!d):d},mixin:a.extend,identity:function(a){return a},clone:function(b){return a.extend(!0,{},b)},getIdGenerator:function(){var a=0;return function(){return a++}},templatify:function(b){function c(){return String(b)}return a.isFunction(b)?b:c},defer:function(a){setTimeout(a,0)},debounce:function(a,b,c){var d,e;return function(){var f,g,h=this,i=arguments;return f=function(){d=null,c||(e=a.apply(h,i))},g=c&&!d,clearTimeout(d),d=setTimeout(f,b),g&&(e=a.apply(h,i)),e}},throttle:function(a,b){var c,d,e,f,g,h;return g=0,h=function(){g=new Date,e=null,f=a.apply(c,d)},function(){var i=new Date,j=b-(i-g);return c=this,d=arguments,0>=j?(clearTimeout(e),e=null,g=i,f=a.apply(c,d)):e||(e=setTimeout(h,j)),f}},stringify:function(a){return b.isString(a)?a:JSON.stringify(a)},noop:function(){}}}(),c="0.11.1",d=function(){"use strict";function a(a){return a=b.toStr(a),a?a.split(/\s+/):[]}function c(a){return a=b.toStr(a),a?a.split(/\W+/):[]}function d(a){return function(c){return c=b.isArray(c)?c:[].slice.call(arguments,0),function(d){var e=[];return b.each(c,function(c){e=e.concat(a(b.toStr(d[c])))}),e}}}return{nonword:c,whitespace:a,obj:{nonword:d(c),whitespace:d(a)}}}(),e=function(){"use strict";function c(c){this.maxSize=b.isNumber(c)?c:100,this.reset(),this.maxSize<=0&&(this.set=this.get=a.noop)}function d(){this.head=this.tail=null}function e(a,b){this.key=a,this.val=b,this.prev=this.next=null}return b.mixin(c.prototype,{set:function(a,b){var c,d=this.list.tail;this.size>=this.maxSize&&(this.list.remove(d),delete this.hash[d.key],this.size--),(c=this.hash[a])?(c.val=b,this.list.moveToFront(c)):(c=new e(a,b),this.list.add(c),this.hash[a]=c,this.size++)},get:function(a){var b=this.hash[a];return b?(this.list.moveToFront(b),b.val):void 0},reset:function(){this.size=0,this.hash={},this.list=new d}}),b.mixin(d.prototype,{add:function(a){this.head&&(a.next=this.head,this.head.prev=a),this.head=a,this.tail=this.tail||a},remove:function(a){a.prev?a.prev.next=a.next:this.head=a.next,a.next?a.next.prev=a.prev:this.tail=a.prev},moveToFront:function(a){this.remove(a),this.add(a)}}),c}(),f=function(){"use strict";function c(a,c){this.prefix=["__",a,"__"].join(""),this.ttlKey="__ttl__",this.keyMatcher=new RegExp("^"+b.escapeRegExChars(this.prefix)),this.ls=c||h,!this.ls&&this._noop()}function d(){return(new Date).getTime()}function e(a){return JSON.stringify(b.isUndefined(a)?null:a)}function f(b){return a.parseJSON(b)}function g(a){var b,c,d=[],e=h.length;for(b=0;e>b;b++)(c=h.key(b)).match(a)&&d.push(c.replace(a,""));return d}var h;try{h=window.localStorage,h.setItem("~~~","!"),h.removeItem("~~~")}catch(i){h=null}return b.mixin(c.prototype,{_prefix:function(a){return this.prefix+a},_ttlKey:function(a){return this._prefix(a)+this.ttlKey},_noop:function(){this.get=this.set=this.remove=this.clear=this.isExpired=b.noop},_safeSet:function(a,b){try{this.ls.setItem(a,b)}catch(c){"QuotaExceededError"===c.name&&(this.clear(),this._noop())}},get:function(a){return this.isExpired(a)&&this.remove(a),f(this.ls.getItem(this._prefix(a)))},set:function(a,c,f){return b.isNumber(f)?this._safeSet(this._ttlKey(a),e(d()+f)):this.ls.removeItem(this._ttlKey(a)),this._safeSet(this._prefix(a),e(c))},remove:function(a){return this.ls.removeItem(this._ttlKey(a)),this.ls.removeItem(this._prefix(a)),this},clear:function(){var a,b=g(this.keyMatcher);for(a=b.length;a--;)this.remove(b[a]);return this},isExpired:function(a){var c=f(this.ls.getItem(this._ttlKey(a)));return b.isNumber(c)&&d()>c?!0:!1}}),c}(),g=function(){"use strict";function c(a){a=a||{},this.cancelled=!1,this.lastReq=null,this._send=a.transport,this._get=a.limiter?a.limiter(this._get):this._get,this._cache=a.cache===!1?new e(0):h}var d=0,f={},g=6,h=new e(10);return c.setMaxPendingRequests=function(a){g=a},c.resetCache=function(){h.reset()},b.mixin(c.prototype,{_fingerprint:function(b){return b=b||{},b.url+b.type+a.param(b.data||{})},_get:function(a,b){function c(a){b(null,a),k._cache.set(i,a)}function e(){b(!0)}function h(){d--,delete f[i],k.onDeckRequestArgs&&(k._get.apply(k,k.onDeckRequestArgs),k.onDeckRequestArgs=null)}var i,j,k=this;i=this._fingerprint(a),this.cancelled||i!==this.lastReq||((j=f[i])?j.done(c).fail(e):g>d?(d++,f[i]=this._send(a).done(c).fail(e).always(h)):this.onDeckRequestArgs=[].slice.call(arguments,0))},get:function(c,d){var e,f;d=d||a.noop,c=b.isString(c)?{url:c}:c||{},f=this._fingerprint(c),this.cancelled=!1,this.lastReq=f,(e=this._cache.get(f))?d(null,e):this._get(c,d)},cancel:function(){this.cancelled=!0}}),c}(),h=window.SearchIndex=function(){"use strict";function c(c){c=c||{},c.datumTokenizer&&c.queryTokenizer||a.error("datumTokenizer and queryTokenizer are both required"),this.identify=c.identify||b.stringify,this.datumTokenizer=c.datumTokenizer,this.queryTokenizer=c.queryTokenizer,this.reset()}function d(a){return a=b.filter(a,function(a){return!!a}),a=b.map(a,function(a){return a.toLowerCase()})}function e(){var a={};return a[i]=[],a[h]={},a}function f(a){for(var b={},c=[],d=0,e=a.length;e>d;d++)b[a[d]]||(b[a[d]]=!0,c.push(a[d]));return c}function g(a,b){var c=0,d=0,e=[];a=a.sort(),b=b.sort();for(var f=a.length,g=b.length;f>c&&g>d;)a[c]b[d]?d++:(e.push(a[c]),c++,d++);return e}var h="c",i="i";return b.mixin(c.prototype,{bootstrap:function(a){this.datums=a.datums,this.trie=a.trie},add:function(a){var c=this;a=b.isArray(a)?a:[a],b.each(a,function(a){var f,g;c.datums[f=c.identify(a)]=a,g=d(c.datumTokenizer(a)),b.each(g,function(a){var b,d,g;for(b=c.trie,d=a.split("");g=d.shift();)b=b[h][g]||(b[h][g]=e()),b[i].push(f)})})},get:function(a){var c=this;return b.map(a,function(a){return c.datums[a]})},search:function(a){var c,e,j=this;return c=d(this.queryTokenizer(a)),b.each(c,function(a){var b,c,d,f;if(e&&0===e.length)return!1;for(b=j.trie,c=a.split("");b&&(d=c.shift());)b=b[h][d];return b&&0===c.length?(f=b[i].slice(0),void(e=e?g(e,f):f)):(e=[],!1)}),e?b.map(f(e),function(a){return j.datums[a]}):[]},all:function(){var a=[];for(var b in this.datums)a.push(this.datums[b]);return a},reset:function(){this.datums={},this.trie=e()},serialize:function(){return{datums:this.datums,trie:this.trie}}}),c}(),i=function(){"use strict";function a(a){this.url=a.url,this.ttl=a.ttl,this.cache=a.cache,this.prepare=a.prepare,this.transform=a.transform,this.transport=a.transport,this.thumbprint=a.thumbprint,this.storage=new f(a.cacheKey)}var c;return c={data:"data",protocol:"protocol",thumbprint:"thumbprint"},b.mixin(a.prototype,{_settings:function(){return{url:this.url,type:"GET",dataType:"json"}},store:function(a){this.cache&&(this.storage.set(c.data,a,this.ttl),this.storage.set(c.protocol,location.protocol,this.ttl),this.storage.set(c.thumbprint,this.thumbprint,this.ttl))},fromCache:function(){var a,b={};return this.cache?(b.data=this.storage.get(c.data),b.protocol=this.storage.get(c.protocol),b.thumbprint=this.storage.get(c.thumbprint),a=b.thumbprint!==this.thumbprint||b.protocol!==location.protocol,b.data&&!a?b.data:null):null},fromNetwork:function(a){function b(){a(!0)}function c(b){a(null,e.transform(b))}var d,e=this;a&&(d=this.prepare(this._settings()),this.transport(d).fail(b).done(c))},clear:function(){return this.storage.clear(),this}}),a}(),j=function(){"use strict";function a(a){this.url=a.url,this.prepare=a.prepare,this.transform=a.transform,this.transport=new g({cache:a.cache,limiter:a.limiter,transport:a.transport})}return b.mixin(a.prototype,{_settings:function(){return{url:this.url,type:"GET",dataType:"json"}},get:function(a,b){function c(a,c){b(a?[]:e.transform(c))}var d,e=this;if(b)return a=a||"",d=this.prepare(a,this._settings()),this.transport.get(d,c)},cancelLastRequest:function(){this.transport.cancel()}}),a}(),k=function(){"use strict";function d(d){var e;return d?(e={url:null,ttl:864e5,cache:!0,cacheKey:null,thumbprint:"",prepare:b.identity,transform:b.identity,transport:null},d=b.isString(d)?{url:d}:d,d=b.mixin(e,d),!d.url&&a.error("prefetch requires url to be set"),d.transform=d.filter||d.transform,d.cacheKey=d.cacheKey||d.url,d.thumbprint=c+d.thumbprint,d.transport=d.transport?h(d.transport):a.ajax,d):null}function e(c){var d;if(c)return d={url:null,cache:!0,prepare:null,replace:null,wildcard:null,limiter:null,rateLimitBy:"debounce",rateLimitWait:300,transform:b.identity,transport:null},c=b.isString(c)?{url:c}:c,c=b.mixin(d,c),!c.url&&a.error("remote requires url to be set"),c.transform=c.filter||c.transform,c.prepare=f(c),c.limiter=g(c),c.transport=c.transport?h(c.transport):a.ajax,delete c.replace,delete c.wildcard,delete c.rateLimitBy,delete c.rateLimitWait,c}function f(a){function b(a,b){return b.url=f(b.url,a),b}function c(a,b){return b.url=b.url.replace(g,encodeURIComponent(a)),b}function d(a,b){return b}var e,f,g;return e=a.prepare,f=a.replace,g=a.wildcard,e?e:e=f?b:a.wildcard?c:d}function g(a){function c(a){return function(c){return b.debounce(c,a)}}function d(a){return function(c){return b.throttle(c,a)}}var e,f,g;return e=a.limiter,f=a.rateLimitBy,g=a.rateLimitWait,e||(e=/^throttle$/i.test(f)?d(g):c(g)),e}function h(c){return function(d){function e(a){b.defer(function(){g.resolve(a)})}function f(a){b.defer(function(){g.reject(a)})}var g=a.Deferred();return c(d,e,f),g}}return function(c){var f,g;return f={initialize:!0,identify:b.stringify,datumTokenizer:null,queryTokenizer:null,sufficient:5,sorter:null,local:[],prefetch:null,remote:null},c=b.mixin(f,c||{}),!c.datumTokenizer&&a.error("datumTokenizer is required"),!c.queryTokenizer&&a.error("queryTokenizer is required"),g=c.sorter,c.sorter=g?function(a){return a.sort(g)}:b.identity,c.local=b.isFunction(c.local)?c.local():c.local,c.prefetch=d(c.prefetch),c.remote=e(c.remote),c}}(),l=function(){"use strict";function c(a){a=k(a),this.sorter=a.sorter,this.identify=a.identify,this.sufficient=a.sufficient,this.local=a.local,this.remote=a.remote?new j(a.remote):null,this.prefetch=a.prefetch?new i(a.prefetch):null,this.index=new h({identify:this.identify,datumTokenizer:a.datumTokenizer,queryTokenizer:a.queryTokenizer}),a.initialize!==!1&&this.initialize()}var e;return e=window&&window.Bloodhound,c.noConflict=function(){return window&&(window.Bloodhound=e),c},c.tokenizers=d,b.mixin(c.prototype,{__ttAdapter:function(){function a(a,b,d){return c.search(a,b,d)}function b(a,b){return c.search(a,b)}var c=this;return this.remote?a:b},_loadPrefetch:function(){function b(a,b){return a?c.reject():(e.add(b),e.prefetch.store(e.index.serialize()),void c.resolve())}var c,d,e=this;return c=a.Deferred(),this.prefetch?(d=this.prefetch.fromCache())?(this.index.bootstrap(d),c.resolve()):this.prefetch.fromNetwork(b):c.resolve(),c.promise()},_initialize:function(){function a(){b.add(b.local)}var b=this;return this.clear(),(this.initPromise=this._loadPrefetch()).done(a),this.initPromise},initialize:function(a){return!this.initPromise||a?this._initialize():this.initPromise},add:function(a){return this.index.add(a),this},get:function(a){return a=b.isArray(a)?a:[].slice.call(arguments),this.index.get(a)},search:function(a,c,d){function e(a){var c=[];b.each(a,function(a){!b.some(f,function(b){return g.identify(a)===g.identify(b)})&&c.push(a)}),d&&d(c)}var f,g=this;return f=this.sorter(this.index.search(a)),c(this.remote?f.slice():f),this.remote&&f.length=j?(clearTimeout(e),e=null,g=i,f=a.apply(c,d)):e||(e=setTimeout(h,j)),f}},stringify:function(a){return b.isString(a)?a:JSON.stringify(a)},noop:function(){}}}(),c=function(){"use strict";function a(a){var g,h;return h=b.mixin({},f,a),g={css:e(),classes:h,html:c(h),selectors:d(h)},{css:g.css,html:g.html,classes:g.classes,selectors:g.selectors,mixin:function(a){b.mixin(a,g)}}}function c(a){return{wrapper:'',menu:'
'}}function d(a){var c={};return b.each(a,function(a,b){c[b]="."+a}),c}function e(){var a={wrapper:{position:"relative",display:"inline-block"},hint:{position:"absolute",top:"0",left:"0",borderColor:"transparent",boxShadow:"none",opacity:"1"},input:{position:"relative",verticalAlign:"top",backgroundColor:"transparent"},inputWithNoHint:{position:"relative",verticalAlign:"top"},menu:{position:"absolute",top:"100%",left:"0",zIndex:"100",display:"none"},ltr:{left:"0",right:"auto"},rtl:{left:"auto",right:" 0"}};return b.isMsie()&&b.mixin(a.input,{backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)"}),a}var f={wrapper:"twitter-typeahead",input:"tt-input",hint:"tt-hint",menu:"tt-menu",dataset:"tt-dataset",suggestion:"tt-suggestion",selectable:"tt-selectable",empty:"tt-empty",open:"tt-open",cursor:"tt-cursor",highlight:"tt-highlight"};return a}(),d=function(){"use strict";function c(b){b&&b.el||a.error("EventBus initialized without el"),this.$el=a(b.el)}var d,e;return d="typeahead:",e={render:"rendered",cursorchange:"cursorchanged",select:"selected",autocomplete:"autocompleted"},b.mixin(c.prototype,{_trigger:function(b,c){var e;return e=a.Event(d+b),(c=c||[]).unshift(e),this.$el.trigger.apply(this.$el,c),e},before:function(a){var b,c;return b=[].slice.call(arguments,1),c=this._trigger("before"+a,b),c.isDefaultPrevented()},trigger:function(a){var b;this._trigger(a,[].slice.call(arguments,1)),(b=e[a])&&this._trigger(b,[].slice.call(arguments,1))}}),c}(),e=function(){"use strict";function a(a,b,c,d){var e;if(!c)return this;for(b=b.split(i),c=d?h(c,d):c,this._callbacks=this._callbacks||{};e=b.shift();)this._callbacks[e]=this._callbacks[e]||{sync:[],async:[]},this._callbacks[e][a].push(c);return this}function b(b,c,d){return a.call(this,"async",b,c,d)}function c(b,c,d){return a.call(this,"sync",b,c,d)}function d(a){var b;if(!this._callbacks)return this;for(a=a.split(i);b=a.shift();)delete this._callbacks[b];return this}function e(a){var b,c,d,e,g;if(!this._callbacks)return this;for(a=a.split(i),d=[].slice.call(arguments,1);(b=a.shift())&&(c=this._callbacks[b]);)e=f(c.sync,this,[b].concat(d)),g=f(c.async,this,[b].concat(d)),e()&&j(g);return this}function f(a,b,c){function d(){for(var d,e=0,f=a.length;!d&&f>e;e+=1)d=a[e].apply(b,c)===!1;return!d}return d}function g(){var a;return a=window.setImmediate?function(a){setImmediate(function(){a()})}:function(a){setTimeout(function(){a()},0)}}function h(a,b){return a.bind?a.bind(b):function(){a.apply(b,[].slice.call(arguments,0))}}var i=/\s+/,j=g();return{onSync:c,onAsync:b,off:d,trigger:e}}(),f=function(a){"use strict";function c(a,c,d){for(var e,f=[],g=0,h=a.length;h>g;g++)f.push(b.escapeRegExChars(a[g]));return e=d?"\\b("+f.join("|")+")\\b":"("+f.join("|")+")",c?new RegExp(e):new RegExp(e,"i")}var d={node:null,pattern:null,tagName:"strong",className:null,wordsOnly:!1,caseSensitive:!1};return function(e){function f(b){var c,d,f;return(c=h.exec(b.data))&&(f=a.createElement(e.tagName),e.className&&(f.className=e.className),d=b.splitText(c.index),d.splitText(c[0].length),f.appendChild(d.cloneNode(!0)),b.parentNode.replaceChild(f,d)),!!c}function g(a,b){for(var c,d=3,e=0;e
8
- e=document.activeElement,f=d.is(e),g=d.has(e).length>0,b.isMsie()&&(f||g)&&(a.preventDefault(),a.stopImmediatePropagation(),b.defer(function(){c.focus()}))}),d.on("mousedown.tt",function(a){a.preventDefault()})},_onSelectableClicked:function(a,b){this.select(b)},_onDatasetCleared:function(){this._updateHint()},_onDatasetRendered:function(a,b,c,d){this._updateHint(),this.eventBus.trigger("render",c,d,b)},_onAsyncRequested:function(a,b,c){this.eventBus.trigger("asyncrequest",c,b)},_onAsyncCanceled:function(a,b,c){this.eventBus.trigger("asynccancel",c,b)},_onAsyncReceived:function(a,b,c){this.eventBus.trigger("asyncreceive",c,b)},_onFocused:function(){this._minLengthMet()&&this.menu.update(this.input.getQuery())},_onBlurred:function(){this.input.hasQueryChangedSinceLastFocus()&&this.eventBus.trigger("change",this.input.getQuery())},_onEnterKeyed:function(a,b){var c;(c=this.menu.getActiveSelectable())&&this.select(c)&&b.preventDefault()},_onTabKeyed:function(a,b){var c;(c=this.menu.getActiveSelectable())?this.select(c)&&b.preventDefault():(c=this.menu.getTopSelectable())&&this.autocomplete(c)&&b.preventDefault()},_onEscKeyed:function(){this.close()},_onUpKeyed:function(){this.moveCursor(-1)},_onDownKeyed:function(){this.moveCursor(1)},_onLeftKeyed:function(){"rtl"===this.dir&&this.input.isCursorAtEnd()&&this.autocomplete(this.menu.getTopSelectable())},_onRightKeyed:function(){"ltr"===this.dir&&this.input.isCursorAtEnd()&&this.autocomplete(this.menu.getTopSelectable())},_onQueryChanged:function(a,b){this._minLengthMet(b)?this.menu.update(b):this.menu.empty()},_onWhitespaceChanged:function(){this._updateHint()},_onLangDirChanged:function(a,b){this.dir!==b&&(this.dir=b,this.menu.setLanguageDirection(b))},_openIfActive:function(){this.isActive()&&this.open()},_minLengthMet:function(a){return a=b.isString(a)?a:this.input.getQuery()||"",a.length>=this.minLength},_updateHint:function(){var a,c,d,e,f,h,i;a=this.menu.getTopSelectable(),c=this.menu.getSelectableData(a),d=this.input.getInputValue(),!c||b.isBlankString(d)||this.input.hasOverflow()?this.input.clearHint():(e=g.normalizeQuery(d),f=b.escapeRegExChars(e),h=new RegExp("^(?:"+f+")(.+$)","i"),i=h.exec(c.val),i&&this.input.setHint(d+i[1]))},isEnabled:function(){return this.enabled},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},isActive:function(){return this.active},activate:function(){return this.isActive()?!0:!this.isEnabled()||this.eventBus.before("active")?!1:(this.active=!0,this.eventBus.trigger("active"),!0)},deactivate:function(){return this.isActive()?this.eventBus.before("idle")?!1:(this.active=!1,this.close(),this.eventBus.trigger("idle"),!0):!0},isOpen:function(){return this.menu.isOpen()},open:function(){return this.isOpen()||this.eventBus.before("open")||(this.menu.open(),this._updateHint(),this.eventBus.trigger("open")),this.isOpen()},close:function(){return this.isOpen()&&!this.eventBus.before("close")&&(this.menu.close(),this.input.clearHint(),this.input.resetInputValue(),this.eventBus.trigger("close")),!this.isOpen()},setVal:function(a){this.input.setQuery(b.toStr(a))},getVal:function(){return this.input.getQuery()},select:function(a){var b=this.menu.getSelectableData(a);return b&&!this.eventBus.before("select",b.obj)?(this.input.setQuery(b.val,!0),this.eventBus.trigger("select",b.obj),this.close(),!0):!1},autocomplete:function(a){var b,c,d;return b=this.input.getQuery(),c=this.menu.getSelectableData(a),d=c&&b!==c.val,d&&!this.eventBus.before("autocomplete",c.obj)?(this.input.setQuery(c.val),this.eventBus.trigger("autocomplete",c.obj),!0):!1},moveCursor:function(a){var b,c,d,e,f;return b=this.input.getQuery(),c=this.menu.selectableRelativeToCursor(a),d=this.menu.getSelectableData(c),e=d?d.obj:null,f=this._minLengthMet()&&this.menu.update(b),f||this.eventBus.before("cursorchange",e)?!1:(this.menu.setCursor(c),d?this.input.setInputValue(d.val):(this.input.resetInputValue(),this._updateHint()),this.eventBus.trigger("cursorchange",e),!0)},destroy:function(){this.input.destroy(),this.menu.destroy()}}),c}();!function(){"use strict";function e(b,c){b.each(function(){var b,d=a(this);(b=d.data(p.typeahead))&&c(b,d)})}function f(a,b){return a.clone().addClass(b.classes.hint).removeData().css(b.css.hint).css(l(a)).prop("readonly",!0).removeAttr("id name placeholder required").attr({autocomplete:"off",spellcheck:"false",tabindex:-1})}function h(a,b){a.data(p.attrs,{dir:a.attr("dir"),autocomplete:a.attr("autocomplete"),spellcheck:a.attr("spellcheck"),style:a.attr("style")}),a.addClass(b.classes.input).attr({autocomplete:"off",spellcheck:!1});try{!a.attr("dir")&&a.attr("dir","auto")}catch(c){}return a}function l(a){return{backgroundAttachment:a.css("background-attachment"),backgroundClip:a.css("background-clip"),backgroundColor:a.css("background-color"),backgroundImage:a.css("background-image"),backgroundOrigin:a.css("background-origin"),backgroundPosition:a.css("background-position"),backgroundRepeat:a.css("background-repeat"),backgroundSize:a.css("background-size")}}function m(a){var c,d;c=a.data(p.www),d=a.parent().filter(c.selectors.wrapper),b.each(a.data(p.attrs),function(c,d){b.isUndefined(c)?a.removeAttr(d):a.attr(d,c)}),a.removeData(p.typeahead).removeData(p.www).removeData(p.attr).removeClass(c.classes.input),d.length&&(a.detach().insertAfter(d),d.remove())}function n(c){var d,e;return d=b.isJQuery(c)||b.isElement(c),e=d?a(c).first():[],e.length?e:null}var o,p,q;o=a.fn.typeahead,p={www:"tt-www",attrs:"tt-attrs",typeahead:"tt-typeahead"},q={initialize:function(e,l){function m(){var c,m,q,r,s,t,u,v,w,x,y;b.each(l,function(a){a.highlight=!!e.highlight}),c=a(this),m=a(o.html.wrapper),q=n(e.hint),r=n(e.menu),s=e.hint!==!1&&!q,t=e.menu!==!1&&!r,s&&(q=f(c,o)),t&&(r=a(o.html.menu).css(o.css.menu)),q&&q.val(""),c=h(c,o),(s||t)&&(m.css(o.css.wrapper),c.css(s?o.css.input:o.css.inputWithNoHint),c.wrap(m).parent().prepend(s?q:null).append(t?r:null)),y=t?j:i,u=new d({el:c}),v=new g({hint:q,input:c},o),w=new y({node:r,datasets:l},o),x=new k({input:v,menu:w,eventBus:u,minLength:e.minLength},o),c.data(p.www,o),c.data(p.typeahead,x)}var o;return l=b.isArray(l)?l:[].slice.call(arguments,1),e=e||{},o=c(e.classNames),this.each(m)},isEnabled:function(){var a;return e(this.first(),function(b){a=b.isEnabled()}),a},enable:function(){return e(this,function(a){a.enable()}),this},disable:function(){return e(this,function(a){a.disable()}),this},isActive:function(){var a;return e(this.first(),function(b){a=b.isActive()}),a},activate:function(){return e(this,function(a){a.activate()}),this},deactivate:function(){return e(this,function(a){a.deactivate()}),this},isOpen:function(){var a;return e(this.first(),function(b){a=b.isOpen()}),a},open:function(){return e(this,function(a){a.open()}),this},close:function(){return e(this,function(a){a.close()}),this},select:function(b){var c=!1,d=a(b);return e(this.first(),function(a){c=a.select(d)}),c},autocomplete:function(b){var c=!1,d=a(b);return e(this.first(),function(a){c=a.autocomplete(d)}),c},moveCursor:function(a){var b=!1;return e(this.first(),function(c){b=c.moveCursor(a)}),b},val:function(a){var b;return arguments.length?(e(this,function(b){b.setVal(a)}),this):(e(this.first(),function(a){b=a.getVal()}),b)},destroy:function(){return e(this,function(a,b){m(b),a.destroy()}),this}},a.fn.typeahead=function(a){return q[a]?q[a].apply(this,[].slice.call(arguments,1)):q.initialize.apply(this,arguments)},a.fn.typeahead.noConflict=function(){return a.fn.typeahead=o,this}}()});
7
+ !function(e,n){"function"==typeof define&&define.amd?define("bloodhound",["jquery"],function(t){return e.Bloodhound=n(t)}):"object"==typeof exports?module.exports=n(require("jquery")):e.Bloodhound=n(jQuery)}(this,function(h){var l=function(){"use strict";return{isMsie:function(){return!!/(msie|trident)/i.test(navigator.userAgent)&&navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2]},isBlankString:function(t){return!t||/^\s*$/.test(t)},escapeRegExChars:function(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isArray:h.isArray,isFunction:h.isFunction,isObject:h.isPlainObject,isUndefined:function(t){return void 0===t},isElement:function(t){return!(!t||1!==t.nodeType)},isJQuery:function(t){return t instanceof h},toStr:function(t){return l.isUndefined(t)||null===t?"":t+""},bind:h.proxy,each:function(t,n){h.each(t,function(t,e){return n(e,t)})},map:h.map,filter:h.grep,every:function(n,i){var r=!0;return n?(h.each(n,function(t,e){if(!(r=i.call(null,e,t,n)))return!1}),!!r):r},some:function(n,i){var r=!1;return n?(h.each(n,function(t,e){if(r=i.call(null,e,t,n))return!1}),!!r):r},mixin:h.extend,identity:function(t){return t},clone:function(t){return h.extend(!0,{},t)},getIdGenerator:function(){var t=0;return function(){return t++}},templatify:function(t){return h.isFunction(t)?t:function(){return String(t)}},defer:function(t){setTimeout(t,0)},debounce:function(r,s,o){var u,a;return function(){function t(){u=null,o||(a=r.apply(e,n))}var e=this,n=arguments,i=o&&!u;return clearTimeout(u),u=setTimeout(t,s),i&&(a=r.apply(e,n)),a}},throttle:function(n,i){function r(){c=new Date,u=null,a=n.apply(s,o)}var s,o,u,a,c=0;return function(){var t=new Date,e=i-(t-c);return s=this,o=arguments,e<=0?(clearTimeout(u),u=null,c=t,a=n.apply(s,o)):u=u||setTimeout(r,e),a}},stringify:function(t){return l.isString(t)?t:JSON.stringify(t)},noop:function(){}}}(),n=function(){"use strict";return{nonword:e,whitespace:t,obj:{nonword:n(e),whitespace:n(t)}};function t(t){return(t=l.toStr(t))?t.split(/\s+/):[]}function e(t){return(t=l.toStr(t))?t.split(/\W+/):[]}function n(i){return function(t){return t=l.isArray(t)?t:[].slice.call(arguments,0),function(e){var n=[];return l.each(t,function(t){n=n.concat(i(l.toStr(e[t])))}),n}}}}(),i=function(){"use strict";function t(t){this.maxSize=l.isNumber(t)?t:100,this.reset(),this.maxSize<=0&&(this.set=this.get=h.noop)}function e(){this.head=this.tail=null}function r(t,e){this.key=t,this.val=e,this.prev=this.next=null}return l.mixin(t.prototype,{set:function(t,e){var n,i=this.list.tail;this.size>=this.maxSize&&(this.list.remove(i),delete this.hash[i.key],this.size--),(n=this.hash[t])?(n.val=e,this.list.moveToFront(n)):(n=new r(t,e),this.list.add(n),this.hash[t]=n,this.size++)},get:function(t){var e=this.hash[t];if(e)return this.list.moveToFront(e),e.val},reset:function(){this.size=0,this.hash={},this.list=new e}}),l.mixin(e.prototype,{add:function(t){this.head&&(t.next=this.head,this.head.prev=t),this.head=t,this.tail=this.tail||t},remove:function(t){t.prev?t.prev.next=t.next:this.head=t.next,t.next?t.next.prev=t.prev:this.tail=t.prev},moveToFront:function(t){this.remove(t),this.add(t)}}),t}(),e=function(){"use strict";var s;try{(s=window.localStorage).setItem("~~~","!"),s.removeItem("~~~")}catch(t){s=null}function t(t,e){this.prefix=["__",t,"__"].join(""),this.ttlKey="__ttl__",this.keyMatcher=new RegExp("^"+l.escapeRegExChars(this.prefix)),this.ls=e||s,this.ls||this._noop()}return l.mixin(t.prototype,{_prefix:function(t){return this.prefix+t},_ttlKey:function(t){return this._prefix(t)+this.ttlKey},_noop:function(){this.get=this.set=this.remove=this.clear=this.isExpired=l.noop},_safeSet:function(t,e){try{this.ls.setItem(t,e)}catch(t){"QuotaExceededError"===t.name&&(this.clear(),this._noop())}},get:function(t){return this.isExpired(t)&&this.remove(t),n(this.ls.getItem(this._prefix(t)))},set:function(t,e,n){return l.isNumber(n)?this._safeSet(this._ttlKey(t),r(i()+n)):this.ls.removeItem(this._ttlKey(t)),this._safeSet(this._prefix(t),r(e))},remove:function(t){return this.ls.removeItem(this._ttlKey(t)),this.ls.removeItem(this._prefix(t)),this},clear:function(){for(var t=function(t){var e,n,i=[],r=s.length;for(e=0;ee)}}),t;function i(){return(new Date).getTime()}function r(t){return JSON.stringify(l.isUndefined(t)?null:t)}function n(t){return h.parseJSON(t)}}(),r=function(){"use strict";var u=0,a={},c=6,e=new i(10);function t(t){t=t||{},this.cancelled=!1,this.lastReq=null,this._send=t.transport,this._get=t.limiter?t.limiter(this._get):this._get,this._cache=!1===t.cache?new i(0):e}return t.setMaxPendingRequests=function(t){c=t},t.resetCache=function(){e.reset()},l.mixin(t.prototype,{_fingerprint:function(t){return(t=t||{}).url+t.type+h.param(t.data||{})},_get:function(t,e){var n,i,r=this;function s(t){e(null,t),r._cache.set(n,t)}function o(){e(!0)}n=this._fingerprint(t),this.cancelled||n!==this.lastReq||((i=a[n])?i.done(s).fail(o):ue[i]||(r.push(t[n]),n++),i++);return r}(s,r):r}),s?l.map(function(t){for(var e={},n=[],i=0,r=t.length;i',menu:'
'}}(n),selectors:function(t){var n={};return y.each(t,function(t,e){n[e]="."+t}),n}(n)}).css,html:e.html,classes:e.classes,selectors:e.selectors,mixin:function(t){y.mixin(t,e)}}}}(),v=function(){"use strict";var n;function t(t){t&&t.el||m.error("EventBus initialized without el"),this.$el=m(t.el)}return n={render:"rendered",cursorchange:"cursorchanged",select:"selected",autocomplete:"autocompleted"},y.mixin(t.prototype,{_trigger:function(t,e){var n=m.Event("typeahead:"+t);return(e=e||[]).unshift(n),this.$el.trigger.apply(this.$el,e),n},before:function(t){var e=[].slice.call(arguments,1);return this._trigger("before"+t,e).isDefaultPrevented()},trigger:function(t){var e;this._trigger(t,[].slice.call(arguments,1)),(e=n[t])&&this._trigger(e,[].slice.call(arguments,1))}}),t}(),e=function(){"use strict";var u=/\s+/,o=function(){var t;t=window.setImmediate?function(t){setImmediate(function(){t()})}:function(t){setTimeout(function(){t()},0)};return t}();return{onSync:function(t,e,n){return i.call(this,"sync",t,e,n)},onAsync:function(t,e,n){return i.call(this,"async",t,e,n)},off:function(t){var e;if(!this._callbacks)return this;t=t.split(u);for(;e=t.shift();)delete this._callbacks[e];return this},trigger:function(t){var e,n,i,r,s;if(!this._callbacks)return this;t=t.split(u),i=[].slice.call(arguments,1);for(;(e=t.shift())&&(n=this._callbacks[e]);)r=a(n.sync,this,[e].concat(i)),s=a(n.async,this,[e].concat(i)),r()&&o(s);return this}};function i(t,e,n,i){var r,s,o;if(!n)return this;for(e=e.split(u),n=i?(o=i,(s=n).bind?s.bind(o):function(){s.apply(o,[].slice.call(arguments,0))}):n,this._callbacks=this._callbacks||{};r=e.shift();)this._callbacks[r]=this._callbacks[r]||{sync:[],async:[]},this._callbacks[r][t].push(n);return this}function a(i,r,s){return function(){for(var t,e=0,n=i.length;!t&&e
@@ -9,6 +9,8 @@
9
9
  == multiple_select_input({ :name => "user_id", :elements => notifications.collect { |notification| { :value => notification.creator.id, :text => notification.creator.full_name } }.uniq, :placeholder => "Empleados", :selected_elements => filters[:user_id] })
10
10
  .col-md-12
11
11
  == multiple_select_input({ :name => "label", :elements => Notification.labels.collect { |notification| { :value => notification.label, :text => notification.label.upcase } }, :placeholder => "Etiquetas", :selected_elements => filters[:label] })
12
+ .col-md-12
13
+ == multiple_select_input({ :name => "status", :elements => Notification.labels.collect { |notification| { :value => notification.label, :text => notification.label.upcase } }, :placeholder => "Etiquetas", :selected_elements => filters[:label] })
12
14
  .pm-body.clearfix
13
15
  ul.tab-nav.tn-justified role="tablist"
14
16
  li.waves-effect.active role="presentation"
metadata CHANGED
@@ -1,15 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-hexacta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Zanger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-12 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2020-06-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sucker_punch
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tzinfo-data
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2019'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2019'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rufus-scheduler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.6.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.6.0
13
55
  description: A gem to support general functionality accross all apps
14
56
  email: mzanger@hexacta.com
15
57
  executables: []
@@ -18,7 +60,11 @@ extra_rdoc_files: []
18
60
  files:
19
61
  - lib/sinatra/extensions/antiquity.rb
20
62
  - lib/sinatra/extensions/date.rb
63
+ - lib/sinatra/extensions/generalmail.rb
21
64
  - lib/sinatra/extensions/init.rb
65
+ - lib/sinatra/extensions/mail.rb
66
+ - lib/sinatra/extensions/mailbuilder.rb
67
+ - lib/sinatra/extensions/mailsender.rb
22
68
  - lib/sinatra/extensions/notification.rb
23
69
  - lib/sinatra/handlers/errors.rb
24
70
  - lib/sinatra/handlers/init.rb
@@ -31,7 +77,6 @@ files:
31
77
  - lib/sinatra/helpers/init.rb
32
78
  - lib/sinatra/helpers/inputs.rb
33
79
  - lib/sinatra/helpers/libraries.rb
34
- - lib/sinatra/helpers/mailer.rb
35
80
  - lib/sinatra/helpers/reports.rb
36
81
  - lib/sinatra/helpers/schedule.rb
37
82
  - lib/sinatra/helpers/subscriptions.rb
@@ -1,74 +0,0 @@
1
- # encoding: utf-8
2
- require 'sucker_punch'
3
-
4
- module Sinatra
5
- module MailHelper
6
-
7
- attr_reader :access_token, :expire, :refresh_token
8
-
9
- def _do_connect(uri, form={},token=nil)
10
- url = URI.parse("#{uri}")
11
- http = Net::HTTP.new(url.host, url.port)
12
- http.read_timeout = 1000
13
- http.use_ssl = (url.scheme == 'https')
14
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
15
- header = { 'Content-Type' => 'application/x-www-form-urlencoded' }
16
- header["Authorization"] = "Bearer #{token}" unless token.nil?
17
- request = Net::HTTP::Post.new(url, header)
18
- request.form_data = form
19
- http.start {|http| http.request(request) }
20
- end
21
-
22
- def _authorize_mail
23
- params = [ [ "grant_type", "password" ], [ "client_id", "MailApp" ], [ "client_secret", "MailAppPRD2018!" ] ]
24
- response = _do_connect("https://comunicacion.hexacta.com:4443/apptoken",params)
25
- if( response.is_a?( Net::HTTPSuccess ) )
26
- token = JSON.parse(response.body)
27
- @access_token = token["access_token"]
28
- @refresh_token = token["refresh_token"]
29
- @expire = DateTime.parse(token[".expires"])
30
- else
31
- p "Didn't succeed :("
32
- end
33
- end
34
-
35
- def _build_map_values(mail_values)
36
- values = []
37
- for key in mail_values.keys
38
- index = mail_values.keys.index(key)
39
- values << ["MailValues[#{index}].Key", key]
40
- values << ["MailValues[#{index}].Value", mail_values[key]]
41
- end
42
- values
43
- end
44
-
45
- def _build_to_map(to_map)
46
- values = []
47
- for key in to_map.keys
48
- index = to_map.keys.index(key)
49
- values << ["ResourcesRequest[#{index}].TypeGroup", to_map[key]]
50
- values << ["ResourcesRequest[#{index}].Name", key]
51
- end
52
- values
53
- end
54
-
55
- def _expired?
56
- expire.nil? || DateTime.now < expire
57
- end
58
-
59
- def send_mail(template,subject,mail_values={},to_map)
60
- if _expired?
61
- _authorize_mail
62
- end
63
- params = [ [ "ApplicationCode", 1 ], [ "Name", template ], [ "Subject", subject ], [ "EmailAddress", "apps@hexacta.com" ] ]
64
- params = params + _build_map_values(mail_values) + _build_to_map(to_map)
65
- response = do_connect("https://comunicacion.hexacta.com:4444/api/app/TemplateNotification/SendMail",params,@access_token)
66
- if( !response.is_a?( Net::HTTPSuccess ) )
67
- p "Didn't succeed :("
68
- end
69
- end
70
-
71
- end
72
-
73
- helpers MailHelper
74
- end