From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: [ox-html, patch] Viewport Date: Wed, 01 Apr 2015 15:50:09 +0200 Message-ID: <87zj6sdkku.fsf@gmx.us> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdJ2N-0003bF-MV for emacs-orgmode@gnu.org; Wed, 01 Apr 2015 09:50:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdJ2K-0001zf-13 for emacs-orgmode@gnu.org; Wed, 01 Apr 2015 09:50:31 -0400 Received: from plane.gmane.org ([80.91.229.3]:51922) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdJ2J-0001xq-I3 for emacs-orgmode@gnu.org; Wed, 01 Apr 2015 09:50:27 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YdJ2H-0002uM-Pm for emacs-orgmode@gnu.org; Wed, 01 Apr 2015 15:50:25 +0200 Received: from 46.166.188.200 ([46.166.188.200]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 01 Apr 2015 15:50:25 +0200 Received: from rasmus by 46.166.188.200 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 01 Apr 2015 15:50:25 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi, I think ox-html should insert a viewport to make it mobile friendly. I think it's not a W3 standard, though, but it's also just an additional meta tag. I'd like to hear from somebody who knows about html. This patch adds this tag by default. —Rasmus -- m-mm-mmm-mmmm bacon! --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0007-ox-html-Use-viewport.patch >From 1a0e32d45b70877e9e52cf0fad3500b632259a12 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Wed, 1 Apr 2015 15:39:28 +0200 Subject: [PATCH 7/7] ox-html: Use viewport * ox-html.el (org-html--build-meta-info): Insert viewport. (org-html-viewport): New custom variable. * ORG-NEWS: Mention viewport. * org.texi: Mention org-html-viewport. Viewport makes org-generated html work well with small screens. --- doc/org.texi | 1 + etc/ORG-NEWS | 10 ++++++++- lisp/ox-html.el | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 0342c07..947e6ca 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -14263,6 +14263,7 @@ however, override everything. @item @code{:html-use-infojs} @tab @code{org-html-use-infojs} @item @code{:html-use-unicode-chars} @tab @code{org-html-use-unicode-chars} @item @code{:html-validation-link} @tab @code{org-html-validation-link} +@item @code{:html-viewport} @tab @code{org-html-viewport} @item @code{:html-xml-declaration} @tab @code{org-html-xml-declaration} @end multitable diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 28e8394..ec972c9 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -327,6 +327,9 @@ leading spaces within table cells. *** New MathJax configuration options. Org uses the MathJax CDN by default. See the manual and the docstring of ~org-html-mathjax-options~ for details. +*** Viewport support in html export +Viewport for mobile-optimized website is now automatically inserted +when exporting to html. See ~org-html-viewport~ for details. ** Miscellaneous *** Strip all meta data from ITEM special property ITEM special property does not contain TODO, priority or tags anymore. @@ -1430,7 +1433,7 @@ See http://orgmode.org/elpa/ | =C-c C-x E= | =E= | [[doc::org-inc-effort][org-inc-effort]] | | | =#= | [[doc::org-toggle-comment][org-toggle-comment]] | | | =:= | [[doc::org-columns][org-columns]] | - | | =W= | Set =APPT_WARNTIME= | + | | =W= | Set =APPT_WARNTIME= | | =k= | | [[doc::org-agenda-capture][org-agenda-capture]] | | C-c , | , | [[doc::org-priority][org-priority]] | @@ -2824,3 +2827,8 @@ that Calc formulas can operate on them. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . + + + + + diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 8c6406b..7761cca 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -162,6 +162,7 @@ (:html-use-infojs nil nil org-html-use-infojs) (:html-use-unicode-chars nil nil org-html-use-unicode-chars) (:html-validation-link nil nil org-html-validation-link) + (:html-viewport nil nil org-html-viewport) (:html-inline-images nil nil org-html-inline-images) (:html-table-attributes nil nil org-html-table-default-attributes) (:html-table-row-tags nil nil org-html-table-row-tags) @@ -1403,6 +1404,53 @@ or for publication projects using the :html-head-extra property." ;;;###autoload (put 'org-html-head-extra 'safe-local-variable 'stringp) +;;;; Template :: Viewport + +(defcustom org-html-viewport '((width "device-width") + (initial-scale "1") + (minimum-scale "") + (maximum-scale "") + (user-scalable "")) + "Viewport options for mobile-optimized sites. + +The following values are recognized + +width Size of the viewport. +initial-scale Zoom level when the page is first loaded. +minimum-scale Minimum allowed zoom level. +maximum-scale Maximum allowed zoom level. +user-scalable Whether zoom can be changed. + +The viewport meta tag is inserted if this variable is non-nil. + +See the following site for a reference: +https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag" + :group 'org-export-html + :version "25.1" + :package-version '(Org . "8.3") + :type '(list :greedy t + (list :tag "Width of viewport" + (const :format " " width) + (choice (const :tag "unset" "") + (string))) + (list :tag "Initial scale" + (const :format " " initial-scale) + (choice (const :tag "unset" "") + (string))) + (list :tag "Minimum scale/zoom" + (const :format " " minimum-scale) + (choice (const :tag "unset" "") + (string))) + (list :tag "Maximum scale/zoom" + (const :format " " maximum-scale) + (choice (const :tag "unset" "") + (string))) + (list :tag "User scalable/zoomable" + (const :format " " user-scalable) + (choice (const :tag "unset" "") + (const "true") + (const "false"))))) + ;;;; Todos (defcustom org-html-todo-kwd-class-prefix "" @@ -1681,7 +1729,20 @@ INFO is a plist used as a communication channel." (format " name=\"keywords\" content=\"%s\"" (funcall protect-string keywords)) info) - "\n"))))) + "\n")) + (let ((viewport (remove-if-not (lambda (cell) + (org-string-nw-p (cadr cell))) + (plist-get info :html-viewport)))) + (and viewport + (concat + (org-html-close-tag + "meta" + (format " name=\"viewport\" content=\"%s\"" + (mapconcat (lambda (elm) + (format "%s=%s" (car elm) (cadr elm))) + viewport ", ")) + info) + "\n")))))) (defun org-html--build-head (info) "Return information for the .. of the HTML output. -- 2.3.4 --=-=-=--