[devdocsgjs/main: 450/1867] Fix merge conflicts
- From: Andy Holmes <andyholmes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devdocsgjs/main: 450/1867] Fix merge conflicts
- Date: Fri, 19 Nov 2021 23:47:15 +0000 (UTC)
commit bf53a00ca986ceba0fbc0e49b1d8f8441b014fb6
Merge: cdd86a8f e8d52c9c
Author: Jasper van Merle <jaspervmerle gmail com>
Date: Sun Oct 21 19:04:30 2018 +0200
Fix merge conflicts
.travis.yml | 3 +
Gemfile | 1 +
Gemfile.lock | 56 +++++-----
README.md | 12 +-
assets/javascripts/app/app.coffee | 7 +-
assets/javascripts/lib/page.coffee | 2 +-
assets/javascripts/news.json | 3 +
assets/javascripts/templates/error_tmpl.coffee | 11 +-
.../javascripts/templates/pages/about_tmpl.coffee | 10 ++
.../templates/pages/root_tmpl.coffee.erb | 11 --
assets/javascripts/views/content/root_page.coffee | 4 -
.../javascripts/views/content/settings_page.coffee | 7 +-
assets/stylesheets/application-dark.css.scss | 107 ------------------
assets/stylesheets/application.css.scss | 4 +-
assets/stylesheets/components/_app.scss | 10 +-
assets/stylesheets/components/_content.scss | 59 +++++-----
assets/stylesheets/components/_fail.scss | 4 +-
assets/stylesheets/components/_header.scss | 60 +++++-----
assets/stylesheets/components/_mobile.scss | 4 +-
assets/stylesheets/components/_notice.scss | 10 +-
assets/stylesheets/components/_notif.scss | 24 ++--
assets/stylesheets/components/_page.scss | 8 +-
assets/stylesheets/components/_path.scss | 12 +-
assets/stylesheets/components/_prism.scss | 57 +++++-----
assets/stylesheets/components/_settings.scss | 24 ++--
assets/stylesheets/components/_sidebar.scss | 76 +++++++------
assets/stylesheets/global/_base.scss | 68 ++++++------
assets/stylesheets/global/_classes.scss | 49 ++++-----
assets/stylesheets/global/_icons.scss.erb | 4 +-
assets/stylesheets/global/_mixins.scss | 6 +
assets/stylesheets/global/_print.scss | 4 +-
assets/stylesheets/global/_variables-dark.scss | 122 +++++++++------------
assets/stylesheets/global/_variables-light.scss | 76 +++++++++++++
assets/stylesheets/global/_variables.scss | 107 +++++-------------
assets/stylesheets/pages/_angularjs.scss | 2 +-
assets/stylesheets/pages/_async.scss | 4 +-
assets/stylesheets/pages/_bash.scss | 2 +-
assets/stylesheets/pages/_bootstrap.scss | 2 +-
assets/stylesheets/pages/_c.scss | 4 +-
assets/stylesheets/pages/_clojure.scss | 2 +-
assets/stylesheets/pages/_d.scss | 6 +-
assets/stylesheets/pages/_dart.scss | 2 +-
assets/stylesheets/pages/_dojo.scss | 2 +-
assets/stylesheets/pages/_ember.scss | 4 +-
assets/stylesheets/pages/_erlang.scss | 2 +-
assets/stylesheets/pages/_jquery.scss | 4 +-
assets/stylesheets/pages/_love.scss | 4 +-
assets/stylesheets/pages/_mdn.scss | 6 +-
assets/stylesheets/pages/_meteor.scss | 4 +-
assets/stylesheets/pages/_npm.scss | 2 +-
assets/stylesheets/pages/_phalcon.scss | 2 +-
assets/stylesheets/pages/_php.scss | 4 +-
assets/stylesheets/pages/_postgres.scss | 2 +-
assets/stylesheets/pages/_qt.scss | 2 +-
assets/stylesheets/pages/_rdoc.scss | 8 +-
assets/stylesheets/pages/_react_native.scss | 2 +-
assets/stylesheets/pages/_redis.scss | 4 +-
assets/stylesheets/pages/_rfc.scss | 2 +-
assets/stylesheets/pages/_rust.scss | 11 +-
assets/stylesheets/pages/_simple.scss | 32 +-----
assets/stylesheets/pages/_sphinx.scss | 4 +-
assets/stylesheets/pages/_sphinx_simple.scss | 2 +-
assets/stylesheets/pages/_support_tables.scss | 2 +-
assets/stylesheets/pages/_yard.scss | 2 +-
assets/stylesheets/pages/_yii.scss | 2 +-
lib/app.rb | 18 +--
lib/docs/filters/elixir/clean_html.rb | 1 +
lib/docs/filters/express/clean_html.rb | 5 +
lib/docs/filters/handlebars/clean_html.rb | 44 ++++++++
lib/docs/filters/handlebars/entries.rb | 19 ++++
lib/docs/filters/puppeteer/clean_html.rb | 24 ++++
lib/docs/filters/puppeteer/entries.rb | 41 +++++++
lib/docs/filters/python/clean_html.rb | 8 +-
lib/docs/filters/python/entries_v3.rb | 22 ++--
lib/docs/filters/rust/clean_html.rb | 36 +++++-
lib/docs/filters/rust/entries.rb | 13 ++-
lib/docs/scrapers/apache_pig.rb | 2 +-
lib/docs/scrapers/bower.rb | 2 +-
lib/docs/scrapers/chai.rb | 2 +-
lib/docs/scrapers/codeceptjs.rb | 2 +-
lib/docs/scrapers/docker.rb | 2 +-
lib/docs/scrapers/electron.rb | 2 +-
lib/docs/scrapers/elixir.rb | 2 +-
lib/docs/scrapers/express.rb | 2 +-
lib/docs/scrapers/fish.rb | 2 +-
lib/docs/scrapers/flow.rb | 2 +-
lib/docs/scrapers/gnu.rb | 2 +-
lib/docs/scrapers/grunt.rb | 2 +-
lib/docs/scrapers/handlebars.rb | 23 ++++
lib/docs/scrapers/haxe.rb | 2 +-
lib/docs/scrapers/immutable.rb | 2 +-
lib/docs/scrapers/influxdata.rb | 2 +-
lib/docs/scrapers/jasmine.rb | 2 +-
lib/docs/scrapers/jest.rb | 2 +-
lib/docs/scrapers/laravel.rb | 13 +++
lib/docs/scrapers/less.rb | 2 +-
lib/docs/scrapers/lodash.rb | 2 +-
lib/docs/scrapers/marionette.rb | 2 +-
lib/docs/scrapers/markdown.rb | 2 +-
lib/docs/scrapers/mocha.rb | 2 +-
lib/docs/scrapers/mongoose.rb | 2 +-
lib/docs/scrapers/nim.rb | 2 +-
lib/docs/scrapers/puppeteer.rb | 18 +++
lib/docs/scrapers/redux.rb | 2 +-
lib/docs/scrapers/requirejs.rb | 2 +-
lib/docs/scrapers/rust.rb | 2 +-
lib/docs/scrapers/typescript.rb | 2 +-
lib/docs/scrapers/vagrant.rb | 2 +-
lib/docs/scrapers/vulkan.rb | 2 +-
lib/docs/scrapers/yarn.rb | 2 +-
lib/tasks/docs.thor | 8 +-
lib/tasks/sprites.thor | 2 +-
public/icons/docs/handlebars/16.png | Bin 0 -> 303 bytes
public/icons/docs/handlebars/16 2x png | Bin 0 -> 534 bytes
public/icons/docs/handlebars/SOURCE | 1 +
public/icons/docs/puppeteer/16.png | Bin 0 -> 484 bytes
public/icons/docs/puppeteer/16 2x png | Bin 0 -> 857 bytes
public/icons/docs/puppeteer/SOURCE | 1 +
public/images/webapp-icon-512.png | Bin 0 -> 246851 bytes
public/manifest.json | 5 +
test/app_test.rb | 64 +++++++----
views/index.erb | 4 +-
views/other.erb | 4 +-
views/unsupported.erb | 11 +-
124 files changed, 849 insertions(+), 753 deletions(-)
---
diff --cc Gemfile.lock
index 3fdb414f,0e177c4d..c3d1907f
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@@ -32,12 -31,12 +32,12 @@@ GE
html-pipeline (2.8.4)
activesupport (>= 2)
nokogiri (>= 1.4)
- i18n (1.0.1)
- i18n (1.1.0)
++ i18n (1.1.1)
concurrent-ruby (~> 1.0)
- image_optim (0.26.1)
- image_optim (0.26.2)
++ image_optim (0.26.3)
exifr (~> 1.2, >= 1.2.2)
fspath (~> 3.0)
- image_size (~> 1.5)
+ image_size (>= 1.5, < 3)
in_threads (~> 1.3)
progress (~> 3.0, >= 3.0.1)
image_optim_pack (0.5.1)
@@@ -49,14 -48,14 +49,14 @@@
mini_portile2 (2.3.0)
minitest (5.11.3)
multi_json (1.13.1)
- mustermann (1.0.2)
- newrelic_rpm (5.2.0.345)
- nokogiri (1.8.4)
+ mustermann (1.0.3)
+ newrelic_rpm (5.4.0.347)
- nokogiri (1.8.4)
++ nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
options (2.3.2)
-- progress (3.4.0)
- progress_bar (1.2.0)
- highline (~> 1.6)
++ progress (3.5.0)
+ progress_bar (1.3.0)
+ highline (>= 1.6, < 3)
options (~> 2.3.0)
pry (0.11.3)
coderay (~> 1.1.0)
@@@ -94,11 -94,11 +95,13 @@@
rack (> 1, < 3)
sprockets-helpers (1.2.1)
sprockets (>= 2.2)
+ sprockets-sass (2.0.0.beta2)
+ sprockets (>= 2.0, < 4.0)
- strings (0.1.1)
- unicode-display_width (~> 1.3.0)
+ strings (0.1.4)
+ strings-ansi (~> 0.1.0)
+ unicode-display_width (~> 1.4.0)
unicode_utils (~> 1.4.0)
+ strings-ansi (0.1.0)
thin (1.7.2)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
@@@ -163,4 -162,4 +167,4 @@@ RUBY VERSIO
ruby 2.5.1p57
BUNDLED WITH
- 1.16.4
- 1.16.1
++ 1.16.6
diff --cc assets/stylesheets/global/_icons.scss.erb
index bfc852f4,00000000..b2b22c22
mode 100644,000000..100644
--- a/assets/stylesheets/global/_icons.scss.erb
+++ b/assets/stylesheets/global/_icons.scss.erb
@@@ -1,43 -1,0 +1,43 @@@
+<% manifest = JSON.parse(File.read('assets/images/sprites/docs.json')) %>
+
+%svg-icon {
+ display: inline-block;
+ vertical-align: top;
+ width: 1rem;
+ height: 1rem;
+ pointer-events: none;
+ fill: currentColor;
+}
+
+%doc-icon {
+ content: '';
+ display: block;
+ width: 1rem;
+ height: 1rem;
+ background-image: image-url('sprites/docs.png');
+ background-size: <%= manifest['icons_per_row'] %>rem <%= manifest['icons_per_row'] %>rem;
+}
+
+@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
+ %doc-icon { background-image: image-url('sprites/docs 2x png'); }
+}
+
- %darkIconFix {
- @if $style == 'dark' {
++html._theme-dark {
++ %darkIconFix {
+ filter: invert(100%) grayscale(100%);
+ -webkit-filter: invert(100%) grayscale(100%);
+ }
+}
+
+<%=
+ items = []
+
+ manifest['items'].each do |item|
+ rules = []
+ rules << "background-position: -#{item['col']}rem -#{item['row']}rem;"
+ rules << "@extend %darkIconFix !optional;" if item['dark_icon_fix']
+ items << "._icon-#{item['type']}:before { #{rules.join(' ')} }"
+ end
+
+ items.join('')
+ %>
diff --cc lib/tasks/sprites.thor
index bd2ff781,00000000..b50f0f04
mode 100644,000000..100644
--- a/lib/tasks/sprites.thor
+++ b/lib/tasks/sprites.thor
@@@ -1,205 -1,0 +1,205 @@@
+class SpritesCLI < Thor
+ def self.to_s
+ 'Sprites'
+ end
+
+ def initialize(*args)
+ require 'docs'
+ require 'chunky_png'
+ require 'fileutils'
+ super
+ end
+
+ desc 'generate [--verbose]', 'Generate the documentation icon spritesheets'
+ option :verbose, type: :boolean
+ def generate
+ items = get_items
+ items_with_icons = items.select {|item| item[:has_icons]}
+ items_without_icons = items.select {|item| !item[:has_icons]}
+ icons_per_row = Math.sqrt(items_with_icons.length).ceil
+
+ bg_color = get_sidebar_background
+
+ items_with_icons.each_with_index do |item, index|
+ item[:row] = (index / icons_per_row).floor
+ item[:col] = index - item[:row] * icons_per_row
+
+ item[:icon_16] = get_icon(item[:path_16], 16)
+ item[:icon_32] = get_icon(item[:path_32], 32)
+
+ item[:dark_icon_fix] = needs_dark_icon_fix(item[:icon_32], bg_color)
+ end
+
+ log_details(items_with_icons, icons_per_row)
+
+ generate_spritesheet(16, items_with_icons, 'assets/images/sprites/docs.png') {|item| item[:icon_16]}
+ generate_spritesheet(32, items_with_icons, 'assets/images/sprites/docs 2x png') {|item| item[:icon_32]}
+
+ # Add Mongoose's icon details to docs without custom icons
+ default_item = items_with_icons.find {|item| item[:type] == 'mongoose'}
+ items_without_icons.each do |item|
+ item[:row] = default_item[:row]
+ item[:col] = default_item[:col]
+ item[:dark_icon_fix] = default_item[:dark_icon_fix]
+ end
+
+ save_manifest(items, icons_per_row, 'assets/images/sprites/docs.json')
+ end
+
+ private
+
+ def get_items
+ items = Docs.all.map do |doc|
+ base_path = "public/icons/docs/#{doc.slug}"
+ {
+ :type => doc.slug,
+ :path_16 => "#{base_path}/16.png",
+ :path_32 => "#{base_path}/16 2x png"
+ }
+ end
+
+ # Checking paths against an array of possible paths is faster than 200+ File.exist? calls
+ files = Dir.glob('public/icons/docs/**/*.png')
+
+ items.each do |item|
+ item[:has_icons] = files.include?(item[:path_16]) && files.include?(item[:path_32])
+ end
+ end
+
+ def get_icon(path, max_size)
+ icon = ChunkyPNG::Image.from_file(path)
+
+ # Check if the icon is too big
+ # If it is, resize the image without changing the aspect ratio
+ if icon.width > max_size || icon.height > max_size
+ ratio = icon.width.to_f / icon.height
+ new_width = (icon.width >= icon.height ? max_size : max_size * ratio).floor
+ new_height = (icon.width >= icon.height ? max_size / ratio : max_size).floor
+
+ logger.warn("Icon #{path} is too big: max size is #{max_size} x #{max_size}, icon is #{icon.width} x
#{icon.height}, resizing to #{new_width} x #{new_height}")
+
+ icon.resample_nearest_neighbor!(new_width, new_height)
+ end
+
+ icon
+ end
+
+ def get_sidebar_background
+ # This is a hacky way to get the background color of the sidebar
+ # Unfortunately, it's not possible to get the value of a SCSS variable from a Thor task
+ # Because hard-coding the value is even worse, we extract it using some regex
+ path = 'assets/stylesheets/global/_variables-dark.scss'
- regex = /\$sidebarBackground:\s+([^;]+);/
++ regex = /--sidebarBackground:\s+([^;]+);/
+ ChunkyPNG::Color.parse(File.read(path)[regex, 1])
+ end
+
+ def needs_dark_icon_fix(icon, bg_color)
+ # Determine whether the icon needs to be grayscaled if the user has enabled the dark theme
+ # The logic is roughly based on https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast
+ contrast = icon.pixels.select {|pixel| ChunkyPNG::Color.a(pixel) > 0}.map do |pixel|
+ get_contrast(bg_color, pixel)
+ end
+
+ avg = contrast.reduce(:+) / contrast.size.to_f
+ avg < 3.5
+ end
+
+ def get_contrast(base, other)
+ # Calculating the contrast ratio as described in the WCAG 2.0:
+ # https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef
+ l1 = get_luminance(base) + 0.05
+ l2 = get_luminance(other) + 0.05
+ ratio = l1 / l2
+ l2 > l1 ? 1 / ratio : ratio
+ end
+
+ def get_luminance(color)
+ rgb = [
+ ChunkyPNG::Color.r(color).to_f,
+ ChunkyPNG::Color.g(color).to_f,
+ ChunkyPNG::Color.b(color).to_f
+ ]
+
+ # Calculating the relative luminance as described in the WCAG 2.0:
+ # https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
+
+ rgb.map! do |value|
+ value /= 255
+ value < 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4
+ end
+
+ 0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2]
+ end
+
+ def generate_spritesheet(size, items_with_icons, output_path, &item_to_icon)
+ logger.info("Generating spritesheet #{output_path} with icons of size #{size} x #{size}")
+
+ icons_per_row = Math.sqrt(items_with_icons.length).ceil
+ spritesheet = ChunkyPNG::Image.new(size * icons_per_row, size * icons_per_row)
+
+ items_with_icons.each do |item|
+ icon = item_to_icon.call(item)
+
+ # Calculate the base coordinates
+ base_x = item[:col] * size
+ base_y = item[:row] * size
+
+ # Center the icon if it's not a perfect rectangle
+ x = base_x + ((size - icon.width) / 2).floor
+ y = base_y + ((size - icon.height) / 2).floor
+
+ spritesheet.compose!(icon, x, y)
+ end
+
+ FileUtils.mkdir_p(File.dirname(output_path))
+ spritesheet.save(output_path)
+ end
+
+ def save_manifest(items, icons_per_row, path)
+ logger.info("Saving spritesheet details to #{path}")
+
+ FileUtils.mkdir_p(File.dirname(path))
+
+ # Only save the details that the scss file needs
+ manifest_items = items.map do |item|
+ {
+ :type => item[:type],
+ :row => item[:row],
+ :col => item[:col],
+ :dark_icon_fix => item[:dark_icon_fix]
+ }
+ end
+
+ manifest = {:icons_per_row => icons_per_row, :items => manifest_items}
+
+ File.open(path, 'w') do |f|
+ f.write(JSON.generate(manifest))
+ end
+ end
+
+ def log_details(items_with_icons, icons_per_row)
+ logger.debug("Amount of icons: #{items_with_icons.length}")
+ logger.debug("Amount of icons needing the dark icon fix: #{items_with_icons.count {|item|
item[:dark_icon_fix]}}")
+ logger.debug("Amount of icons per row: #{icons_per_row}")
+
+ max_type_length = items_with_icons.map {|item| item[:type].length}.max
+ border = "+#{'-' * (max_type_length + 2)}+#{'-' * 5}+#{'-' * 8}+#{'-' * 15}+"
+
+ logger.debug(border)
+ logger.debug("| #{'Type'.ljust(max_type_length)} | Row | Column | Dark icon fix |")
+ logger.debug(border)
+
+ items_with_icons.each do |item|
+ logger.debug("| #{item[:type].ljust(max_type_length)} | #{item[:row].to_s.ljust(3)} |
#{item[:col].to_s.ljust(6)} | #{(item[:dark_icon_fix] ? 'Yes' : 'No').ljust(13)} |")
+ end
+
+ logger.debug(border)
+ end
+
+ def logger
+ @logger ||= Logger.new($stdout).tap do |logger|
+ logger.level = options[:verbose] ? Logger::DEBUG : Logger::INFO
+ logger.formatter = proc {|severity, datetime, progname, msg| "#{msg}\n"}
+ end
+ end
+end
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]