Project

General

Profile

Patch #41725 » 0001-Add-svg-icons-sample-view.patch

Takashi Kato, 2024-11-10 13:49

View differences:

app/assets/stylesheets/application.css
2141 2141
	display: inline;
2142 2142
	opacity: 1;
2143 2143
}
2144

  
2145
.svg-icon-sample {
2146
  display: flex;
2147
  flex-wrap: wrap;
2148
  list-style: none;
2149
  max-width: 1000px
2150
}
2151

  
2152
.svg-icon-sample li {
2153
  padding: 0.5rem;
2154
  width: calc(200px - 0.5rem * 2);
2155
}
app/controllers/svg_icons_controller.rb
1
# frozen_string_literal: true
2

  
3
# Redmine - project management software
4
# Copyright (C) 2006-  Jean-Philippe Lang
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19

  
20
class SvgIconsController < ApplicationController
21
  self.main_menu = false
22

  
23
  def index
24
    @icons_mapping = YAML.load_file(Rails.root.join('config/icon_source.yml'))
25
  end
26
end
app/helpers/svg_icon_helper.rb
1
# frozen_string_literal: true
2

  
3
# Redmine - project management software
4
# Copyright (C) 2006-  Jean-Philippe Lang
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19

  
20
module SvgIconHelper
21
end
app/views/svg_icons/index.html.erb
1
<ul class="svg-icon-sample">
2
  <% @icons_mapping.sort{|a,b| a['name'] <=> b['name']}.each do |icon| %>
3
    <li><%= sprite_icon icon['name'], icon['name'] %></li>
4
  <% end %>
5
</ul>
config/icon_source.yml
20 20
#   - name: destination icon name
21 21
#     svg: source icon name from Github repository
22 22
#     style: outline (default) or filled
23
#
24
# To see the appearance of all icons, visit /rails/info/svg_icons
23 25

  
24 26
- name: edit
25 27
  svg: pencil
config/routes.rb
409 409

  
410 410
  get 'robots.:format', :to => 'welcome#robots', :constraints => {:format => 'txt'}
411 411

  
412
  if Rails.env.development?
413
    get 'rails/info/svg_icons', :to => 'svg_icons#index'
414
  end
415

  
412 416
  get 'help/wiki_syntax/(:type)', :controller => 'help', :action => 'show_wiki_syntax', :constraints => { :type => /detailed/ }, :as => 'help_wiki_syntax'
413 417
  get 'help/code_highlighting', :controller => 'help', :action => 'show_code_highlighting',  :as => 'help_code_highlighting'
414 418

  
(1-1/2)