From 16e672b9d893a7d5b7ecc6b4901eb420c45a2f80 Mon Sep 17 00:00:00 2001 From: Luka Murn Date: Mon, 10 Jul 2017 09:26:35 +0200 Subject: [PATCH 1/2] Add VERSION file where the sciNote Core version is stored --- VERSION | 1 + app/controllers/wopi_controller.rb | 2 +- app/views/shared/_navigation.html.erb | 2 +- config/application.rb | 3 +++ config/initializers/constants.rb | 3 --- 5 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..6f165bc1b --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.12.1 \ No newline at end of file diff --git a/app/controllers/wopi_controller.rb b/app/controllers/wopi_controller.rb index dd7b30192..b548489c2 100644 --- a/app/controllers/wopi_controller.rb +++ b/app/controllers/wopi_controller.rb @@ -82,7 +82,7 @@ class WopiController < ActionController::Base } response.headers['X-WOPI-HostEndpoint'] = ENV['WOPI_ENDPOINT_URL'] response.headers['X-WOPI-MachineName'] = ENV['WOPI_ENDPOINT_URL'] - response.headers['X-WOPI-ServerVersion'] = Constants::APP_VERSION + response.headers['X-WOPI-ServerVersion'] = Scinote::Application::VERSION render json: msg and return end diff --git a/app/views/shared/_navigation.html.erb b/app/views/shared/_navigation.html.erb index ff7598c0f..1c9affa91 100644 --- a/app/views/shared/_navigation.html.erb +++ b/app/views/shared/_navigation.html.erb @@ -19,7 +19,7 @@ <% if show_version %> <%= image_tag('/images/logo.png', class: 'with-version', id: 'logo') %> - <%= Constants::APP_VERSION %> + <%= Scinote::Application::VERSION %> <% else %> <%= image_tag('/images/logo.png', id: 'logo') %> diff --git a/config/application.rb b/config/application.rb index 2260cbeeb..91f89022a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -37,5 +37,8 @@ module Scinote csv: 'text/plain', wopitest: ['text/plain', 'inode/x-empty'] } + + # sciNote Core Application version + VERSION = File.read(Rails.root.join('VERSION')).strip.freeze end end diff --git a/config/initializers/constants.rb b/config/initializers/constants.rb index f705420b5..1bb0e2bc2 100644 --- a/config/initializers/constants.rb +++ b/config/initializers/constants.rb @@ -196,9 +196,6 @@ class Constants # Other #============================================================================= - # Application version - APP_VERSION = '1.12.1'.freeze - TEXT_EXTRACT_FILE_TYPES = [ 'application/pdf', 'application/rtf', From 3e80f761b8692637c9b75c4d263dfffb96cafe0f Mon Sep 17 00:00:00 2001 From: Luka Murn Date: Mon, 10 Jul 2017 15:27:50 +0200 Subject: [PATCH 2/2] Add "about" modal, prepare hooks, VERSION system for addons Also the addon generator is fixed so it properly creates VERSION file for new addons. --- .../javascripts/sitewide/about_modal.js | 9 ++++++ app/helpers/addons_helper.rb | 8 ++++++ app/views/layouts/application.html.erb | 3 ++ app/views/shared/_about_modal.html.erb | 28 +++++++++++++++++++ app/views/shared/_navigation.html.erb | 6 ++++ config/locales/en.yml | 6 ++++ lib/generators/addon/addon_generator.rb | 7 ++++- 7 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/sitewide/about_modal.js create mode 100644 app/helpers/addons_helper.rb create mode 100644 app/views/shared/_about_modal.html.erb diff --git a/app/assets/javascripts/sitewide/about_modal.js b/app/assets/javascripts/sitewide/about_modal.js new file mode 100644 index 000000000..ca558059a --- /dev/null +++ b/app/assets/javascripts/sitewide/about_modal.js @@ -0,0 +1,9 @@ +(function() { + 'use strict'; + + $(document).ready(function() { + $("[data-trigger='about-modal']").on('click', function() { + $('[data-role=about-modal]').modal('show'); + }); + }); +})(); diff --git a/app/helpers/addons_helper.rb b/app/helpers/addons_helper.rb new file mode 100644 index 000000000..150af4976 --- /dev/null +++ b/app/helpers/addons_helper.rb @@ -0,0 +1,8 @@ +module AddonsHelper + def list_all_addons + Rails::Engine + .subclasses + .select { |c| c.name.start_with?('Scinote') } + .map(&:parent) + end +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 4b7027acf..a508c5f48 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -45,6 +45,9 @@ + + <%= render "shared/about_modal" %> + <%= render "shared/navigation" %>
diff --git a/app/views/shared/_about_modal.html.erb b/app/views/shared/_about_modal.html.erb new file mode 100644 index 000000000..3d2deeb92 --- /dev/null +++ b/app/views/shared/_about_modal.html.erb @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/app/views/shared/_navigation.html.erb b/app/views/shared/_navigation.html.erb index 1c9affa91..17f3a5281 100644 --- a/app/views/shared/_navigation.html.erb +++ b/app/views/shared/_navigation.html.erb @@ -234,6 +234,12 @@
  • <%= link_to t('nav.help.contact'), Constants::CONTACT_URL, target: "_blank" %>
  • + +
  • + <%= link_to '#', data: { trigger: 'about-modal' } do %> + <%= t('nav.help.about') %> + <% end %> +
  • diff --git a/config/locales/en.yml b/config/locales/en.yml index 6dce7f8ec..fa31517ed 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -72,6 +72,7 @@ en: support: "Customer support" premium: "Premium" contact: "Contact us" + about: "About sciNote" activities: none: "No activities!" label: @@ -87,6 +88,11 @@ en: info: "Info" account: "Account" + about: + modal_title: "About sciNote" + core_version: "sciNote core version" + addon_versions: "Addon versions" + sidebar: title: "Navigation" no_module_group: "No workflow" diff --git a/lib/generators/addon/addon_generator.rb b/lib/generators/addon/addon_generator.rb index 5ef5a0892..8b4c51376 100644 --- a/lib/generators/addon/addon_generator.rb +++ b/lib/generators/addon/addon_generator.rb @@ -114,12 +114,16 @@ class AddonGenerator < Rails::Generators::NamedBase gsub_file(file_path, '${ADDON_NAME}', @addon_name) # lib/.../version.rb + dots = @modules.map { '/..' }.join create_file( "addons/#{@addon_name}/lib/" \ "#{@folders_path}/version.rb" ) do embed_into_modules do - "VERSION = '0.0.1'.freeze\n" + "VERSION =\n" \ + " File.read(\n" \ + " \"\#{File.dirname(__FILE__)}#{dots}/../VERSION\"\n" \ + " ).strip.freeze\n" end end @@ -182,6 +186,7 @@ class AddonGenerator < Rails::Generators::NamedBase gsub_file(file_path, '${FULL_UNDERSCORE_NAME}', @full_underscore_name) gsub_file(file_path, '${NAME}', name) gsub_file(file_path, '${FOLDERS_PATH}', @folders_path) + create_file("addons/#{@addon_name}/VERSION") { '0.0.1' } # Rakefile file_path = "addons/#{@addon_name}/Rakefile"