Added remaining constants.

This commit is contained in:
Matej Zrimšek 2016-09-29 14:12:52 +02:00
parent 21ec05d541
commit a3dfb59558
40 changed files with 271 additions and 161 deletions

View file

@ -194,9 +194,9 @@ function notificationAlertClose(){
$(document).ready(function(){
$('.tree-link a').each( function(){
truncateLongString( $(this), 30);
truncateLongString( $(this), NAME_TRUNCATION_LENGTH);
});
$(".tree-link span").each( function(){
truncateLongString( $(this), 30);
truncateLongString( $(this), NAME_TRUNCATION_LENGTH);
});
});

View file

@ -182,7 +182,7 @@ var Comments = (function() {
var parentTopPos = $el.offset().top;
if (leftPos + menu.width() > $(window).width()) {
menu.offset({ left: leftPos - menu.width(),
top: (parentTopPos + <%= DROPDOWN_TOP_OFFSET %>)});
top: (parentTopPos + <%= DROPDOWN_TOP_OFFSET_PX %>)});
}
});
}
@ -208,7 +208,7 @@ var Comments = (function() {
var $el = $(el);
var offset = useParentOffset ? $el.offset().top : $el.position().top;
$el.find('.dropdown-menu-fixed')
.offset({ top: (offset + <%= DROPDOWN_TOP_OFFSET %>) });
.offset({ top: (offset + <%= DROPDOWN_TOP_OFFSET_PX %>) });
});
}

View file

@ -88,11 +88,11 @@ function initEditKeywords() {
// Init tagsinput & typeahead
input.tagsinput({
maxChars: 50,
maxChars: NAME_MAX_LENGTH,
trimValue: true,
typeaheadjs: {
highlight: true,
minLength: 3,
minLength: NAME_MIN_LENGTH,
name: "keywords",
source: keywordsEngine
}

View file

@ -1124,7 +1124,7 @@ function initializeReportSidebartruncation() {
function() {
$.each($("a.report-nav-link"),
function(){
truncateLongString($(this), 30);
truncateLongString($(this), NAME_TRUNCATION_LENGTH);
});
}
);
@ -1214,8 +1214,8 @@ $(document).ready(function() {
initializeUnsavedWorkDialog();
initializeTutorial();
$(".report-nav-link").each( function(){
truncateLongString( $(this), 30);
$('.report-nav-link').each(function() {
truncateLongString($(this), NAME_TRUNCATION_LENGTH);
});
}
})
@ -1223,7 +1223,7 @@ $(document).ready(function() {
$(document).change(function(){
setTimeout(function(){
$(".report-nav-link").each( function(){
truncateLongString( $(this), 30);
truncateLongString( $(this), NAME_TRUNCATION_LENGTH);
});
}, 1000);
});

View file

@ -0,0 +1,47 @@
// All the constants from server-side available on client-side.
var APP_VERSION = "<%= APP_VERSION %>";
var TAG_COLORS = <%= TAG_COLORS %>;
var TEXT_EXTRACT_FILE_TYPES = <%= TEXT_EXTRACT_FILE_TYPES %>;
var DEFAULT_PRIVATE_ORG_NAME = "<%= DEFAULT_PRIVATE_ORG_NAME %>";
var NAME_MIN_LENGTH = <%= NAME_MIN_LENGTH %>;
var NAME_MAX_LENGTH = <%= NAME_MAX_LENGTH %>;
var NAME_TRUNCATION_LENGTH = <%= NAME_TRUNCATION_LENGTH %>;
var TEXT_MAX_LENGTH = <%= TEXT_MAX_LENGTH %>;
var COLOR_MAX_LENGTH = <%= TEXT_MAX_LENGTH %>;
var DROPDOWN_TEXT_MAX_LENGTH = <%= DROPDOWN_TEXT_MAX_LENGTH %>;
var FILENAME_TRUNCATION_LENGTH = <%= FILENAME_TRUNCATION_LENGTH %>;
var USER_INITIALS_MAX_LENGTH = <%= USER_INITIALS_MAX_LENGTH %>;
var EMAIL_MAX_LENGTH = <%= EMAIL_MAX_LENGTH %>;
var SEARCH_LIMIT = <%= SEARCH_LIMIT %>;
var SEARCH_NO_LIMIT = <%= SEARCH_NO_LIMIT %>;
var MODAL_SEARCH_LIMIT = <%= MODAL_SEARCH_LIMIT %>;
var COMMENTS_SEARCH_LIMIT = <%= COMMENTS_SEARCH_LIMIT %>;
var ACTIVITY_SEARCH_LIMIT = <%= ACTIVITY_SEARCH_LIMIT %>;
var TABLE_JSON_MAX_SIZE = <%= TABLE_JSON_MAX_SIZE %>;
var FILE_MAX_SIZE = <%= FILE_MAX_SIZE %>;
var AVATAR_MAX_SIZE = <%= AVATAR_MAX_SIZE %>;
var MEDIUM_PIC_FORMAT = "<%= MEDIUM_PIC_FORMAT %>";
var THUMB_PIC_FORMAT = "<%= THUMB_PIC_FORMAT %>";
var ICON_PIC_FORMAT = "<%= ICON_PIC_FORMAT %>";
var ICON_SMALL_PIC_FORMAT = "<%= ICON_SMALL_PIC_FORMAT %>";
var URL_SHORT_EXPIRE_TIME = <%= URL_SHORT_EXPIRE_TIME %>;
var URL_LONG_EXPIRE_TIME = <%= URL_LONG_EXPIRE_TIME %>;
var MINIMAL_ORGANIZATION_SPACE_TAKEN =
<%= MINIMAL_ORGANIZATION_SPACE_TAKEN %>;
var ASSET_ESTIMATED_SIZE_FACTOR = <%= ASSET_ESTIMATED_SIZE_FACTOR %>;
var TUTORIALS_URL = "<%= TUTORIALS_URL %>";
var FAQ_URL = "<%= FAQ_URL %>";
var SUPPORT_URL = "<%= SUPPORT_URL %>";
var PLANS_URL = "<%= PLANS_URL %>";
var CONTACT_URL = "<%= CONTACT_URL %>";
var DEFAULT_AVATAR_URL = "<%= DEFAULT_AVATAR_URL %>";
var KICKSTARTER_SUPPORTERS = <%= KICKSTARTER_SUPPORTERS %>;

View file

@ -21,9 +21,9 @@ $.fn.onSubmitValidator = function(validatorCb) {
var TextLimitEnum = Object.freeze({
OPTIONAL: 0,
REQUIRED: 1,
NAME_MIN_LENGTH: '<%= NAME_MIN_LENGTH %>',
NAME_MAX_LENGTH: '<%= NAME_MAX_LENGTH %>',
TEXT_MAX_LENGTH: '<%= TEXT_MAX_LENGTH %>'
NAME_MIN_LENGTH: "<%= NAME_MIN_LENGTH %>",
NAME_MAX_LENGTH: "<%= NAME_MAX_LENGTH %>",
TEXT_MAX_LENGTH: "<%= TEXT_MAX_LENGTH %>"
});
/*
@ -102,8 +102,8 @@ function checklistsValidator(ev, checklists, editMode) {
}
var FileTypeSizeEnum = Object.freeze({
FILE: '<%= FILE_MAX_SIZE.megabytes %>',
AVATAR: '<%= AVATAR_MAX_SIZE.megabytes %>'
FILE: "<%= FILE_MAX_SIZE.megabytes %>",
AVATAR: "<%= AVATAR_MAX_SIZE.megabytes %>"
});
function filesValidator(ev, fileInputs, fileTypeEnum, canBeEmpty) {

View file

@ -9,7 +9,7 @@ function truncateLongString( el, chars ) {
html = el.children()[0];
}
if( input.length >= chars){
if( input.length >= chars ){
var newText = el.text().slice(0, chars);
for( var i = newText.length; i > 0; i--){
if(newText[i] === ' ' && i > 10){

View file

@ -162,7 +162,7 @@ class MyModuleCommentsController < ApplicationController
def load_vars
@last_comment_id = params[:from].to_i
@per_page = 10
@per_page = COMMENTS_SEARCH_LIMIT
@my_module = MyModule.find_by_id(params[:my_module_id])
unless @my_module

View file

@ -158,7 +158,7 @@ class ProjectCommentsController < ApplicationController
def load_vars
@last_comment_id = params[:from].to_i
@per_page = 10
@per_page = COMMENTS_SEARCH_LIMIT
@project = Project.find_by_id(params[:project_id])
unless @project

View file

@ -159,7 +159,7 @@ class ResultCommentsController < ApplicationController
def load_vars
@last_comment_id = params[:from].to_i
@per_page = 10
@per_page = COMMENTS_SEARCH_LIMIT
@result = Result.find_by_id(params[:result_id])
@my_module = @result.my_module

View file

@ -168,7 +168,7 @@ class StepCommentsController < ApplicationController
def load_vars
@last_comment_id = params[:from].to_i
@per_page = 10
@per_page = COMMENTS_SEARCH_LIMIT
@step = Step.find_by_id(params[:step_id])
@protocol = @step.protocol

View file

@ -140,7 +140,7 @@ class Users::SettingsController < ApplicationController
nr_of_results = User.search(true, query, @org).count
users = User.search(false, query, @org).limit(EXISTING_USERS_SEARCH_LIMIT)
users = User.search(false, query, @org).limit(MODAL_SEARCH_LIMIT)
nr_of_members = User.organization_search(false, query, @org).count

View file

@ -1,7 +1,7 @@
module ActivityHelper
def activity_truncate(message, len = 20)
def activity_truncate(message, len = NAME_TRUNCATION_LENGTH)
activity_title = message.match(/<strong>(.*?)<\/strong>/)[1]
if activity_title.length > 20
if activity_title.length > NAME_TRUNCATION_LENGTH
title = "<div class='modal-tooltip'>#{truncate(activity_title, length: len)}
<span class='modal-tooltiptext'>#{activity_title}</span></div>"
else

View file

@ -81,7 +81,7 @@ end
def report_image_asset_url(asset)
prefix = (ENV["PAPERCLIP_STORAGE"].present? && ENV["MAIL_SERVER_URL"].present? && ENV["PAPERCLIP_STORAGE"] == "filesystem") ? ENV["MAIL_SERVER_URL"] : ""
prefix = (!prefix.empty? && !prefix.include?("http://") && !prefix.include?("https://")) ? "http://#{prefix}" : prefix
url = prefix + asset.url(:medium, timeout: 86_400)
url = prefix + asset.url(:medium, timeout: URL_LONG_EXPIRE_TIME)
image_tag(url)
end

View file

@ -6,11 +6,7 @@ class Asset < ActiveRecord::Base
require 'tempfile'
# Paperclip validation
has_attached_file :file, {
styles: {
medium: '300x300>'
}
}
has_attached_file :file, styles: { medium: MEDIUM_PIC_FORMAT }
validates_attachment :file,
presence: true,
@ -75,14 +71,14 @@ class Asset < ActiveRecord::Base
)
step_ids =
Step
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.joins(:step_assets)
.select("step_assets.id")
.distinct
result_ids =
Result
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.joins(:result_asset)
.select("result_assets.id")
.distinct
@ -125,7 +121,7 @@ class Asset < ActiveRecord::Base
)
# Show all results if needed
if page != SHOW_ALL_RESULTS
if page != SEARCH_NO_LIMIT
ids = ids
.limit(SEARCH_LIMIT)
.offset((page - 1) * SEARCH_LIMIT)
@ -250,7 +246,7 @@ class Asset < ActiveRecord::Base
end
end
def url(style = :original, timeout: 30)
def url(style = :original, timeout: URL_SHORT_EXPIRE_TIME)
if file.is_stored_on_s3?
presigned_url(style, timeout: timeout)
else
@ -259,7 +255,7 @@ class Asset < ActiveRecord::Base
end
# When using S3 file upload, we can limit file accessibility with url signing
def presigned_url(style = :original, download: false, timeout: 30)
def presigned_url(style = :original, download: false, timeout: URL_SHORT_EXPIRE_TIME)
if file.is_stored_on_s3?
if download
download_arg = 'attachment; filename=' + URI.escape(file_file_name)

View file

@ -23,7 +23,7 @@ class Checklist < ActiveRecord::Base
def self.search(user, include_archived, query = nil, page = 1)
step_ids =
Step
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.select("id")
if query
@ -43,7 +43,7 @@ class Checklist < ActiveRecord::Base
.where_attributes_like(["checklists.name", "checklist_items.text"], a_query)
# Show all results if needed
if page == SHOW_ALL_RESULTS
if page == SEARCH_NO_LIMIT
new_query
else
new_query

View file

@ -24,19 +24,19 @@ class Comment < ActiveRecord::Base
)
project_ids =
Project
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.select("id")
my_module_ids =
MyModule
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.select("id")
step_ids =
Step
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.select("id")
result_ids =
Result
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.select("id")
@ -73,7 +73,7 @@ class Comment < ActiveRecord::Base
)
# Show all results if needed
if page == SHOW_ALL_RESULTS
if page == SEARCH_NO_LIMIT
new_query
else
new_query

View file

@ -35,7 +35,7 @@ class Experiment < ActiveRecord::Base
def self.search(user, include_archived, query = nil, page = 1)
project_ids =
Project
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.select("id")
if query
@ -62,7 +62,7 @@ class Experiment < ActiveRecord::Base
end
# Show all results if needed
if page == SHOW_ALL_RESULTS
if page == SEARCH_NO_LIMIT
new_query
else
new_query
@ -335,10 +335,10 @@ class Experiment < ActiveRecord::Base
format = 'Clone %d - %s'
i = 1
i += 1 while experiment_names.include?(format(format, i, name)[0, 50])
i += 1 while experiment_names.include?(format(format, i, name))
clone = Experiment.new(
name: format(format, i, name)[0, 50],
name: format(format, i, name),
description: description,
created_by: current_user,
last_modified_by: current_user,

View file

@ -43,7 +43,7 @@ class MyModule < ActiveRecord::Base
def self.search(user, include_archived, query = nil, page = 1)
exp_ids =
Experiment
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.select("id")
if query
@ -70,7 +70,7 @@ class MyModule < ActiveRecord::Base
end
# Show all results if needed
if page == SHOW_ALL_RESULTS
if page == SEARCH_NO_LIMIT
new_query
else
new_query
@ -145,13 +145,13 @@ class MyModule < ActiveRecord::Base
)
end
def last_activities(count = 20)
def last_activities(count = ACTIVITY_SEARCH_LIMIT)
Activity.where(my_module_id: id).order(:created_at).last(count)
end
# Get module comments ordered by created_at time. Results are paginated
# using last comment id and per_page parameters.
def last_comments(last_id = 1, per_page = 20)
def last_comments(last_id = 1, per_page = COMMENTS_SEARCH_LIMIT)
last_id = 9999999999999 if last_id <= 1
comments = Comment.joins(:my_module_comment)
.where(my_module_comments: { my_module_id: id })
@ -161,7 +161,7 @@ class MyModule < ActiveRecord::Base
comments.reverse
end
def last_activities(last_id = 1, count = 20)
def last_activities(last_id = 1, count = ACTIVITY_SEARCH_LIMIT)
last_id = 9999999999999 if last_id <= 1
Activity.joins(:my_module)
.where(my_module_id: id)
@ -177,7 +177,7 @@ class MyModule < ActiveRecord::Base
protocols.count > 0 ? protocols.first : nil
end
def first_n_samples(count = 20)
def first_n_samples(count)
samples.order(name: :asc).limit(count)
end

View file

@ -12,7 +12,7 @@ class MyModuleGroup < ActiveRecord::Base
def self.search(user, include_archived, query = nil, page = 1)
exp_ids =
Experiment
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.select("id")
@ -32,7 +32,7 @@ class MyModuleGroup < ActiveRecord::Base
.where_attributes_like("my_module_groups.name", a_query)
# Show all results if needed
if page == SHOW_ALL_RESULTS
if page == SEARCH_NO_LIMIT
new_query
else
new_query

View file

@ -64,7 +64,7 @@ class Project < ActiveRecord::Base
end
# Show all results if needed
if page == SHOW_ALL_RESULTS
if page == SEARCH_NO_LIMIT
new_query
else
new_query
@ -73,13 +73,13 @@ class Project < ActiveRecord::Base
end
end
def last_activities(count = 20)
def last_activities(count = ACTIVITY_SEARCH_LIMIT)
activities.order(created_at: :desc).first(count)
end
# Get project comments order by created_at time. Results are paginated
# using last comment id and per_page parameters.
def last_comments(last_id = 1, per_page = 20)
def last_comments(last_id = 1, per_page = COMMENTS_SEARCH_LIMIT)
last_id = 9999999999999 if last_id <= 1
comments = Comment.joins(:project_comment)
.where(project_comments: { project_id: id })

View file

@ -76,7 +76,7 @@ class Protocol < ActiveRecord::Base
module_ids =
MyModule
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.select("id")
where_str =
@ -140,7 +140,7 @@ class Protocol < ActiveRecord::Base
)
# Show all results if needed
if page == SHOW_ALL_RESULTS
if page == SEARCH_NO_LIMIT
new_query
else
new_query

View file

@ -1,6 +1,7 @@
class ProtocolKeyword < ActiveRecord::Base
auto_strip_attributes :name, nullify: false
validates :name, presence: true, length: { maximum: NAME_MAX_LENGTH }
validates :name,
length: { minimum: NAME_MIN_LENGTH, maximum: NAME_MAX_LENGTH }
validates :organization, presence: true
belongs_to :organization, inverse_of: :protocol_keywords

View file

@ -26,7 +26,7 @@ class Report < ActiveRecord::Base
project_ids =
Project
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.select("id")
if query
@ -53,7 +53,7 @@ class Report < ActiveRecord::Base
)
# Show all results if needed
if page == SHOW_ALL_RESULTS
if page == SEARCH_NO_LIMIT
new_query
else
new_query

View file

@ -35,7 +35,7 @@ class Result < ActiveRecord::Base
def self.search(user, include_archived, query = nil, page = 1)
module_ids =
MyModule
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.select("id")
if query
@ -59,7 +59,7 @@ class Result < ActiveRecord::Base
end
# Show all results if needed
if page == SHOW_ALL_RESULTS
if page == SEARCH_NO_LIMIT
new_query
else
new_query
@ -72,7 +72,7 @@ class Result < ActiveRecord::Base
is_asset ? result_asset.space_taken : 0
end
def last_comments(last_id = 1, per_page = 20)
def last_comments(last_id = 1, per_page = COMMENTS_SEARCH_LIMIT)
last_id = 9999999999999 if last_id <= 1
comments = Comment.joins(:result_comment)
.where(result_comments: { result_id: id })

View file

@ -59,7 +59,7 @@ class Sample < ActiveRecord::Base
)
# Show all results if needed
if page == SHOW_ALL_RESULTS
if page == SEARCH_NO_LIMIT
new_query
else
new_query

View file

@ -42,7 +42,7 @@ class Step < ActiveRecord::Base
def self.search(user, include_archived, query = nil, page = 1)
protocol_ids =
Protocol
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.select("id")
if query
@ -61,7 +61,7 @@ class Step < ActiveRecord::Base
.where_attributes_like([:name, :description], a_query)
# Show all results if needed
if page == SHOW_ALL_RESULTS
if page == SEARCH_NO_LIMIT
new_query
else
new_query
@ -86,7 +86,7 @@ class Step < ActiveRecord::Base
protocol.present? ? protocol.my_module : nil
end
def last_comments(last_id = 1, per_page = 20)
def last_comments(last_id = 1, per_page = COMMENTS_SEARCH_LIMIT)
last_id = 9999999999999 if last_id <= 1
comments = Comment.joins(:step_comment)
.where(step_comments: { step_id: id })

View file

@ -20,14 +20,14 @@ class Table < ActiveRecord::Base
def self.search(user, include_archived, query = nil, page = 1)
step_ids =
Step
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.joins(:step_tables)
.select("step_tables.id")
.distinct
result_ids =
Result
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.joins(:result_table)
.select("result_tables.id")
.distinct
@ -55,7 +55,7 @@ class Table < ActiveRecord::Base
new_query = table_query
# Show all results if needed
if page == SHOW_ALL_RESULTS
if page == SEARCH_NO_LIMIT
new_query
else
new_query

View file

@ -15,7 +15,7 @@ class Tag < ActiveRecord::Base
def self.search(user, include_archived, query = nil, page = 1)
project_ids =
Project
.search(user, include_archived, nil, SHOW_ALL_RESULTS)
.search(user, include_archived, nil, SEARCH_NO_LIMIT)
.select("id")
if query
@ -34,7 +34,7 @@ class Tag < ActiveRecord::Base
.where_attributes_like(:name, a_query)
# Show all results if needed
if page == SHOW_ALL_RESULTS
if page == SEARCH_NO_LIMIT
new_query
else
new_query

View file

@ -3,13 +3,14 @@ class User < ActiveRecord::Base
devise :invitable, :confirmable, :database_authenticatable, :registerable, :async,
:recoverable, :rememberable, :trackable, :validatable, stretches: 10
has_attached_file :avatar, :styles => {
:medium => "300x300>",
:thumb => "100x100>",
:icon => "40x40>",
:icon_small => "30x30>"
},
:default_url => "/images/:style/missing.png"
has_attached_file :avatar,
styles: {
medium: MEDIUM_PIC_FORMAT,
thumb: THUMB_PIC_FORMAT,
icon: ICON_PIC_FORMAT,
icon_small: ICON_SMALL_PIC_FORMAT
},
default_url: DEFAULT_AVATAR_URL
enum tutorial_status: {
no_tutorial_done: 0,
@ -233,7 +234,7 @@ class User < ActiveRecord::Base
# Finds all activities of user that is assigned to project. If user
# is not an owner of the project, user must be also assigned to
# module.
def last_activities(last_activity_id = nil, per_page = 10)
def last_activities(last_activity_id = nil, per_page = ACTIVITY_SEARCH_LIMIT)
# TODO replace with some kind of Infinity value
last_activity_id = 999999999999999999999999 if last_activity_id < 1
Activity

View file

@ -3,19 +3,19 @@
<%= l activity.created_at, format: '%H:%M' %>
</span>
<span class="activity-item-text">
<%= activity_truncate( activity.message ) %>
<%= activity_truncate(activity.message) %>
<% if activity.my_module %>
[<%=t 'Project' %>:
<% if activity.my_module.experiment.project.name.length > 20 %>
<% if activity.my_module.experiment.project.name.length > NAME_TRUNCATION_LENGTH %>
<div class="modal-tooltip">
<%= truncate(activity.my_module.experiment.project.name, lenght: 20).strip %>
<%= truncate(activity.my_module.experiment.project.name, lenght: NAME_TRUNCATION_LENGTH).strip %>
<span class="modal-tooltiptext"><%= activity.my_module.experiment.project.name %></span>
</div>
<% else %>
<%= activity.my_module.experiment.project.name %>
<% end %>, <%=t 'Module' %>:
<% if activity.my_module.name.length > 20 %>
<div class="modal-tooltip"><%= truncate(activity.my_module.name, lenght: 20) %>
<% if activity.my_module.name.length > NAME_TRUNCATION_LENGTH %>
<div class="modal-tooltip"><%= truncate(activity.my_module.name, lenght: NAME_TRUNCATION_LENGTH) %>
<span class="modal-tooltiptext"><%= activity.my_module.name %></span>
</div>
<% else %>

View file

@ -5,8 +5,8 @@
<li><em><%= t 'experiments.canvas.popups.no_activities' %></em></li>
<% else %>
<% @activities.each do |activity| %>
<li><span class="text-muted"><%=l activity.created_at, format: :full %></span>
<br><span><%= activity_truncate( activity.message ) %></span>
<li><span class="text-muted"><%= l activity.created_at, format: :full %></span>
<br><span><%= activity_truncate(activity.message) %></span>
</li>
<% end %>
<% end %>

View file

@ -6,7 +6,7 @@
<% else %>
<% @activities.each do |activity| %>
<li><span class="text-muted"><%= l activity.created_at, format: :full %></span>
<br><span><%= activity_truncate( activity.message, 30 ) %></span>
<br><span><%= activity_truncate(activity.message) %></span>
</li>
<% end %>
<% end %>

View file

@ -25,7 +25,7 @@
<div class="panel-body">
<% if experiment.workflowimg? %>
<div class="workflowimg-container">
<%= image_tag(experiment.workflowimg.expiring_url(30),
<%= image_tag(experiment.workflowimg.expiring_url(URL_SHORT_EXPIRE_TIME),
class: 'img-responsive center-block') %>
</div>
<% end %>

View file

@ -1,3 +1,3 @@
<%= link_to image_tag( @experiment.workflowimg.expiring_url(30),
<%= link_to image_tag( @experiment.workflowimg.expiring_url(URL_SHORT_EXPIRE_TIME),
class: 'img-responsive center-block'),
canvas_experiment_path(@experiment) %>

View file

@ -15,7 +15,7 @@
<%= name %>
</div>
<div class="pull-left file-name">
<em><%=t "projects.reports.elements.result_asset.file_name", file: truncate( asset.file_file_name, length: 50 ) %></em>
<em><%=t "projects.reports.elements.result_asset.file_name", file: truncate( asset.file_file_name, length: FILENAME_TRUNCATION_LENGTH ) %></em>
</div>
<div class="pull-left user-time">
<%=t "projects.reports.elements.result_asset.user_time", user: result.user.full_name, timestamp: l(timestamp, format: :full) %>

View file

@ -1,7 +1,7 @@
<% if can_view_or_download_result_assets(result.my_module) %>
<%= link_to download_asset_path(result.asset), data: {no_turbolink: true} do %>
<%= image_tag(preview_asset_path result.asset) if result.asset.is_image? %>
<p><%= truncate(result.asset.file_file_name, length: 50) %></p>
<p><%= truncate(result.asset.file_file_name, length: FILENAME_TRUNCATION_LENGTH) %></p>
<% end %>
<% else %>
<%= image_tag(preview_asset_path result.asset) if result.asset.is_image? %>

View file

@ -186,21 +186,21 @@
<% if can_view_projects(@project.organization) %>
<a href="<%= projects_path :organization => @project.organization.id %>">
<% end %>
<%= truncate( @project.organization.name, length: 20 ) %>
<%= truncate( @project.organization.name, length: NAME_TRUNCATION_LENGTH ) %>
<% if can_view_projects(@project.organization) %>
</a>
<% end %>
</li>
<% if project_page? %>
<li class="active">
<%= truncate( @project.name, length: 20 ) %>
<%= truncate( @project.name, length: NAME_TRUNCATION_LENGTH ) %>
</li>
<% else %>
<li>
<% if can_view_project(@project) %>
<a href="<%= project_url(@project) %>">
<% end %>
<%= truncate( @project.name, length: 20 ) %>
<%= truncate( @project.name, length: NAME_TRUNCATION_LENGTH ) %>
<% if can_view_project(@project) %>
</a>
<% end %>
@ -209,21 +209,21 @@
<% if experiment_page? || module_page? %>
<% if !module_page? %>
<li class="active">
<%= truncate(@experiment.name, length: 20) %>
<%= truncate(@experiment.name, length: NAME_TRUNCATION_LENGTH) %>
</li>
<% else %>
<li>
<% if can_view_experiment(@experiment) %>
<%= link_to truncate(@experiment.name, length: 20), canvas_experiment_path(@experiment) %>
<%= link_to truncate(@experiment.name, length: NAME_TRUNCATION_LENGTH), canvas_experiment_path(@experiment) %>
<% else %>
<%= truncate(@experiment.name, length: 20) %>
<%= truncate(@experiment.name, length: NAME_TRUNCATION_LENGTH) %>
<% end %>
</li>
<% end %>
<% end %>
<% if module_page? %>
<li class="active">
<%= truncate( @my_module.name, length: 20 ) %>
<%= truncate( @my_module.name, length: NAME_TRUNCATION_LENGTH ) %>
</li>
<% end %>
</ul>

View file

@ -61,14 +61,16 @@
<% if asset.file_present %>
<%= link_to download_asset_path(asset), data: {no_turbolink: true, id: true, status: "asset-present"} do %>
<%= image_tag preview_asset_path(asset) if asset.is_image? %>
<p><%= truncate(asset.file_file_name, length: 50) %></p>
<p><%= truncate(asset.file_file_name,
length: FILENAME_TRUNCATION_LENGTH) %></p>
<% end %>
<% else %>
<%= asset_loading_span(asset) %>
<% end %>
<% else %>
<%= image_tag preview_asset_path(asset) if asset.is_image? %>
<p><%= truncate(asset.file_file_name, length: 50) %></p>
<p><%= truncate(asset.file_file_name,
length: FILENAME_TRUNCATION_LENGTH) %></p>
<% end %>
</li>
<% end %>

View file

@ -1,81 +1,138 @@
#===============================================================================
# Defaults
#===============================================================================
# Application version
APP_VERSION = '1.3.1'.freeze
TAG_COLORS = [
"#6C159E",
"#159B5E",
"#FF4500",
"#008B8B",
"#757575",
"#32CD32",
"#FFD700",
"#48D1CC",
"#15369E",
"#FF69B4",
"#CD5C5C",
"#C9C9C9",
"#6495ED",
"#DC143C",
"#FF8C00",
"#C71585",
"#000000"
]
'#6C159E',
'#159B5E',
'#FF4500',
'#008B8B',
'#757575',
'#32CD32',
'#FFD700',
'#48D1CC',
'#15369E',
'#FF69B4',
'#CD5C5C',
'#C9C9C9',
'#6495ED',
'#DC143C',
'#FF8C00',
'#C71585',
'#000000'
].freeze
# Min/max characters for short text fields
TEXT_EXTRACT_FILE_TYPES = [
'application/pdf',
'application/rtf',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.oasis.opendocument.presentation',
'application/vnd.oasis.opendocument.spreadsheet',
'application/vnd.oasis.opendocument.text',
'application/vnd.ms-excel',
'application/vnd.ms-powerpoint',
'application/vnd.ms-word',
'text/plain'
].freeze
DEFAULT_PRIVATE_ORG_NAME = 'My projects'.freeze
#===============================================================================
# String length
#===============================================================================
# Min characters for short text fields
NAME_MIN_LENGTH = 2
# Max characters for short text fields
NAME_MAX_LENGTH = 255
# Max characters for short text fields, after which they get truncated
NAME_TRUNCATION_LENGTH = 25
# Max characters for long text fields
TEXT_MAX_LENGTH = 10000
# Max characters for color field (given in HEX format)
COLOR_MAX_LENGTH = 7
# Max characters for text in dropdown list element
DROPDOWN_TEXT_MAX_LENGTH = 15
# Max characters for filenames, after which they get truncated
FILENAME_TRUNCATION_LENGTH = 50
USER_INITIALS_MAX_LENGTH = 4
# Standard length limit for email
# Standard max length for email
EMAIL_MAX_LENGTH = 254
#===============================================================================
# Query/display limits
#===============================================================================
# General limited/unlimited query/display elements for pages
SEARCH_LIMIT = 20
SEARCH_NO_LIMIT = -1
# General limited query/display elements for popup modals
MODAL_SEARCH_LIMIT = 5
# Comments limited query/display elements for pages
COMMENTS_SEARCH_LIMIT = 10
# Activity limited query/display elements for pages
ACTIVITY_SEARCH_LIMIT = 20
#===============================================================================
# File and data memory size
#===============================================================================
# Max table JSON size in MB
TABLE_JSON_MAX_SIZE = 20
# Max uploaded file size in MB
FILE_MAX_SIZE = 50
# Max uploaded user avatar size in MB
# Max uploaded user picture avatar size in MB
AVATAR_MAX_SIZE = 0.2
# Max characters for text in dropdown list
DROPDOWN_TEXT_MAX_LENGTH = 15
#===============================================================================
# Picture size format
#===============================================================================
MEDIUM_PIC_FORMAT = '300x300>'.freeze
THUMB_PIC_FORMAT = '100x100>'.freeze
ICON_PIC_FORMAT = '40x40>'.freeze
ICON_SMALL_PIC_FORMAT = '30x30>'.freeze
#===============================================================================
# Styling
#===============================================================================
# Dropdown top offset from the parent
DROPDOWN_TOP_OFFSET = 20
DROPDOWN_TOP_OFFSET_PX = 20
SEARCH_LIMIT = 20
#===============================================================================
# Time
#===============================================================================
EXISTING_USERS_SEARCH_LIMIT = 5
# URL expire time, used for presigned file URLs, because outsiders shouldn't
# have access to them, but some buffer time is needed for file to be loaded
URL_SHORT_EXPIRE_TIME = 30
# Same as URL_EXPIRE_TIME, except for cases where the URL migth be used in
# another page, and hence the URL mustn't expire by then (e.g. when generating
# report and than using same HTML code in PDF, and consequently same file URL);
# it expires in exactly one day
URL_LONG_EXPIRE_TIME = 86_400
SHOW_ALL_RESULTS = -1
QUERY_MIN_LENGTH = 2
TEXT_EXTRACT_FILE_TYPES = [
"application/pdf",
"application/rtf",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
"application/vnd.oasis.opendocument.presentation",
"application/vnd.oasis.opendocument.spreadsheet",
"application/vnd.oasis.opendocument.text",
"application/vnd.ms-excel",
"application/vnd.ms-powerpoint",
"application/vnd.ms-word",
"text/plain"
]
#===============================================================================
# Space
#===============================================================================
# 1 MB of space is minimal for organizations (in B)
MINIMAL_ORGANIZATION_SPACE_TAKEN = 1.megabyte
# additional space of each file is added to its estimated
# size to account for DB indexes size etc.
ASSET_ESTIMATED_SIZE_FACTOR = 1.1
DEFAULT_PRIVATE_ORG_NAME = "My projects"
#===============================================================================
# External URL
#===============================================================================
# External URLs
HTTP = 'http://'.freeze
TUTORIALS_URL = (HTTP + 'scinote.net/product/tutorials/').freeze
FAQ_URL = (HTTP + 'scinote.net/product/faq/').freeze
@ -83,6 +140,12 @@ SUPPORT_URL = (HTTP + 'scinote.net/plans/#prof-support').freeze
PLANS_URL = (HTTP + 'scinote.net/plans/').freeze
CONTACT_URL = (HTTP + 'scinote.net/about-us/').freeze
RELEASE_NOTES_URL = (HTTP + 'scinote.net/docs/release-notes/').freeze
# Default user picture avatar
DEFAULT_AVATAR_URL = '/images/:style/missing.png'.freeze
#===============================================================================
# Other
#===============================================================================
# ) \ / (
# /|\ )\_/( /|\
@ -104,15 +167,15 @@ RELEASE_NOTES_URL = (HTTP + 'scinote.net/docs/release-notes/').freeze
# * l / V )) V \ l *
# l/ // \I
KICKSTARTER_SUPPORTERS = [
"Manuela Lanzafame",
"Fluckiger Rudolf",
"Emily Gleason",
"Benjamin E Doremus",
"Chord Pet Wearable",
"Chris Taylor",
"Abraham White",
"Ryotaro Eguchi",
"Simon Waldherr",
"Isaac Sandaljian",
"Markus Rademacher"
]
'Manuela Lanzafame',
'Fluckiger Rudolf',
'Emily Gleason',
'Benjamin E Doremus',
'Chord Pet Wearable',
'Chris Taylor',
'Abraham White',
'Ryotaro Eguchi',
'Simon Waldherr',
'Isaac Sandaljian',
'Markus Rademacher'
].freeze