[gnus git] branch master updated: m0-7-55-gcdcf29e =1= Handle hidden form elements

Lars Magne Ingebrigtsen <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  cdcf29eb1e925d1aa29f8d393a5a81441448dcfb (commit)
      from  7869a1c0ab015c5d7ba42c64c0396c877e24e9fd (commit)


- Log -----------------------------------------------------------------
commit cdcf29eb1e925d1aa29f8d393a5a81441448dcfb
Author: Lars Magne Ingebrigtsen <[email protected]>
Date:   Mon Jun 10 23:07:24 2013 +0200

    Handle hidden form elements
    
    (eww-submit): Handle hidden elements.
    
    * shr.el (shr-final-table-render): New variable to signal when we're
    doing the final table rendering so that we can collect more data at
    that point.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e6f4180..e90dfc9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,8 +1,13 @@
 2013-06-10  Lars Magne Ingebrigtsen  <[email protected]>
 
+	* shr.el (shr-final-table-render): New variable to signal when we're
+	doing the final table rendering so that we can collect more data at
+	that point.
+
 	* eww.el (eww-submit): Make form submission work.
 	(eww-tag-input): Implement submit buttons.
 	(eww-click-radio): Implement radio and checkboxes.
+	(eww-submit): Handle hidden elements.
 
 	* shr.el (shr-descend): Allow other packages to override (or provide)
 	rendering of elements.
diff --git a/lisp/eww.el b/lisp/eww.el
index 5e893be..4fbe89c 100644
--- a/lisp/eww.el
+++ b/lisp/eww.el
@@ -201,6 +201,10 @@
 		  :checkbox-value (cdr (assq :value cont))
 		  :eww-form eww-form
 		  (cdr (assq :checked cont))))
+	   ((equal type "hidden")
+	    (list 'hidden
+		  :name (cdr (assq :name cont))
+		  :value (cdr (assq :value cont))))
 	   (t
 	    (list
 	     'editable-field
@@ -211,7 +215,10 @@
 	     :action 'eww-submit
 	     :name (cdr (assq :name cont))
 	     :eww-form eww-form)))))
-    (apply 'widget-create widget)
+    (if (eq (car widget) 'hidden)
+	(when shr-final-table-render
+	  (nconc eww-form (list widget)))
+      (apply 'widget-create widget))
     (put-text-property start (point) 'eww-widget widget)))
 
 (defun eww-click-radio (widget &rest ignore)
@@ -233,7 +240,8 @@
 	values)
     (dolist (overlay (overlays-in (point-min) (point-max)))
       (let ((field (or (getf (overlay-properties overlay) 'field)
-		       (getf (overlay-properties overlay) 'button))))
+		       (getf (overlay-properties overlay) 'button)
+		       (getf (overlay-properties overlay) 'eww-hidden))))
 	(when (eq (getf (cdr field) :eww-form) form)
 	  (let ((name (getf (cdr field) :name)))
 	    (when name
@@ -242,10 +250,18 @@
 		(when (widget-value field)
 		  (push (cons name (getf (cdr field) :checkbox-value))
 			values)))
+	       ((eq (car field) 'eww-hidden)
+		(push (cons name (getf (cdr field) :value))
+		      values))
 	       (t
 		(push (cons name (widget-value field))
 		      values))))))))
-    (debug values)
+    (dolist (elem form)
+      (when (and (consp elem)
+		 (eq (car elem) 'hidden))
+	(push (cons (getf (cdr elem) :name)
+		    (getf (cdr elem) :value))
+	      values)))
     (let ((shr-base eww-current-url))
       (if (and (stringp (getf form :method))
 	       (equal (downcase (getf form :method)) "post"))
@@ -272,8 +288,7 @@
 
 (defun eww-fix-widget-keymap ()
   (dolist (overlay (overlays-in (point-min) (point-max)))
-    (when (or (getf (overlay-properties overlay) 'field)
-	      (getf (overlay-properties overlay) 'button))
+    (when (getf (overlay-properties overlay) 'button)
       (overlay-put overlay 'local-map widget-keymap))))
 
 (provide 'eww)
diff --git a/lisp/shr.el b/lisp/shr.el
index bf9f5a4..7a63675 100644
--- a/lisp/shr.el
+++ b/lisp/shr.el
@@ -115,6 +115,7 @@ cid: URL as the argument.")
 (defvar shr-base nil)
 (defvar shr-ignore-cache nil)
 (defvar shr-external-rendering-functions nil)
+(defvar shr-final-table-render nil)
 
 (defvar shr-map
   (let ((map (make-sparse-keymap)))
@@ -1177,7 +1178,8 @@ ones, in case fg and bg are nil."
 	     (frame-width))
       (setq truncate-lines t))
     ;; Then render the table again with these new "hard" widths.
-    (shr-insert-table (shr-make-table cont sketch-widths t) sketch-widths))
+    (let ((shr-final-table-render t))
+      (shr-insert-table (shr-make-table cont sketch-widths t) sketch-widths)))
   ;; Finally, insert all the images after the table.  The Emacs buffer
   ;; model isn't strong enough to allow us to put the images actually
   ;; into the tables.

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog |    5 +++++
 lisp/eww.el    |   25 ++++++++++++++++++++-----
 lisp/shr.el    |    4 +++-
 3 files changed, 28 insertions(+), 6 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.