From 53808b073f539ba2b442738b6abf97228488e311 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 8 Apr 2014 09:12:37 +0200 Subject: moving all of core into toplevel, tests fail. --- core/Gemfile | 17 --- core/Rakefile | 44 ------- core/Readme.md | 6 - core/app/assets/javascripts/leap.js | 7 - core/app/assets/javascripts/platform.js | 93 -------------- core/app/helpers/core_helper.rb | 13 -- core/app/helpers/download_helper.rb | 33 ----- core/app/helpers/navigation_helper.rb | 82 ------------ core/app/views/common/_download_for_os.html.haml | 17 --- core/app/views/common/_home_page_buttons.html.haml | 23 ---- core/app/views/kaminari/_first_page.html.haml | 9 -- core/app/views/kaminari/_gap.html.haml | 8 -- core/app/views/kaminari/_last_page.html.haml | 9 -- core/app/views/kaminari/_next_page.html.haml | 12 -- core/app/views/kaminari/_page.html.haml | 14 -- core/app/views/kaminari/_paginator.html.haml | 19 --- core/app/views/kaminari/_prev_page.html.haml | 12 -- core/config/initializers/backtrace_silencers.rb | 7 - core/config/initializers/couchrest_model.rb | 3 - core/config/initializers/inflections.rb | 15 --- core/config/initializers/mime_types.rb | 5 - core/config/initializers/simple_form.rb | 142 --------------------- core/config/initializers/simple_form_bootstrap.rb | 57 --------- core/config/initializers/validations.rb | 4 - core/config/initializers/wrap_parameters.rb | 10 -- core/config/locales/en.yml | 41 ------ core/config/locales/simple_form.en.yml | 26 ---- core/config/routes.rb | 2 - core/leap_web_core.gemspec | 25 ---- core/lib/extensions/couchrest.rb | 95 -------------- core/lib/extensions/testing.rb | 48 ------- core/lib/leap_web_core.rb | 14 -- core/lib/leap_web_core/dependencies.rb | 40 ------ core/lib/leap_web_core/engine.rb | 9 -- core/lib/leap_web_core/ui_dependencies.rb | 11 -- core/lib/tasks/leap_web_core_tasks.rake | 25 ---- core/script/rails | 8 -- core/test/support/browser_integration_test.rb | 81 ------------ core/test/support/rack_test.rb | 37 ------ core/test/support/with_config_helper.rb | 16 --- 40 files changed, 1139 deletions(-) delete mode 100644 core/Gemfile delete mode 100644 core/Rakefile delete mode 100644 core/Readme.md delete mode 100644 core/app/assets/javascripts/leap.js delete mode 100644 core/app/assets/javascripts/platform.js delete mode 100644 core/app/helpers/core_helper.rb delete mode 100644 core/app/helpers/download_helper.rb delete mode 100644 core/app/helpers/navigation_helper.rb delete mode 100644 core/app/views/common/_download_for_os.html.haml delete mode 100644 core/app/views/common/_home_page_buttons.html.haml delete mode 100644 core/app/views/kaminari/_first_page.html.haml delete mode 100644 core/app/views/kaminari/_gap.html.haml delete mode 100644 core/app/views/kaminari/_last_page.html.haml delete mode 100644 core/app/views/kaminari/_next_page.html.haml delete mode 100644 core/app/views/kaminari/_page.html.haml delete mode 100644 core/app/views/kaminari/_paginator.html.haml delete mode 100644 core/app/views/kaminari/_prev_page.html.haml delete mode 100644 core/config/initializers/backtrace_silencers.rb delete mode 100644 core/config/initializers/couchrest_model.rb delete mode 100644 core/config/initializers/inflections.rb delete mode 100644 core/config/initializers/mime_types.rb delete mode 100644 core/config/initializers/simple_form.rb delete mode 100644 core/config/initializers/simple_form_bootstrap.rb delete mode 100644 core/config/initializers/validations.rb delete mode 100644 core/config/initializers/wrap_parameters.rb delete mode 100644 core/config/locales/en.yml delete mode 100644 core/config/locales/simple_form.en.yml delete mode 100644 core/config/routes.rb delete mode 100644 core/leap_web_core.gemspec delete mode 100644 core/lib/extensions/couchrest.rb delete mode 100644 core/lib/extensions/testing.rb delete mode 100644 core/lib/leap_web_core.rb delete mode 100644 core/lib/leap_web_core/dependencies.rb delete mode 100644 core/lib/leap_web_core/engine.rb delete mode 100644 core/lib/leap_web_core/ui_dependencies.rb delete mode 100644 core/lib/tasks/leap_web_core_tasks.rake delete mode 100755 core/script/rails delete mode 100644 core/test/support/browser_integration_test.rb delete mode 100644 core/test/support/rack_test.rb delete mode 100644 core/test/support/with_config_helper.rb (limited to 'core') diff --git a/core/Gemfile b/core/Gemfile deleted file mode 100644 index b552dc5..0000000 --- a/core/Gemfile +++ /dev/null @@ -1,17 +0,0 @@ -source "https://rubygems.org" - -# Declare your gem's dependencies in leap_web_core.gemspec. -# Bundler will treat runtime dependencies like base dependencies, and -# development dependencies will be added by default to the :development group. -gemspec - -# jquery-rails is used by the dummy application -gem "jquery-rails" - -# Declare any dependencies that are still in development here instead of in -# your gemspec. These might include edge Rails or gems from your path or -# Git. Remember to move these dependencies to your gemspec before releasing -# your gem to rubygems.org. - -# To use debugger -# gem 'ruby-debug' diff --git a/core/Rakefile b/core/Rakefile deleted file mode 100644 index 3c6539c..0000000 --- a/core/Rakefile +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env rake - -require 'rake/packagetask' -require 'rubygems/package_task' - -begin - require 'bundler/setup' -rescue LoadError - puts 'You must `gem install bundler` and `bundle install` to run rake tasks' -end -begin - require 'rdoc/task' -rescue LoadError - require 'rdoc/rdoc' - require 'rake/rdoctask' - RDoc::Task = Rake::RDocTask -end - -RDoc::Task.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'LeapWebCore' - rdoc.options << '--line-numbers' - rdoc.rdoc_files.include('README.rdoc') - rdoc.rdoc_files.include('lib/**/*.rb') -end - -spec = eval(File.read('leap_web_core.gemspec')) -Gem::PackageTask.new(spec) do |p| - p.gem_spec = spec -end - -Bundler::GemHelper.install_tasks - -require 'rake/testtask' - -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.libs << 'test' - t.pattern = 'test/**/*_test.rb' - t.verbose = false -end - - -task :default => :test diff --git a/core/Readme.md b/core/Readme.md deleted file mode 100644 index 795c0a4..0000000 --- a/core/Readme.md +++ /dev/null @@ -1,6 +0,0 @@ -Leap Web Core -=== - -[Leap](http://www.leap.se) is the Leap Encryption Access Project and this is the rails app for its web interface. - -This is the its core gem. Currently it only serves to load shared dependencies. diff --git a/core/app/assets/javascripts/leap.js b/core/app/assets/javascripts/leap.js deleted file mode 100644 index 94e602d..0000000 --- a/core/app/assets/javascripts/leap.js +++ /dev/null @@ -1,7 +0,0 @@ - -// -// add a bootstrap alert to the page via javascript. -// -function alert_message(msg) { - $('#messages').append('
×'+msg+'
'); -} diff --git a/core/app/assets/javascripts/platform.js b/core/app/assets/javascripts/platform.js deleted file mode 100644 index 108c162..0000000 --- a/core/app/assets/javascripts/platform.js +++ /dev/null @@ -1,93 +0,0 @@ -/* Inspired by mozillas platform detection: - https://github.com/mozilla/bedrock/tree/master/media/js/base -*/ - (function () { - 'use strict'; - function getPlatform() { - var ua = navigator.userAgent, - pf = navigator.platform; - if (/Win(16|9[x58]|NT( [1234]| 5\.0| [^0-9]|[^ -]|$))/.test(ua) || - /Windows ([MC]E|9[x58]|3\.1|4\.10|NT( [1234]| 5\.0| [^0-9]|[^ ]|$))/.test(ua) || - /Windows_95/.test(ua)) { - /** - * Officially unsupported platforms are Windows 95, 98, ME, NT 4.x, 2000 - * These regular expressions match: - * - Win16 - * - Win9x - * - Win95 - * - Win98 - * - WinNT (not followed by version or followed by version <= 5) - * - Windows ME - * - Windows CE - * - Windows 9x - * - Windows 95 - * - Windows 98 - * - Windows 3.1 - * - Windows 4.10 - * - Windows NT (not followed by version or followed by version <= 5) - * - Windows_95 - */ - return 'oldwin'; - } - if (ua.indexOf("MSIE 6.0") !== -1 && - ua.indexOf("Windows NT 5.1") !== -1 && - ua.indexOf("SV1") === -1) { - // Windows XP SP1 - return 'oldwin'; - } - if (pf.indexOf("Win32") !== -1 || - pf.indexOf("Win64") !== -1) { - return 'windows'; - } - if (/android/i.test(ua)) { - return 'android'; - } - if (/armv[6-7]l/.test(pf)) { - return 'android'; - } - if (pf.indexOf("Linux") !== -1) { - return 'linux'; - //if (pf.indexOf("64") !== -1) { - // return 'linux64'; - //} else { - // return 'linux32'; - //} - } - if (pf.indexOf("MacPPC") !== -1) { - return 'oldmac'; - } - if (/Mac OS X 10.[0-5]/.test(ua)) { - return 'oldmac'; - } - if (pf.indexOf('iPhone') !== -1 || - pf.indexOf('iPad') !== -1 || - pf.indexOf('iPod') !== -1 ) { - return 'ios'; - } - if (ua.indexOf("Mac OS X") !== -1) { - return 'osx'; - } - if (ua.indexOf("MSIE 5.2") !== -1) { - return 'oldmac'; - } - if (pf.indexOf("Mac") !== -1) { - return 'oldmac'; - } - if (navigator.platform === '' && - navigator.userAgent.indexOf("Firefox") !== -1 && - navigator.userAgent.indexOf("Mobile") !== -1) { - return 'fxos'; - } - - return 'other'; - } - (function () { - // Immediately set the platform classname on the html-element - // to avoid lots of flickering - var h = document.documentElement; - window.site = { - platform : getPlatform() - }; - h.className = window.site.platform; - })(); - })(); diff --git a/core/app/helpers/core_helper.rb b/core/app/helpers/core_helper.rb deleted file mode 100644 index a6c7479..0000000 --- a/core/app/helpers/core_helper.rb +++ /dev/null @@ -1,13 +0,0 @@ -# -# Misc. helpers needed throughout. -# -module CoreHelper - - # - # insert common buttons (download, login, etc) - # - def home_page_buttons(on_user_page = false) - render 'common/home_page_buttons', {:on_user_page => on_user_page} - end - -end diff --git a/core/app/helpers/download_helper.rb b/core/app/helpers/download_helper.rb deleted file mode 100644 index ee0fe73..0000000 --- a/core/app/helpers/download_helper.rb +++ /dev/null @@ -1,33 +0,0 @@ -module DownloadHelper - - def alternative_client_links(os = nil) - alternative_clients(os).map do |client| - link_to(I18n.t("os."+client), client_download_url(client)) - end - end - - def alternative_clients(os = nil) - available_clients - [os] - end - - def client_download_url(os = nil) - client_download_domain + client_download_path(os) - end - - def client_download_path(os) - download_paths[os.to_s] || download_paths['other'] || '' - end - - def available_clients - APP_CONFIG[:available_clients] || [] - end - - def client_download_domain - APP_CONFIG[:client_download_domain] || '' - end - - def download_paths - APP_CONFIG[:download_paths] || {} - end - -end diff --git a/core/app/helpers/navigation_helper.rb b/core/app/helpers/navigation_helper.rb deleted file mode 100644 index 19cb934..0000000 --- a/core/app/helpers/navigation_helper.rb +++ /dev/null @@ -1,82 +0,0 @@ -module NavigationHelper - - # - # used to create a side navigation link. - # - # Signature is the same as link_to, except it accepts an :active value in the html_options - # - def link_to_navigation(*args) - if args.last.is_a? Hash - html_options = args.pop.dup - active_class = html_options.delete(:active) ? 'active' : nil - html_options[:class] = [html_options[:class], active_class].join(' ') - args << html_options - else - active_class = nil - end - content_tag :li, :class => active_class do - link_to(*args) - end - end - - # - # returns true if params[:action] matches one of the args. - # - def action?(*actions) - actions.detect do |action| - if action.is_a? String - action == action_string - elsif action.is_a? Symbol - if action == :none - action_string == nil - else - action == action_symbol - end - end - end - end - - # - # returns true if params[:controller] matches one of the args. - # - # for example: - # controller?(:me, :home) - # controller?('groups/') <-- matches any controller in namespace 'groups' - # - def controller?(*controllers) - controllers.each do |cntr| - if cntr.is_a? String - if cntr.ends_with?('/') - return true if controller_string.starts_with?(cntr.chop) - end - return true if cntr == controller_string - elsif cntr.is_a? Symbol - return true if cntr == controller_symbol - end - end - return false - end - - private - - def controller_string - @controller_string ||= params[:controller].to_s.gsub(/^\//, '') - end - - def controller_symbol - @controller_symbol ||= params[:controller].gsub(/^\//,'').gsub('/','_').to_sym - end - - def action_string - params[:action] - end - - def action_symbol - @action_symbol ||= if params[:action].present? - params[:action].to_sym - else - nil - end - end - -end diff --git a/core/app/views/common/_download_for_os.html.haml b/core/app/views/common/_download_for_os.html.haml deleted file mode 100644 index 3a11d10..0000000 --- a/core/app/views/common/_download_for_os.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -- os = download_for_os -%div{:class => "os-#{os}"} - %span.link - - btn_class = (os == "other") ? "disabled" : "btn-primary" - = link_to client_download_url(os), :class => "btn btn-large #{btn_class}" do - = big_icon('download') - .pull-right - = t(:download_client) - %br/ - %small= I18n.t("os.#{os}") - %span.info - %div= t(:client_info, :provider => content_tag(:b,APP_CONFIG[:domain])).html_safe - %div - - if os == "other" - = t(:all_downloads_info, :clients => alternative_client_links(os).to_sentence).html_safe - - else - = t(:other_downloads_info, :clients => alternative_client_links(os).to_sentence).html_safe diff --git a/core/app/views/common/_home_page_buttons.html.haml b/core/app/views/common/_home_page_buttons.html.haml deleted file mode 100644 index c9ea7a2..0000000 --- a/core/app/views/common/_home_page_buttons.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -- icon_color = :black - -.home-buttons - .row-fluid.first - .span2 - .download.span8 - = render partial: 'common/download_for_os', collection: available_clients + ['other'] - .span2 - - if local_assigns[:divider] - .row-fluid - .span12 - = render local_assigns[:divider] - - if !local_assigns[:on_user_page] - .row-fluid.second - .login.span4 - %span.link= link_to(icon('ok-sign', icon_color) + t(:login), login_path, :class => 'btn') - %span.info= t(:login_info) - .signup.span4 - %span.link= link_to(icon('user', icon_color) + t(:signup), signup_path, :class => 'btn') - %span.info= t(:signup_info) - .help.span4 - %span.link= link_to(icon('question-sign', icon_color) + t(:get_help), new_ticket_path, :class => 'btn') - %span.info= t(:help_info) diff --git a/core/app/views/kaminari/_first_page.html.haml b/core/app/views/kaminari/_first_page.html.haml deleted file mode 100644 index 34436e3..0000000 --- a/core/app/views/kaminari/_first_page.html.haml +++ /dev/null @@ -1,9 +0,0 @@ --# Link to the "First" page --# available local variables --# url: url to the first page --# current_page: a page object for the currently displayed page --# num_pages: total number of pages --# per_page: number of items to fetch per page --# remote: data-remote -%li - = link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote diff --git a/core/app/views/kaminari/_gap.html.haml b/core/app/views/kaminari/_gap.html.haml deleted file mode 100644 index 51de678..0000000 --- a/core/app/views/kaminari/_gap.html.haml +++ /dev/null @@ -1,8 +0,0 @@ --# Non-link tag that stands for skipped pages... --# available local variables --# current_page: a page object for the currently displayed page --# num_pages: total number of pages --# per_page: number of items to fetch per page --# remote: data-remote -%li.disabled - = raw(t 'views.pagination.truncate') diff --git a/core/app/views/kaminari/_last_page.html.haml b/core/app/views/kaminari/_last_page.html.haml deleted file mode 100644 index c90433c..0000000 --- a/core/app/views/kaminari/_last_page.html.haml +++ /dev/null @@ -1,9 +0,0 @@ --# Link to the "Last" page --# available local variables --# url: url to the last page --# current_page: a page object for the currently displayed page --# num_pages: total number of pages --# per_page: number of items to fetch per page --# remote: data-remote -%li - = link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote} diff --git a/core/app/views/kaminari/_next_page.html.haml b/core/app/views/kaminari/_next_page.html.haml deleted file mode 100644 index ea6cab2..0000000 --- a/core/app/views/kaminari/_next_page.html.haml +++ /dev/null @@ -1,12 +0,0 @@ --# Link to the "Next" page --# available local variables --# url: url to the next page --# current_page: a page object for the currently displayed page --# num_pages: total number of pages --# per_page: number of items to fetch per page --# remote: data-remote -- if current_page.last? - %li.disabled - %span= raw(t 'views.pagination.next') -- else - %li= link_to(raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote) diff --git a/core/app/views/kaminari/_page.html.haml b/core/app/views/kaminari/_page.html.haml deleted file mode 100644 index 2f2f142..0000000 --- a/core/app/views/kaminari/_page.html.haml +++ /dev/null @@ -1,14 +0,0 @@ --# Link showing page number --# available local variables --# page: a page object for "this" page --# url: url to this page --# current_page: a page object for the currently displayed page --# num_pages: total number of pages --# per_page: number of items to fetch per page --# remote: data-remote - -- if page.current? - %li.active - %span= page -- else - %li= link_to(page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil}) diff --git a/core/app/views/kaminari/_paginator.html.haml b/core/app/views/kaminari/_paginator.html.haml deleted file mode 100644 index 79c5b92..0000000 --- a/core/app/views/kaminari/_paginator.html.haml +++ /dev/null @@ -1,19 +0,0 @@ --# The container tag --# available local variables --# current_page: a page object for the currently displayed page --# num_pages: total number of pages --# per_page: number of items to fetch per page --# remote: data-remote --# paginator: the paginator that renders the pagination tags inside -= paginator.render do - .pagination - %ul - -#= first_page_tag unless current_page.first? - = prev_page_tag #unless current_page.first? - - each_page do |page| - - if page.left_outer? || page.right_outer? || page.inside_window? - = page_tag page - - elsif !page.was_truncated? - = gap_tag - = next_page_tag #unless current_page.last? - -#= last_page_tag unless current_page.last? diff --git a/core/app/views/kaminari/_prev_page.html.haml b/core/app/views/kaminari/_prev_page.html.haml deleted file mode 100644 index d274bf4..0000000 --- a/core/app/views/kaminari/_prev_page.html.haml +++ /dev/null @@ -1,12 +0,0 @@ --# Link to the "Previous" page --# available local variables --# url: url to the previous page --# current_page: a page object for the currently displayed page --# num_pages: total number of pages --# per_page: number of items to fetch per page --# remote: data-remote -- if current_page.first? - %li.disabled - %span= raw(t 'views.pagination.previous') -- else - %li= link_to(raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote) diff --git a/core/config/initializers/backtrace_silencers.rb b/core/config/initializers/backtrace_silencers.rb deleted file mode 100644 index 59385cd..0000000 --- a/core/config/initializers/backtrace_silencers.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. -# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } - -# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. -# Rails.backtrace_cleaner.remove_silencers! diff --git a/core/config/initializers/couchrest_model.rb b/core/config/initializers/couchrest_model.rb deleted file mode 100644 index ce4f41a..0000000 --- a/core/config/initializers/couchrest_model.rb +++ /dev/null @@ -1,3 +0,0 @@ -CouchRest::Model::Base.configure do |config| - config.auto_update_design_doc = false -end diff --git a/core/config/initializers/inflections.rb b/core/config/initializers/inflections.rb deleted file mode 100644 index 5d8d9be..0000000 --- a/core/config/initializers/inflections.rb +++ /dev/null @@ -1,15 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new inflection rules using the following format -# (all these examples are active by default): -# ActiveSupport::Inflector.inflections do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' -# inflect.uncountable %w( fish sheep ) -# end -# -# These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections do |inflect| -# inflect.acronym 'RESTful' -# end diff --git a/core/config/initializers/mime_types.rb b/core/config/initializers/mime_types.rb deleted file mode 100644 index 72aca7e..0000000 --- a/core/config/initializers/mime_types.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new mime types for use in respond_to blocks: -# Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone diff --git a/core/config/initializers/simple_form.rb b/core/config/initializers/simple_form.rb deleted file mode 100644 index e3f8d09..0000000 --- a/core/config/initializers/simple_form.rb +++ /dev/null @@ -1,142 +0,0 @@ -# Use this setup block to configure all options available in SimpleForm. -SimpleForm.setup do |config| - # Wrappers are used by the form builder to generate a - # complete input. You can remove any component from the - # wrapper, change the order or even add your own to the - # stack. The options given below are used to wrap the - # whole input. - config.wrappers :default, :class => :input, - :hint_class => :field_with_hint, :error_class => :field_with_errors do |b| - ## Extensions enabled by default - # Any of these extensions can be disabled for a - # given input by passing: `f.input EXTENSION_NAME => false`. - # You can make any of these extensions optional by - # renaming `b.use` to `b.optional`. - - # Determines whether to use HTML5 (:email, :url, ...) - # and required attributes - b.use :html5 - - # Calculates placeholders automatically from I18n - # You can also pass a string as f.input :placeholder => "Placeholder" - b.use :placeholder - - ## Optional extensions - # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup` - # to the input. If so, they will retrieve the values from the model - # if any exists. If you want to enable the lookup for any of those - # extensions by default, you can change `b.optional` to `b.use`. - - # Calculates maxlength from length validations for string inputs - b.optional :maxlength - - # Calculates pattern from format validations for string inputs - b.optional :pattern - - # Calculates min and max from length validations for numeric inputs - b.optional :min_max - - # Calculates readonly automatically from readonly attributes - b.optional :readonly - - ## Inputs - b.use :label_input - b.use :hint, :wrap_with => { :tag => :span, :class => :hint } - b.use :error, :wrap_with => { :tag => :span, :class => :error } - end - - # The default wrapper to be used by the FormBuilder. - config.default_wrapper = :default - - # Define the way to render check boxes / radio buttons with labels. - # Defaults to :nested for bootstrap config. - # :inline => input + label - # :nested => label > input - config.boolean_style = :nested - - # Default class for buttons - config.button_class = 'btn' - - # Method used to tidy up errors. Specify any Rails Array method. - # :first lists the first message for each field. - # Use :to_sentence to list all errors for each field. - # config.error_method = :first - - # Default tag used for error notification helper. - config.error_notification_tag = :div - - # CSS class to add for error notification helper. - config.error_notification_class = 'alert alert-error' - - # ID to add for error notification helper. - # config.error_notification_id = nil - - # Series of attempts to detect a default label method for collection. - # config.collection_label_methods = [ :to_label, :name, :title, :to_s ] - - # Series of attempts to detect a default value method for collection. - # config.collection_value_methods = [ :id, :to_s ] - - # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. - # config.collection_wrapper_tag = nil - - # You can define the class to use on all collection wrappers. Defaulting to none. - # config.collection_wrapper_class = nil - - # You can wrap each item in a collection of radio/check boxes with a tag, - # defaulting to :span. Please note that when using :boolean_style = :nested, - # SimpleForm will force this option to be a label. - # config.item_wrapper_tag = :span - - # You can define a class to use in all item wrappers. Defaulting to none. - # config.item_wrapper_class = nil - - # How the label text should be generated altogether with the required text. - # config.label_text = lambda { |label, required| "#{required} #{label}" } - - # You can define the class to use on all labels. Default is nil. - config.label_class = 'control-label' - - # You can define the class to use on all forms. Default is simple_form. - # config.form_class = :simple_form - - # You can define which elements should obtain additional classes - # config.generate_additional_classes_for = [:wrapper, :label, :input] - - # Whether attributes are required by default (or not). Default is true. - # config.required_by_default = true - - # Tell browsers whether to use default HTML5 validations (novalidate option). - # Default is enabled. - config.browser_validations = false - - # Collection of methods to detect if a file type was given. - # config.file_methods = [ :mounted_as, :file?, :public_filename ] - - # Custom mappings for input types. This should be a hash containing a regexp - # to match as key, and the input type that will be used when the field name - # matches the regexp as value. - # config.input_mappings = { /count/ => :integer } - - # Custom wrappers for input types. This should be a hash containing an input - # type as key and the wrapper that will be used for all inputs with specified type. - # config.wrapper_mappings = { :string => :prepend } - - # Default priority for time_zone inputs. - # config.time_zone_priority = nil - - # Default priority for country inputs. - # config.country_priority = nil - - # Default size for text inputs. - # config.default_input_size = 50 - - # When false, do not use translations for labels. - # config.translate_labels = true - - # Automatically discover new inputs in Rails' autoload path. - # config.inputs_discovery = true - - # Cache SimpleForm inputs discovery - # config.cache_discovery = !Rails.env.development? -end diff --git a/core/config/initializers/simple_form_bootstrap.rb b/core/config/initializers/simple_form_bootstrap.rb deleted file mode 100644 index c949f5e..0000000 --- a/core/config/initializers/simple_form_bootstrap.rb +++ /dev/null @@ -1,57 +0,0 @@ -# Use this setup block to configure all options available in SimpleForm. -SimpleForm.setup do |config| - config.wrappers :bootstrap, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b| - b.use :html5 - b.use :placeholder - b.use :label - b.wrapper :tag => 'div', :class => 'controls' do |ba| - ba.use :input - ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' } - ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' } - end - end - - config.wrappers :prepend, :tag => 'div', :class => "control-group", :error_class => 'error' do |b| - b.use :html5 - b.use :placeholder - b.use :label - b.wrapper :tag => 'div', :class => 'controls' do |input| - input.wrapper :tag => 'div', :class => 'input-prepend' do |prepend| - prepend.use :input - end - input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' } - input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' } - end - end - - config.wrappers :append, :tag => 'div', :class => "control-group", :error_class => 'error' do |b| - b.use :html5 - b.use :placeholder - b.use :label - b.wrapper :tag => 'div', :class => 'controls' do |input| - input.wrapper :tag => 'div', :class => 'input-append' do |append| - append.use :input - end - input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' } - input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' } - end - end - - # - # when you don't want any bootstrap "control-group" or "controls" wrappers. - # - config.wrappers :none, :tag => 'div', :error_class => 'error' do |b| - b.use :html5 - b.use :placeholder - b.use :label - b.use :input - b.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' } - b.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' } - end - - # Wrappers for forms and inputs using the Twitter Bootstrap toolkit. - # Check the Bootstrap docs (http://twitter.github.com/bootstrap) - # to learn about the different styles for forms and inputs, - # buttons and other elements. - config.default_wrapper = :bootstrap -end diff --git a/core/config/initializers/validations.rb b/core/config/initializers/validations.rb deleted file mode 100644 index e8acfbe..0000000 --- a/core/config/initializers/validations.rb +++ /dev/null @@ -1,4 +0,0 @@ -# In case we use a different ORM at some point -VALIDATION_FAILED = CouchRest::Model::Errors::Validations -RECORD_NOT_FOUND = CouchRest::Model::DocumentNotFound -RESOURCE_NOT_FOUND = RestClient::ResourceNotFound diff --git a/core/config/initializers/wrap_parameters.rb b/core/config/initializers/wrap_parameters.rb deleted file mode 100644 index 5fe232e..0000000 --- a/core/config/initializers/wrap_parameters.rb +++ /dev/null @@ -1,10 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains settings for ActionController::ParamsWrapper which -# is enabled by default. - -# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. -ActiveSupport.on_load(:action_controller) do - wrap_parameters :format => [:json] -end - diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml deleted file mode 100644 index bb510d4..0000000 --- a/core/config/locales/en.yml +++ /dev/null @@ -1,41 +0,0 @@ -en: - no_such_thing: "No such %{thing}." - thing_was_successfully_created: "%{thing} was successfully created." - create_thing: "Create %{thing}" - - overview: "Overview" - user_control_panel: "user control panel" - - created: "Created" - created_by_on: "Created by %{user} on %{time}" - updated: "Updated" - - none: "None" - unknown: "Unknown" - admin: "Admin" - anonymous: "Anonymous" - save: "Save" - add: "Add" - remove: "Remove" - changes_saved: "Changes saved successfully." - are_you_sure: "Are you sure? This change cannot be undone." - - download_client: "Download Bitmask" - client_info: "The Bitmask application allows you to use %{provider} services." - all_downloads_info: "It is available for %{clients}." - other_downloads_info: "Bitmask is also available for %{clients}." - login_info: "Log in to change your account settings, create support tickets, and manage payments." - signup_info: "Sign up for a new user account via this website (it is better if you use the Bitmask application to sign up, but this website works too)." - welcome: "Welcome to %{provider}." - get_help: "Get Help" - help_info: "Can't login? Create a new support ticket anonymously." - example_email: 'user@domain.org' - os: - linux32: "Linux (32 bit)" - linux64: "Linux (64 bit)" - linux: "GNU/Linux" - windows: "Windows" - android: "Android" - osx: "Mac OS" - other: "(not available for your OS)" - diff --git a/core/config/locales/simple_form.en.yml b/core/config/locales/simple_form.en.yml deleted file mode 100644 index 0df11fe..0000000 --- a/core/config/locales/simple_form.en.yml +++ /dev/null @@ -1,26 +0,0 @@ -en: - simple_form: - "yes": 'Yes' - "no": 'No' - required: - text: 'required' - mark: '*' - # You can uncomment the line below if you need to overwrite the whole required html. - # When using html, text and mark won't be used. - # html: '*' - error_notification: - default_message: "Please review the problems below:" - # Labels and hints examples - # labels: - # defaults: - # password: 'Password' - # user: - # new: - # email: 'E-mail to sign in.' - # edit: - # email: 'E-mail.' - # hints: - # defaults: - # username: 'User name to sign in.' - # password: 'No special characters, please.' - diff --git a/core/config/routes.rb b/core/config/routes.rb deleted file mode 100644 index 1daf9a4..0000000 --- a/core/config/routes.rb +++ /dev/null @@ -1,2 +0,0 @@ -Rails.application.routes.draw do -end diff --git a/core/leap_web_core.gemspec b/core/leap_web_core.gemspec deleted file mode 100644 index 7ca4d90..0000000 --- a/core/leap_web_core.gemspec +++ /dev/null @@ -1,25 +0,0 @@ -$:.push File.expand_path("../lib", __FILE__) - -require File.expand_path('../../lib/leap_web/version.rb', __FILE__) - -# Describe your gem and declare its dependencies: -Gem::Specification.new do |s| - s.name = "leap_web_core" - s.version = LeapWeb::VERSION - s.authors = ["Azul"] - s.email = ["azul@leap.se"] - s.homepage = "http://www.leap.se" - s.summary = "Web interface to the leap platform - core engine" - s.description = "This web interface provides various administrative tools for the leap platform through plugins. Currently it manages user accounts and certificates." - - s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "Readme.md"] - s.test_files = Dir["test/**/*"] - - s.add_dependency "rails", "~> 3.2.11" - - s.add_dependency "couchrest", "~> 1.1.3" - s.add_dependency "couchrest_model", "~> 2.0.0" - s.add_dependency "couchrest_session_store", "~> 0.2.4" - - s.add_dependency "json" -end diff --git a/core/lib/extensions/couchrest.rb b/core/lib/extensions/couchrest.rb deleted file mode 100644 index a9a195e..0000000 --- a/core/lib/extensions/couchrest.rb +++ /dev/null @@ -1,95 +0,0 @@ -module CouchRest - module Model - module Designs - - class View - - # so we can called Ticket.method.descending or Ticket.method.ascending - def ascending - self - end - end - - class DesignMapper - def load_views(dir) - Dir.glob("#{dir}/*.js") do |js| - name = File.basename(js, '.js') - file = File.open(js, 'r') - view name.to_sym, - :map => file.read, - :reduce => "function(key, values, rereduce) { return sum(values); }" - end - end - end - end - - module Connection - - module ClassMethods - - def use_database(db) - @database = prepare_database(db) - rescue RestClient::Exception, - Errno::EHOSTUNREACH, - Errno::ECONNREFUSED => e - message = "Could not connect to couch database #{db} due to #{e.to_s}" - Rails.logger.warn message - raise e.class.new(message) if APP_CONFIG[:reraise_errors] - end - end - - end - - module Utils - module Migrate - def self.load_all_models_with_engines - self.load_all_models_without_engines - return unless defined?(Rails) - Dir[Rails.root + '*/app/models/**/*.rb'].each do |path| - require path - end - end - - class << self - alias_method_chain :load_all_models, :engines - end - - def dump_all_models - prepare_directory - find_models.each do |model| - model.design_docs.each do |design| - dump_design(model, design) - end - end - end - - protected - - def dump_design(model, design) - dir = prepare_directory model.name.tableize - filename = design.id.sub('_design/','') + '.json' - puts dir + filename - design.checksum - File.open(dir + filename, "w") do |file| - file.write(JSON.pretty_generate(design.to_hash)) - end - end - - def prepare_directory(dir = '') - dir = Rails.root + 'tmp' + 'designs' + dir - Dir.mkdir(dir) unless Dir.exists?(dir) - return dir - end - - end - end - - end - - class ModelRailtie - config.action_dispatch.rescue_responses.merge!( - 'CouchRest::Model::DocumentNotFound' => :not_found, - 'RestClient::ResourceNotFound' => :not_found - ) - end -end diff --git a/core/lib/extensions/testing.rb b/core/lib/extensions/testing.rb deleted file mode 100644 index 8f7e73c..0000000 --- a/core/lib/extensions/testing.rb +++ /dev/null @@ -1,48 +0,0 @@ -module LeapWebCore - module AssertResponses - - # response that works with different TestCases: - # ActionController::TestCase has @response - # ActionDispatch::IntegrationTest has @response - # Rack::Test::Methods defines last_response - def get_response - @response || last_response - end - - def assert_attachement_filename(name) - assert_equal %Q(attachment; filename="#{name}"), - get_response.headers["Content-Disposition"] - end - - def json_response - response = JSON.parse(get_response.body) - response.respond_to?(:with_indifferent_access) ? - response.with_indifferent_access : - response - end - - def assert_json_response(object) - assert_equal 'application/json', - get_response.content_type.to_s.split(';').first - if object.is_a? Hash - object.stringify_keys! if object.respond_to? :stringify_keys! - assert_equal object, json_response - else - assert_equal object.to_json, get_response.body - end - end - - def assert_json_error(object) - object.stringify_keys! if object.respond_to? :stringify_keys! - assert_json_response :errors => object - end - end -end - -class ::ActionController::TestCase - include LeapWebCore::AssertResponses -end - -class ::ActionDispatch::IntegrationTest - include LeapWebCore::AssertResponses -end diff --git a/core/lib/leap_web_core.rb b/core/lib/leap_web_core.rb deleted file mode 100644 index a58d140..0000000 --- a/core/lib/leap_web_core.rb +++ /dev/null @@ -1,14 +0,0 @@ -require "rails" - -require "couchrest" -require "couchrest_model" -require "couchrest_session_store" - -require "json" - -require "extensions/testing" -require "extensions/couchrest" -require "leap_web_core/engine" - -module LeapWebCore -end diff --git a/core/lib/leap_web_core/dependencies.rb b/core/lib/leap_web_core/dependencies.rb deleted file mode 100644 index 877e3d1..0000000 --- a/core/lib/leap_web_core/dependencies.rb +++ /dev/null @@ -1,40 +0,0 @@ -module LeapWebCore - class Dependencies - UI_DEV = { - "haml-rails" => "~> 0.3.4", - "sass-rails" => "~> 3.2.5", - "coffee-rails" => "~> 3.2.2", - "uglifier" => "~> 1.2.7" - } - - UI = { - "haml" => "~> 3.1.7", - "jquery-rails" => nil, - "simple_form" => nil, - "bootswatch-rails", "~> 0.5.0" - } - - def self.require_ui_gems - UI.keys.each {|dep| require dep} - if Rails.env == "development" - # This will be run in the app including plugins that run it. - # However not all development_dependencies might be present. - # So we better only require those that are. - available = Bundler.definition.specs.map(&:name) - gems_to_require = available & UI_DEV.keys - gems_to_require.each {|dep| require dep} - end - end - - def self.add_ui_gems_to_spec(spec) - UI.each do |dep, version| - spec.add_dependency dep, version - end - - UI_DEV.each do |dep, version| - spec.add_development_dependency dep, version - end - end - - end -end diff --git a/core/lib/leap_web_core/engine.rb b/core/lib/leap_web_core/engine.rb deleted file mode 100644 index 940b5e2..0000000 --- a/core/lib/leap_web_core/engine.rb +++ /dev/null @@ -1,9 +0,0 @@ -# thou shall require all your dependencies in an engine. -require "couchrest" -require "couchrest_model" - -module LeapWebCore - class Engine < ::Rails::Engine - - end -end diff --git a/core/lib/leap_web_core/ui_dependencies.rb b/core/lib/leap_web_core/ui_dependencies.rb deleted file mode 100644 index 2daee37..0000000 --- a/core/lib/leap_web_core/ui_dependencies.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "haml" -require "jquery-rails" -require "simple_form" -require "bootswatch-rails" - -if Rails.env == "development" - require "haml-rails" - require "sass-rails" - require "coffee-rails" - require "uglifier" -end diff --git a/core/lib/tasks/leap_web_core_tasks.rake b/core/lib/tasks/leap_web_core_tasks.rake deleted file mode 100644 index ec6abac..0000000 --- a/core/lib/tasks/leap_web_core_tasks.rake +++ /dev/null @@ -1,25 +0,0 @@ -namespace :couchrest do - - desc "Dump all the design docs found in each model" - task :dump => :environment do - CouchRest::Model::Utils::Migrate.load_all_models - CouchRest::Model::Utils::Migrate.dump_all_models - end -end - -namespace :cleanup do - - desc "Cleanup all expired session documents" - task :sessions => :environment do - # make sure this is the same as in - # config/initializers/session_store.rb - store = CouchRest::Session::Store.new expire_after: 1800 - store.cleanup(store.expired) - end - - desc "Cleanup all expired tokens" - task :tokens => :environment do - Token.destroy_all_expired - end -end - diff --git a/core/script/rails b/core/script/rails deleted file mode 100755 index c2ad538..0000000 --- a/core/script/rails +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby1.8 -# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. - -ENGINE_ROOT = File.expand_path('../..', __FILE__) -ENGINE_PATH = File.expand_path('../../lib/leap_web_core/engine', __FILE__) - -require 'rails/all' -require 'rails/engine/commands' diff --git a/core/test/support/browser_integration_test.rb b/core/test/support/browser_integration_test.rb deleted file mode 100644 index 2885c3a..0000000 --- a/core/test/support/browser_integration_test.rb +++ /dev/null @@ -1,81 +0,0 @@ -# -# BrowserIntegrationTest -# -# Use this class for capybara based integration tests for the ui. -# - -class BrowserIntegrationTest < ActionDispatch::IntegrationTest - - CONFIG_RU = (Rails.root + 'config.ru').to_s - OUTER_APP = Rack::Builder.parse_file(CONFIG_RU).first - - require 'capybara/poltergeist' - - Capybara.register_driver :rack_test do |app| - Capybara::RackTest::Driver.new(app) - end - - Capybara.register_driver :poltergeist do |app| - Capybara::Poltergeist::Driver.new(app) - end - - # this is integration testing. So let's make the whole - # rack stack available... - Capybara.app = OUTER_APP - Capybara.run_server = true - Capybara.app_host = 'http://lvh.me:3003' - Capybara.server_port = 3003 - Capybara.javascript_driver = :poltergeist - Capybara.default_wait_time = 5 - - - # Make the Capybara DSL available - include Capybara::DSL - - setup do - Capybara.current_driver = Capybara.javascript_driver - page.driver.add_headers 'ACCEPT-LANGUAGE' => 'en-EN' - end - - teardown do - Capybara.reset_sessions! # Forget the (simulated) browser state - Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver - end - - def submit_signup(username = nil, password = nil) - username ||= "test_#{SecureRandom.urlsafe_base64}".downcase - password ||= SecureRandom.base64 - visit '/users/new' - fill_in 'Username', with: username - fill_in 'Password', with: password - fill_in 'Password confirmation', with: password - click_on 'Sign Up' - return username, password - end - - add_teardown_hook do |testcase| - unless testcase.passed? - testcase.save_state - end - end - - def save_state - page.save_screenshot screenshot_path - File.open(logfile_path, 'w') do |test_log| - test_log.puts self.class.name - test_log.puts "=========================" - test_log.puts __name__ - test_log.puts Time.now - test_log.puts current_path - test_log.puts page.status_code - test_log.puts page.response_headers - test_log.puts "page.html" - test_log.puts "------------------------" - test_log.puts page.html - test_log.puts "server log" - test_log.puts "------------------------" - test_log.puts `tail log/test.log -n 200` - end - end - -end diff --git a/core/test/support/rack_test.rb b/core/test/support/rack_test.rb deleted file mode 100644 index 2d8e5c4..0000000 --- a/core/test/support/rack_test.rb +++ /dev/null @@ -1,37 +0,0 @@ -class RackTest < ActiveSupport::TestCase - include Rack::Test::Methods - include Warden::Test::Helpers - include LeapWebCore::AssertResponses - - CONFIG_RU = (Rails.root + 'config.ru').to_s - OUTER_APP = Rack::Builder.parse_file(CONFIG_RU).first - - def app - OUTER_APP - end - - def assert_access_denied - assert_json_response('error' => I18n.t(:not_authorized)) - assert_response :unprocessable_entity - end - - # inspired by rails 4 - # -> actionpack/lib/action_dispatch/testing/assertions/response.rb - def assert_response(type, message = nil) - # RackTest does not know @response - response_code = last_response.status - message ||= "Expected response to be a <#{type}>, but was <#{response_code}>" - - if Symbol === type - if [:success, :missing, :redirect, :error].include?(type) - assert last_response.send("#{type}?"), message - else - code = Rack::Utils::SYMBOL_TO_STATUS_CODE[type] - assert_equal code, response_code, message - end - else - assert_equal type, response_code, message - end - end - -end diff --git a/core/test/support/with_config_helper.rb b/core/test/support/with_config_helper.rb deleted file mode 100644 index 65eb7bc..0000000 --- a/core/test/support/with_config_helper.rb +++ /dev/null @@ -1,16 +0,0 @@ -module WithConfigHelper - extend ActiveSupport::Concern - - def with_config(options) - old_config = APP_CONFIG.dup - APP_CONFIG.merge! options - yield - ensure - APP_CONFIG.replace old_config - end - -end - -class ActiveSupport::TestCase - include WithConfigHelper -end -- cgit v1.2.3