gnucash maint: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Thu Jun 7 13:52:25 EDT 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/8cfa078b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1641c422 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ccf3ebda (commit)
	 via  https://github.com/Gnucash/gnucash/commit/da0160ad (commit)
	from  https://github.com/Gnucash/gnucash/commit/b431b648 (commit)



commit 8cfa078bd7b0531b83879aeea75b8e4d10577f4d
Merge: b431b64 1641c42
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu Jun 7 10:48:28 2018 -0700

    Merge Chris Lam's 'maint-html-layout' into maint.


commit 1641c422478c1e66acfe268edbbfbde72b2f404f
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Jun 5 19:47:22 2018 +0800

    [html-anytag] generic html tag object
    
    Generic tag HTML-object.
    Also defines (gnc:make-html-div/markup) (gnc:make-html-span/markup)
    
    any html object can be enclosed with (gnc:make-html-span obj)
    or (gnc:make-html-span/markup "class" obj), (gnc:make-html-div obj)
    or (gnc:make-html-div/markup "class" obj)

diff --git a/gnucash/report/report-system/CMakeLists.txt b/gnucash/report/report-system/CMakeLists.txt
index d1887b4..a06f4c4 100644
--- a/gnucash/report/report-system/CMakeLists.txt
+++ b/gnucash/report/report-system/CMakeLists.txt
@@ -69,6 +69,7 @@ set (report_system_SCHEME_3
     html-linechart.scm
     html-style-info.scm
     html-style-sheet.scm
+    html-anytag.scm
     html-table.scm
     html-text.scm
     html-utilities.scm
diff --git a/gnucash/report/report-system/html-anytag.scm b/gnucash/report/report-system/html-anytag.scm
new file mode 100644
index 0000000..879fe1d
--- /dev/null
+++ b/gnucash/report/report-system/html-anytag.scm
@@ -0,0 +1,121 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; html-anytag.scm : generate HTML programmatically, with support
+;; for simple style elements. 
+;; Copyright 2018 Christopher Lam
+;;
+;; This module allows any html tag to be created such as
+;; <div> <span>
+;; 
+;; This program is free software; you can redistribute it and/or    
+;; modify it under the terms of the GNU General Public License as   
+;; published by the Free Software Foundation; either version 2 of   
+;; the License, or (at your option) any later version.              
+;;                                                                  
+;; This program is distributed in the hope that it will be useful,  
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of   
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    
+;; GNU General Public License for more details.                     
+;;                                                                  
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, contact:
+;;
+;; Free Software Foundation           Voice:  +1-617-542-5942
+;; 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+;; Boston, MA  02110-1301,  USA       gnu at gnu.org
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define <html-anytag>
+  (make-record-type "<html-anytag>"
+                    '(tag
+                      data
+                      style
+                      )))
+
+(define gnc:html-anytag?
+  (record-predicate <html-anytag>))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;  <html-anytag> class
+;;  wrapper around HTML anytags
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define gnc:make-html-anytag-internal
+  (record-constructor <html-anytag>))
+
+(define (gnc:make-html-anytag tag . data)
+  (gnc:make-html-anytag-internal
+   tag                         ;; tag
+   data                        ;; data
+   (gnc:make-html-style-table) ;; style
+   ))
+
+(define gnc:html-anytag-tag
+  (record-accessor <html-anytag> 'tag))
+
+(define gnc:html-anytag-set-tag!
+  (record-modifier <html-anytag> 'tag))
+
+(define gnc:html-anytag-data
+  (record-accessor <html-anytag> 'data))
+
+(define gnc:html-anytag-set-data!
+  (record-modifier <html-anytag> 'data))
+
+(define gnc:html-anytag-style
+  (record-accessor <html-anytag> 'style))
+
+(define gnc:html-anytag-set-style-internal!
+  (record-modifier <html-anytag> 'style))
+
+(define (gnc:html-anytag-append-data! anytag . data)
+  (gnc:html-anytag-set-data!
+   anytag (append (gnc:html-anytag-data anytag) data)))
+
+(define (gnc:html-anytag-set-style! anytag tag . rest)
+  (let ((style (gnc:html-anytag-style anytag))
+        (newstyle (if (and (= (length rest) 2)
+                           (procedure? (car rest)))
+                      (apply gnc:make-html-data-style-info rest)
+                      (apply gnc:make-html-markup-style-info rest))))
+    (gnc:html-style-table-set! style tag newstyle)))
+
+(define (gnc:html-anytag-render anytag doc)
+  (let* ((tag (gnc:html-anytag-tag anytag))
+         (retval '())
+         (push (lambda (l) (set! retval (cons l retval)))))
+    ;; compile the anytag style to make other compiles faster
+    (gnc:html-style-table-compile
+     (gnc:html-anytag-style anytag) (gnc:html-document-style-stack doc))
+
+    (gnc:html-document-push-style doc (gnc:html-anytag-style anytag))
+
+    (push (gnc:html-document-markup-start doc tag #t))
+    (let ((data (gnc:html-anytag-data anytag)))
+      (for-each
+       (lambda (datum) (push (gnc:html-object-render datum doc)))
+       (if (list? data)
+           data
+           (list data))))
+    (push (gnc:html-document-markup-end doc tag))
+
+    (gnc:html-document-pop-style doc)
+
+    retval))
+
+(define (gnc:make-html-div/markup class . data)
+  (let ((anytag (apply gnc:make-html-anytag "div" data)))
+    (gnc:html-anytag-set-style! anytag "div"
+                                'attribute (list "class" class))
+    anytag))
+
+(define (gnc:make-html-span/markup class . data)
+  (let ((anytag (apply gnc:make-html-anytag "span" data)))
+    (gnc:html-anytag-set-style! anytag "span"
+                                'attribute (list "class" class))
+    anytag))
+
+(define (gnc:make-html-div . data)                 ;ideally should have been (gnc:make-html-anytag "div" data) but it will inherit parent div class.
+  (apply gnc:make-html-div/markup (cons "" data))) ;so we have to redo as an empty-string. so annoying!
+
+(define (gnc:make-html-span . data)
+  (apply gnc:make-html-span/markup (cons "" data)))
diff --git a/gnucash/report/report-system/html-document.scm b/gnucash/report/report-system/html-document.scm
index 8325da6..6978ac0 100644
--- a/gnucash/report/report-system/html-document.scm
+++ b/gnucash/report/report-system/html-document.scm
@@ -399,6 +399,9 @@
          ((gnc:html-table? obj)
           (set! o (gnc:make-html-object-internal
                    gnc:html-table-render obj)))
+         ((gnc:html-anytag? obj)
+          (set! o (gnc:make-html-object-internal
+                   gnc:html-anytag-render obj)))
          ((gnc:html-table-cell? obj)
           (set! o (gnc:make-html-object-internal
                    gnc:html-table-cell-render obj)))
diff --git a/gnucash/report/report-system/report-system.scm b/gnucash/report/report-system/report-system.scm
index 70943f2..73357a6 100644
--- a/gnucash/report/report-system/report-system.scm
+++ b/gnucash/report/report-system/report-system.scm
@@ -622,6 +622,20 @@
 (export gnc:html-table-prepend-column!)
 (export gnc:html-table-render)
 
+;; html-anytag.scm
+(export <html-anytag>)
+(export html-anytag?)
+(export gnc:html-anytag-data)
+(export gnc:html-anytag-set-data!)
+(export gnc:html-anytag-style)
+(export gnc:html-anytag-append-data!)
+(export gnc:html-anytag-set-style!)
+(export gnc:html-anytag-render div doc)
+(export gnc:make-html-div)
+(export gnc:make-html-div/markup)
+(export gnc:make-html-span)
+(export gnc:make-html-span/markup)
+
 ;; html-text.scm
 
 (export <html-text>)
@@ -734,6 +748,7 @@
 (load-from-path "html-fonts")
 
 (load-from-path "html-style-sheet")
+(load-from-path "html-anytag")
 (load-from-path "html-table")
 (load-from-path "html-text")
 (load-from-path "html-acct-table")

commit ccf3ebda1697398656e346d5753c8efd0e31d9f1
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Jun 3 19:35:24 2018 +0800

    [STYLESHEETS] modify stylesheet to accept document style-text
    
    This commit will modify stylesheet-*.scm to pass the *document*
    style-text as well as the *style-sheet* style-text to the <style> tag.

diff --git a/gnucash/report/report-system/html-fonts.scm b/gnucash/report/report-system/html-fonts.scm
index fee9af9..d87ba13 100644
--- a/gnucash/report/report-system/html-fonts.scm
+++ b/gnucash/report/report-system/html-fonts.scm
@@ -132,7 +132,7 @@
 )
 
 ;; Adds CSS style information to an html document
-(define (add-css-information-to-doc options ssdoc)
+(define (add-css-information-to-doc options ssdoc doc)
     (let*
         ((opt-val 
             (lambda (section name)
@@ -173,6 +173,7 @@
                 "td.total-number-cell { " total-number-cell-font-info " }\n"
                 "td.total-label-cell { " total-label-cell-font-info " }\n"
                 "td.centered-label-cell { text-align: center; " centered-label-cell-font-info " }\n"
+                (or (gnc:html-document-style-text doc) "")
             )
         )
     )
diff --git a/gnucash/report/stylesheets/stylesheet-easy.scm b/gnucash/report/stylesheets/stylesheet-easy.scm
index c380acd..3f5cff5 100644
--- a/gnucash/report/stylesheets/stylesheet-easy.scm
+++ b/gnucash/report/stylesheets/stylesheet-easy.scm
@@ -344,7 +344,7 @@
       (if (and logopixmap (> (string-length logopixmap) 0))
         (set! headcolumn 1))
 
-      (add-css-information-to-doc options ssdoc)
+      (add-css-information-to-doc options ssdoc doc)
 
       (let* ((title (gnc:html-document-title doc))
              (doc-headline (gnc:html-document-headline doc))
diff --git a/gnucash/report/stylesheets/stylesheet-fancy.scm b/gnucash/report/stylesheets/stylesheet-fancy.scm
index 2ea37d3..46f2bc1 100644
--- a/gnucash/report/stylesheets/stylesheet-fancy.scm
+++ b/gnucash/report/stylesheets/stylesheet-fancy.scm
@@ -325,7 +325,7 @@
 	(gnc:html-document-set-style!
 	 ssdoc "a" 'tag ""))
     
-    (add-css-information-to-doc options ssdoc)
+    (add-css-information-to-doc options ssdoc doc)
 
     (let ((t (gnc:make-html-table)))
       ;; we don't want a bevel for this table, but we don't want 
diff --git a/gnucash/report/stylesheets/stylesheet-footer.scm b/gnucash/report/stylesheets/stylesheet-footer.scm
index 37a198a..3464d58 100644
--- a/gnucash/report/stylesheets/stylesheet-footer.scm
+++ b/gnucash/report/stylesheets/stylesheet-footer.scm
@@ -343,7 +343,7 @@
     (if (not links?)
 	  (gnc:html-document-set-style! ssdoc "a" 'tag ""))
     
-    (add-css-information-to-doc options ssdoc)
+    (add-css-information-to-doc options ssdoc doc)
 
     (let ((t (gnc:make-html-table)))
       ;; we don't want a bevel for this table, but we don't want 
diff --git a/gnucash/report/stylesheets/stylesheet-head-or-tail.scm b/gnucash/report/stylesheets/stylesheet-head-or-tail.scm
index f6a279c..c2cbfd4 100644
--- a/gnucash/report/stylesheets/stylesheet-head-or-tail.scm
+++ b/gnucash/report/stylesheets/stylesheet-head-or-tail.scm
@@ -408,7 +408,7 @@
     (if (not links?)
 	  (gnc:html-document-set-style! ssdoc "a" 'tag ""))
 
-    (add-css-information-to-doc options ssdoc)
+    (add-css-information-to-doc options ssdoc doc)
 
     (let ((t (gnc:make-html-table)))
       ;; we don't want a bevel for this table, but we don't want
diff --git a/gnucash/report/stylesheets/stylesheet-plain.scm b/gnucash/report/stylesheets/stylesheet-plain.scm
index 511f00d..2a9d7e3 100644
--- a/gnucash/report/stylesheets/stylesheet-plain.scm
+++ b/gnucash/report/stylesheets/stylesheet-plain.scm
@@ -216,7 +216,7 @@
      ssdoc "a"
      'tag ""))
 
-    (add-css-information-to-doc options ssdoc)
+    (add-css-information-to-doc options ssdoc doc)
 
     (let* ((title (gnc:html-document-title doc))
            (doc-headline (gnc:html-document-headline doc))

commit da0160add8ea1007870cac9c479d22ef7517f4c5
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun May 27 16:29:06 2018 +0800

    [test-cashflow-barchart] hide debugging messages
    
    These tests pass. Don't need debugging output anymore.

diff --git a/gnucash/report/standard-reports/test/test-cashflow-barchart.scm b/gnucash/report/standard-reports/test/test-cashflow-barchart.scm
index 248468a..ecb3493 100644
--- a/gnucash/report/standard-reports/test/test-cashflow-barchart.scm
+++ b/gnucash/report/standard-reports/test/test-cashflow-barchart.scm
@@ -95,8 +95,8 @@
         (set-option report gnc:pagename-general "Price Source" 'pricedb-nearest)
         (set-option report gnc:pagename-general "Report's currency"  (gnc-default-report-currency))
         (set-option report gnc:pagename-accounts "Accounts" (list wallet-account bank-account))
-        (format #t "Create first transaction on ~a~%" (gnc-ctime date-1))
-        (format #t "Create second transaction on ~a~%" (gnc-ctime date-2))
+        ;; (format #t "Create first transaction on ~a~%" (gnc-ctime date-1))
+        ;; (format #t "Create second transaction on ~a~%" (gnc-ctime date-2))
         (let ((doc (renderer report)))
           (gnc:html-document-set-style-sheet! doc (gnc:report-stylesheet report))
           (let* ((result (gnc:html-document-render doc #f))
@@ -114,7 +114,7 @@
                                                  (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
                                                  (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1))
                                            result))))
-            (format #t "Report Result ~a~%" result)
+            ;; (format #t "Report Result ~a~%" result)
             (and (every (lambda (row)                 ; test in=net & out=0 in all rows (all days)
                           (and (or (equal? (second row) (fourth row))
                                    (begin (format #t "Failed, ~a and ~a differ~%" (second row) (fourth row)) #f))



Summary of changes:
 gnucash/report/report-system/CMakeLists.txt        |   1 +
 gnucash/report/report-system/html-anytag.scm       | 121 +++++++++++++++++++++
 gnucash/report/report-system/html-document.scm     |   3 +
 gnucash/report/report-system/html-fonts.scm        |   3 +-
 gnucash/report/report-system/report-system.scm     |  15 +++
 .../test/test-cashflow-barchart.scm                |   6 +-
 gnucash/report/stylesheets/stylesheet-easy.scm     |   2 +-
 gnucash/report/stylesheets/stylesheet-fancy.scm    |   2 +-
 gnucash/report/stylesheets/stylesheet-footer.scm   |   2 +-
 .../report/stylesheets/stylesheet-head-or-tail.scm |   2 +-
 gnucash/report/stylesheets/stylesheet-plain.scm    |   2 +-
 11 files changed, 150 insertions(+), 9 deletions(-)
 create mode 100644 gnucash/report/report-system/html-anytag.scm



More information about the gnucash-changes mailing list