olddoc user/dev discussion/patches/bugs/etc
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: <olddoc-public@80x24.org>
Subject: [PATCH 1/3] add dark216 color scheme for power savings
Date: Mon, 22 Apr 2019 01:49:04 +0000	[thread overview]
Message-ID: <20190422014906.4253-2-e@80x24.org> (raw)
In-Reply-To: <20190422014906.4253-1-e@80x24.org>

"oldweb" remains for compatibility and we still have minimal styling.

Some browsers (e.g. Firefox 67.0a1 via "ui.systemUsesDarkTheme") are
adding support for the "prefers-color-scheme" @media query.  So this
allows pages to respect user choice when it comes to dark or light

OLED and CRT displays measure significant power savings when using
dark schemes.  Dark themes work better with less ambient light, so
favoring darkness can lead to overall power savings even with CCFL
and LED-lit displays.
 Documentation/olddoc.1.txt |  4 +++-
 GNUmakefile                |  2 +-
 README                     | 14 +++++++------
 lib/dark216.rb             | 40 ++++++++++++++++++++++++++++++++++++++
 lib/olddoc.rb              |  3 ++-
 lib/oldweb.rb              |  1 +
 lib/oldweb/_head.rhtml     |  6 +++++-
 7 files changed, 60 insertions(+), 10 deletions(-)
 create mode 100644 lib/dark216.rb

diff --git a/Documentation/olddoc.1.txt b/Documentation/olddoc.1.txt
index c294cdb..25bf88b 100644
--- a/Documentation/olddoc.1.txt
+++ b/Documentation/olddoc.1.txt
@@ -10,9 +10,11 @@ olddoc - old-fashioned RDoc HTML generator
 `rdoc` -f oldweb
+`rdoc` -f dark216
-olddoc features oldweb, and old-fashioned RDoc HTML generator.
+olddoc features dark216, and old-fashioned RDoc HTML generator.
 You can also use "olddoc prepare" to generate NEWS files from
 git tags.
diff --git a/GNUmakefile b/GNUmakefile
index 038bc25..1df29ae 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -41,7 +41,7 @@ doc: $(placeholders)
 	$(MAKE) -C Documentation html
 	rm -rf doc
 	olddoc prepare
-	rdoc --debug -f oldweb
+	rdoc --debug -f dark216
 	olddoc merge
 	ln NEWS.atom.xml doc/
diff --git a/README b/README
index 4b5aa1f..b9538e7 100644
--- a/README
+++ b/README
@@ -3,15 +3,17 @@
 olddoc contains old-fashioned document generators for those who do not
 wish to impose bloated, new-fangled web cruft on their readers.
-olddoc contains oldweb, an HTML generator without any images, frames,
-CSS, or JavaScript.  It is designed for users of text-based browsers
-and/or low-bandwidth connections.  oldweb focuses on text as it is
-the lowest common denominator for accessibility and compatibility
+olddoc contains dark216, a HTML generator without any images, frames,
+or JavaScript.  It is designed for users of text-based browsers
+and/or low-bandwidth connections; yet respects user preference for
+light color schemes in new CSS browsers while favoring darkness for
+power savings on OLED and CRT displays.  dark216 focuses on text as
+it is the lowest common denominator for accessibility and compatibility
 with people and hardware.
 == Reasons
-* No CSS.  Encouraging users to use CSS leads to problems like
+* No CSS required.  Encouraging users to use CSS leads to problems like
   copy-paste hijacking: https://thejh.net/misc/website-terminal-copy-paste
   External CSS also increases page load time as it often blocks page
   rendering.  Asynchronous loading of CSS also causes accessibility
@@ -38,7 +40,7 @@ missing out!
 	gem install olddoc
-	rdoc -f oldweb
+	rdoc -f dark216
 You can also use olddoc to generate NEWS entries
 assuming you have git tags, a README file and .olddoc.yml
diff --git a/lib/dark216.rb b/lib/dark216.rb
new file mode 100644
index 0000000..a01584c
--- /dev/null
+++ b/lib/dark216.rb
@@ -0,0 +1,40 @@
+# Copyright (C) 2019 all contributors <olddoc-public@80x24.org>
+# License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
+# Loosely derived from Darkfish in the main rdoc distribution
+require_relative 'oldweb'
+# dark216 is an \RDoc template and not intended as a programming API.
+# It respect prefers-color-scheme:light on newer browsers with CSS
+# support, but favors darkness for power-savings.
+# You may specify it as an \RDoc formatter:
+#   rdoc -f dark216 ...
+class Dark216 < Oldweb
+  RDoc::RDoc.add_generator(self) # :nodoc:
+  include ERB::Util # :nodoc:
+  # description of the generator
+  DESCRIPTION = 'minimal dark HTML generator'
+  # default to a dark, web-safe (216 color) palette for power-savings.
+  # Color-capable browsers can respect the prefers-color-scheme:light
+  # @media query (browser support a work-in-progress)
+  STYLE = <<''.gsub(/^\s*/m, '').delete!("\n") # :nodoc:
+@media screen {
+  *{background:#000;color:#ccc}
+  a{color:#69f}
+  a:visited{color:#96f}
+@media screen AND (prefers-color-scheme:light) {
+  *{background:#fff;color:#333}
+  a{color:#00f}
+  a:visited{color:#808}
+  def initialize(*args) # :nodoc:
+    super
+    @oldweb_style = STYLE
+  end
+# :startdoc:
diff --git a/lib/olddoc.rb b/lib/olddoc.rb
index 3061e73..d5d6b37 100644
--- a/lib/olddoc.rb
+++ b/lib/olddoc.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2016 all contributors <olddoc-public@80x24.org>
+# Copyright (C) 2015-2019 all contributors <olddoc-public@80x24.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 module Olddoc # :nodoc:
   autoload :Gemspec, 'olddoc/gemspec'
@@ -16,3 +16,4 @@ module Olddoc # :nodoc:
 require_relative 'oldweb'
+require_relative 'dark216'
diff --git a/lib/oldweb.rb b/lib/oldweb.rb
index ccc37f7..5b55019 100644
--- a/lib/oldweb.rb
+++ b/lib/oldweb.rb
@@ -91,6 +91,7 @@ class Oldweb
       cgit_url << '#n%d' # lineno
       @old_vcs_url = cgit_url
+    @oldweb_style = nil # used by dark216
   def generate # :nodoc:
diff --git a/lib/oldweb/_head.rhtml b/lib/oldweb/_head.rhtml
index 720fd95..15a428e 100644
--- a/lib/oldweb/_head.rhtml
+++ b/lib/oldweb/_head.rhtml
@@ -8,4 +8,8 @@ type="application/atom+xml" /><%
-content="text/html; charset=<%= @options.charset %>">
+content="text/html; charset=<%= @options.charset %>"><%
+if @oldweb_style
+%><style><%= @oldweb_style %></style><%

  reply	other threads:[~2019-04-22  1:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-22  1:49 [PATCH 0/3] Earth Day changes! Eric Wong
2019-04-22  1:49 ` Eric Wong [this message]
2019-04-22  1:49 ` [PATCH 2/3] doc: switch to perlpod for documentation Eric Wong
2019-04-22  1:49 ` [PATCH 3/3] doc: update wording to avoid "mailing list" Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://80x24.org/olddoc/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190422014906.4253-2-e@80x24.org \
    --to=e@80x24.org \
    --cc=olddoc-public@80x24.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).