[devdocsgjs/wip/andyholmes/upstream-merge] icons: override get_items() in sprites.thor to return gnome icons
- From: Andy Holmes <andyholmes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devdocsgjs/wip/andyholmes/upstream-merge] icons: override get_items() in sprites.thor to return gnome icons
- Date: Fri, 8 Apr 2022 08:28:13 +0000 (UTC)
commit 82efda6113a7854f146a86f5166b473d7413dd23
Author: Andy Holmes <andrew g r holmes gmail com>
Date: Fri Apr 8 01:23:26 2022 -0700
icons: override get_items() in sprites.thor to return gnome icons
In upstream DevDocs the static icons SCSS file was replaced with a
Ruby template that automagically computes icon offsets in the sprites.
Remove our statically generated icon sprites and replace them with a
JSON file that maps docs to icon names. Then override the `get_icons()`
method in `sprites.thor` to return the proper icons.
This results in a lot of redundant icon sprites, but requires less
manual work and makes all the other icon related styles function.
assets/images/gnome-icons.json | 67 +++++++++++++++++++++++++++++++++++++++
assets/images/gnome-icons.png | Bin 8548 -> 0 bytes
assets/images/gnome-icons 2x png | Bin 24676 -> 0 bytes
lib/tasks/sprites.thor | 23 ++++++++++++++
4 files changed, 90 insertions(+)
---
diff --git a/assets/images/gnome-icons.json b/assets/images/gnome-icons.json
new file mode 100644
index 00000000..0f306d34
--- /dev/null
+++ b/assets/images/gnome-icons.json
@@ -0,0 +1,67 @@
+{
+ "appstream": [
+ "appstreamglib\\d+"
+ ],
+ "adwaita": [
+ "adw1"
+ ],
+ "cairo": [
+ "cairo10"
+ ],
+ "clutter": [
+ "cally\\d+",
+ "clutter\\d+",
+ "clutterx11\\d+",
+ "cogl\\d+",
+ "coglpango\\d+"
+ ],
+ "evince": [
+ "evincedocument\\d+",
+ "evinceview\\d+"
+ ],
+ "evolution": [
+ "ecal20",
+ "camel12",
+ "ebook[a-z]*\\d+",
+ "edata[a-z]*\\d+"
+ ],
+ "generic": [
+ "dbus10",
+ "fontconfig20",
+ "freetype220",
+ "gl10",
+ "networkmanager10",
+ "nm10",
+ "nmclient10",
+ "polkit[a-z]*\\d+",
+ "telepathyglib012",
+ "win3210"
+ ],
+ "gnome": [
+ "mutter\\d+",
+ "xdp\\d+"
+ ],
+ "goa": [
+ "goa\\d+"
+ ],
+ "gstreamer": [
+ "gst[a-z]*\\d+"
+ ],
+ "gtk": [
+ "gdk\\d+",
+ "gdkx11\\d+",
+ "gsk\\d+",
+ "gtk\\d+"
+ ],
+ "ubuntu": [
+ "appindicator\\d+",
+ "dbusmenu\\d+"
+ ],
+ "webkit": [
+ "javascriptcore\\d+",
+ "webkit\\d+",
+ "webkit2webextension\\d+"
+ ],
+ "x": [
+ ]
+}
diff --git a/lib/tasks/sprites.thor b/lib/tasks/sprites.thor
index fb1b39aa..a7fee9d5 100644
--- a/lib/tasks/sprites.thor
+++ b/lib/tasks/sprites.thor
@@ -82,6 +82,29 @@ class SpritesCLI < Thor
end
end
+ # Redefine to avoid merge conflicts
+ def get_items
+ manifest = JSON.parse(File.read('assets/images/gnome-icons.json'))
+
+ icons = {}
+ manifest.map do |icon, patterns|
+ patterns.map {|pattern| icons[Regexp.new(pattern)] = icon}
+ end
+
+ items = Docs.all.map do |doc|
+ slug = doc.slug.split('~')[0]
+ icon = icons.detect {|key,value| key.match(slug)}
+ name = icon ? icon[1] : 'gnome'
+ base_path = "public/icons/docs/#{name}"
+ {
+ :type => slug,
+ :path_16 => "#{base_path}/16.png",
+ :path_32 => "#{base_path}/16 2x png",
+ :has_icons => true
+ }
+ end
+ end
+
def get_icon(path, max_size)
icon = ChunkyPNG::Image.from_file(path)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]