From 47bfd69f338c7c7899c13e8468ef4a8cb950b97b Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sat, 30 Aug 2025 07:45:27 +0000 Subject: [PATCH] Add svg icons sample view accessible at /rails/info/svg_icons in development mode (#41725). Patch by Takashi Kato (user:tohosaku). git-svn-id: https://svn.redmine.org/redmine/trunk@23934 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/assets/stylesheets/application.css | 12 ++++++++++++ app/controllers/svg_icons_controller.rb | 26 +++++++++++++++++++++++++ app/helpers/svg_icon_helper.rb | 21 ++++++++++++++++++++ app/views/svg_icons/index.html.erb | 5 +++++ config/icon_source.yml | 2 ++ config/routes.rb | 4 ++++ 6 files changed, 70 insertions(+) create mode 100644 app/controllers/svg_icons_controller.rb create mode 100644 app/helpers/svg_icon_helper.rb create mode 100644 app/views/svg_icons/index.html.erb diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 568bed2bc..08ad8bac4 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -2529,3 +2529,15 @@ th[role=columnheader]:not(.no-sort):hover:after { display: inline; opacity: 1; } + +.svg-icon-sample { + display: flex; + flex-wrap: wrap; + list-style: none; + max-width: 1000px +} + +.svg-icon-sample li { + padding: 0.5rem; + width: calc(200px - 0.5rem * 2); +} diff --git a/app/controllers/svg_icons_controller.rb b/app/controllers/svg_icons_controller.rb new file mode 100644 index 000000000..43bf4d9e3 --- /dev/null +++ b/app/controllers/svg_icons_controller.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +# Redmine - project management software +# Copyright (C) 2006- Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class SvgIconsController < ApplicationController + self.main_menu = false + + def index + @icons_mapping = YAML.load_file(Rails.root.join('config/icon_source.yml')) + end +end diff --git a/app/helpers/svg_icon_helper.rb b/app/helpers/svg_icon_helper.rb new file mode 100644 index 000000000..7addb397c --- /dev/null +++ b/app/helpers/svg_icon_helper.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +# Redmine - project management software +# Copyright (C) 2006- Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +module SvgIconHelper +end diff --git a/app/views/svg_icons/index.html.erb b/app/views/svg_icons/index.html.erb new file mode 100644 index 000000000..e7459b1e2 --- /dev/null +++ b/app/views/svg_icons/index.html.erb @@ -0,0 +1,5 @@ + diff --git a/config/icon_source.yml b/config/icon_source.yml index 64f0a1d8c..b6349461f 100644 --- a/config/icon_source.yml +++ b/config/icon_source.yml @@ -20,6 +20,8 @@ # - name: destination icon name # svg: source icon name from Github repository # style: outline (default) or filled +# +# To see the appearance of all icons, visit /rails/info/svg_icons - name: edit svg: pencil diff --git a/config/routes.rb b/config/routes.rb index 52c95c6a4..7a683c938 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -416,6 +416,10 @@ Rails.application.routes.draw do get 'robots.:format', :to => 'welcome#robots', :constraints => {:format => 'txt'} + if Rails.env.development? + get 'rails/info/svg_icons', :to => 'svg_icons#index' + end + get 'help/wiki_syntax/(:type)', :controller => 'help', :action => 'show_wiki_syntax', :constraints => { :type => /detailed/ }, :as => 'help_wiki_syntax' get 'help/code_highlighting', :controller => 'help', :action => 'show_code_highlighting', :as => 'help_code_highlighting'