emacs/lisp/net/newst-reader.el

356 lines
14 KiB
EmacsLisp
Raw Normal View History

2008-06-13 17:08:25 +00:00
;;; newst-reader.el --- Generic RSS reader functions.
2008-06-08 15:36:18 +00:00
;; Copyright (C) 2003-2015 Free Software Foundation, Inc.
2008-06-08 15:36:18 +00:00
;; Author: Ulf Jasper <ulf.jasper@web.de>
2008-06-13 17:08:25 +00:00
;; Filename: newst-reader.el
2008-06-08 15:36:18 +00:00
;; URL: http://www.nongnu.org/newsticker
;; Package: newsticker
2008-06-08 15:36:18 +00:00
;; ======================================================================
2008-06-10 03:29:43 +00:00
;; This file is part of GNU Emacs.
2008-06-08 15:36:18 +00:00
;; GNU Emacs 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 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;; ======================================================================
;;; Commentary:
;; See newsticker.el
;; ======================================================================
;;; Code:
2009-12-06 19:49:04 +00:00
(require 'newst-backend)
2008-06-08 15:36:18 +00:00
;; ======================================================================
;;; Customization
;; ======================================================================
(defun newsticker--set-customvar-formatting (symbol value)
"Set newsticker-variable SYMBOL value to VALUE.
Calls all actions which are necessary in order to make the new
value effective."
(if (or (not (boundp symbol))
(equal (symbol-value symbol) value))
(set symbol value)
;; something must have changed
(set symbol value)
(when (fboundp 'newsticker--forget-preformatted)
(newsticker--forget-preformatted))))
;; ======================================================================
;; reader
(defgroup newsticker-reader nil
"Settings for the feed reader."
:group 'newsticker)
(defcustom newsticker-frontend
'newsticker-treeview
"Newsticker frontend for reading news.
This must be one of the functions `newsticker-plainview' or
`newsticker-treeview'."
:type '(choice :tag "Frontend"
(const :tag "Single buffer (plainview)" newsticker-plainview)
(const :tag "Tree view (treeview)" newsticker-treeview))
:group 'newsticker-reader)
;; image related things
Newsticker: Use libxml instead of `xml-parse-region'. Fix some glitches. Clean up. * lisp/net/newst-backend.el: Remove Time-stamp. Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--sentinel-work): Move xml-workarounds to function `newsticker--do-xml-workarounds', call unless libxml-parser is used. Allow single quote in regexp for encoding. Use libxml-parser if available, else fall back to `xml-parse-region'. Take care of possibly missing namespace prefixes (like "RDF" instead of "rdf:RDF") when checking xml nodes and attributes (as libxml correctly removes the prefixes). Always use Atom 1.0 as fallback feed type. Rename `newsticker--download-logos' to `newsticker-download-logos' (newsticker--unxml, newsticker--unxml-node) (newsticker--unxml-attribute): New. (newsticker--parse-atom-1.0): Call `unxml' in case that embedded HTML code has become part of the xml parse tree. (newsticker--parse-rss-1.0, newsticker--parse-rss-2.0): Take care of possibly missing namespace prefixes. (newsticker--parse-generic-items): Code formatting. Typo. (newsticker--images-dir): Add trailing slash. (newsticker--image-get): Fix error message. * lisp/net/newst-plainview.el: Remove Time-stamp. * lisp/net/newst-reader.el: Remove Time-stamp. (newsticker-download-logos): Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--print-extra-elements): Add optional parameter 'htmlish for using html markup. Amend list of ignored elements. (newsticker--do-print-extra-element): Add parameter 'htmlish for using html markup. * lisp/net/newst-ticker.el: Remove Time-stamp. * lisp/net/newst-treeview.el (newsticker--treeview-item-show): Use html for formatting extra elements. * lisp/net/newsticker.el: Remove Time-stamp, Version. (newsticker-version): Make obsolete.
2014-10-01 19:20:00 +02:00
(defcustom newsticker-download-logos
t
"If non-nil newsticker downloads logo images of subscribed feeds."
:type 'boolean
:group 'newsticker-reader)
2008-06-08 15:36:18 +00:00
(defcustom newsticker-enable-logo-manipulations
t
"If non-nil newsticker manipulates logo images.
This enables the following image properties: heuristic mask for all
logos, and laplace-conversion for images without new items."
:type 'boolean
:group 'newsticker-reader)
(defcustom newsticker-justification
'left
"How to fill item descriptions.
If non-nil newsticker calls `fill-region' to wrap long lines in
item descriptions. However, if an item description contains HTML
text and `newsticker-html-renderer' is non-nil, filling is not
done."
:type '(choice :tag "Justification"
(const :tag "No filling" nil)
(const :tag "Left" left)
(const :tag "Right" right)
(const :tag "Center" center)
(const :tag "Full" full))
:set 'newsticker--set-customvar-formatting
:group 'newsticker-reader)
(defcustom newsticker-use-full-width
t
"Decides whether to use the full window width when filling.
If non-nil newsticker sets `fill-column' so that the whole
window is used when filling. See also `newsticker-justification'."
:type 'boolean
:set 'newsticker--set-customvar-formatting
:group 'newsticker-reader)
(defcustom newsticker-html-renderer
(if (fboundp 'libxml-parse-html-region)
#'shr-render-region)
2008-06-08 15:36:18 +00:00
"Function for rendering HTML contents.
If non-nil, newsticker.el will call this function whenever it
Newsticker: Show feedicons in treeview. Small fix in opml export. * etc/images/newsticker/README: Add rss-feed.png, rss-feed.svg. * etc/images/newsticker/rss-feed.png: New. * etc/images/newsticker/rss-feed.svg: New. * lisp/net/newst-backend.el: Require url-parse. (newsticker--get-news-by-wget): Store feed name as process property. (newsticker--sentinel): Read feed name from process property. (newsticker--sentinel-work): Rename argument name to feed-name. Rename variable imageurl to image-url. Pick icon url from Atom 1.0 data. Launch download of feed icon. (newsticker--get-icon-url-atom-1.0): New. (newsticker--unxml) (newsticker--unxml-node) (newsticker--unxml-attribute): Documentation. (newsticker--icons-dir): New. (newsticker--image-get): New arguments FILENAME and DIRECTORY. Use `url-retrieve' if `newsticker-retrieval-method' is 'intern. (newsticker--image-download-by-wget): New. Use process properties for storing informations. (newsticker--image-sentinel): Read informations from process properties. (newsticker--image-save) (newsticker--image-remove) (newsticker--image-download-by-url) (newsticker--image-download-by-url-callback): New. (newsticker-opml-export): Handle url list entries containing a function instead of an url string. * lisp/net/newst-reader.el (newsticker-html-renderer): Whitespace. (newsticker--print-extra-elements) (newsticker--do-print-extra-element): Documentation (newsticker--image-read): Optionally limit image height. Use imagemagick if possible. (newsticker--icon-read): New. * lisp/net/newst-treeview.el (newsticker--treeview-item-show): Limit height of feed logo. (newsticker--treeview-tree-expand): Use feed icons in treeview. (newsticker--tree-widget-icon-create): New. Set the tree widget icon. (newsticker--tree-widget-leaf-icon): Use feed icon.
2014-10-19 18:50:15 +02:00
finds HTML-like tags in item descriptions.
Possible functions include `shr-render-region', `w3m-region', `w3-region', and
`newsticker-htmlr-render'.
Newsticker automatically loads the respective package w3m, w3, or
htmlr if this option is set."
2008-06-08 15:36:18 +00:00
:type '(choice :tag "Function"
(const :tag "None" nil)
(const :tag "SHR" shr-render-region)
2008-06-08 15:36:18 +00:00
(const :tag "w3" w3-region)
(const :tag "w3m" w3m-region)
(const :tag "htmlr" newsticker-htmlr-render))
:set 'newsticker--set-customvar-formatting
:group 'newsticker-reader)
(defcustom newsticker-date-format
"(%A, %H:%M)"
"Format for the date part in item and feed lines.
See `format-time-string' for a list of valid specifiers."
:type 'string
:set 'newsticker--set-customvar-formatting
:group 'newsticker-reader)
(defgroup newsticker-faces nil
"Settings for the faces of the feed reader."
:group 'newsticker-reader)
(defface newsticker-feed-face
Face cleanups. Remove some uses of old-style face spec and :bold/:italic. * faces.el (set-face-attribute): Doc fix. (modify-face): Don't use :bold and :italic. (error, warning, success): Tweak definitions. * cus-edit.el (custom-modified, custom-invalid, custom-rogue) (custom-modified, custom-set, custom-changed, custom-themed) (custom-saved, custom-button, custom-button-mouse) (custom-button-pressed, custom-state, custom-comment-tag) (custom-variable-tag, custom-group-tag-1, custom-group-tag) (custom-group-subtitle): Use new-style face specs. (custom-invalid-face, custom-rogue-face, custom-modified-face) (custom-set-face, custom-changed-face, custom-saved-face) (custom-button-face, custom-button-pressed-face) (custom-documentation-face, custom-state-face) (custom-comment-face, custom-comment-tag-face) (custom-variable-tag-face, custom-variable-button-face) (custom-face-tag-face, custom-group-tag-face-1) (custom-group-tag-face): Remove obsolete face alias. * epa.el (epa-validity-high, epa-validity-medium) (epa-validity-low, epa-mark, epa-field-name, epa-string) (epa-field-name, epa-field-body): * font-lock.el (font-lock-comment-face, font-lock-string-face) (font-lock-keyword-face, font-lock-builtin-face) (font-lock-function-name-face, font-lock-variable-name-face) (font-lock-type-face, font-lock-constant-face): * ido.el (ido-first-match, ido-only-match, ido-subdir) (ido-virtual, ido-indicator, ido-incomplete-regexp): * speedbar.el (speedbar-button-face, speedbar-file-face) (speedbar-directory-face, speedbar-tag-face) (speedbar-selected-face, speedbar-highlight-face) (speedbar-separator-face): * whitespace.el (whitespace-newline, whitespace-space) (whitespace-hspace, whitespace-tab, whitespace-trailing) (whitespace-line, whitespace-space-before-tab) (whitespace-space-after-tab, whitespace-indentation) (whitespace-empty): * emulation/cua-base.el (cua-global-mark): * eshell/em-prompt.el (eshell-prompt): * net/newst-plainview.el (newsticker-new-item-face) (newsticker-old-item-face, newsticker-immortal-item-face) (newsticker-obsolete-item-face, newsticker-date-face) (newsticker-statistics-face, newsticker-default-face): * net/newst-reader.el (newsticker-feed-face) (newsticker-extra-face, newsticker-enclosure-face): * net/newst-treeview.el (newsticker-treeview-face) (newsticker-treeview-new-face, newsticker-treeview-old-face) (newsticker-treeview-immortal-face) (newsticker-treeview-obsolete-face) (newsticker-treeview-selection-face): * net/rcirc.el (rcirc-my-nick, rcirc-other-nick) (rcirc-bright-nick, rcirc-server, rcirc-timestamp) (rcirc-nick-in-message, rcirc-nick-in-message-full-line) (rcirc-prompt, rcirc-track-keyword, rcirc-url, rcirc-keyword): * nxml/nxml-outln.el (nxml-heading, nxml-outline-indicator) (nxml-outline-active-indicator, nxml-outline-ellipsis): * play/mpuz.el (mpuz-unsolved, mpuz-solved, mpuz-trivial) (mpuz-text): * progmodes/vera-mode.el (vera-font-lock-number) (vera-font-lock-function, vera-font-lock-interface): * textmodes/table.el (table-cell): Use new-style face specs, and don't use the old :bold and :italic attributes. * erc-button.el (erc-button): * erc-goodies.el (erc-bold-face, erc-inverse-face) (erc-underline-face, fg:erc-color-*): * erc-match.el (erc-current-nick-face, erc-dangerous-host-face) (erc-pal-face, erc-fool-face, erc-keyword-face): * erc-stamp.el (erc-timestamp-face): Likewise. * erc.el (erc-direct-msg-face, erc-header-line, erc-input-face) (erc-command-indicator-face, erc-notice-face, erc-action-face) (erc-error-face, erc-my-nick-face, erc-nick-default-face) (erc-nick-msg-face): Use new-style face specs, and avoid :bold. * progmodes/ebrowse.el (ebrowse-tree-mark, ebrowse-root-class) (ebrowse-member-attribute, ebrowse-default, ebrowse-file-name) (ebrowse-member-class, ebrowse-progress): Likewise. (ebrowse-tree-mark-face, ebrowse-root-class-face) (ebrowse-file-name-face, ebrowse-default-face) (ebrowse-member-attribute-face, ebrowse-member-class-face) (ebrowse-progress-face): Remove obsolete faces. * progmodes/flymake.el (flymake-errline, flymake-warnline): Inherit from error and warning faces respectively. * textmodes/flyspell.el (flyspell-incorrect, flyspell-duplicate): Likewise. (flyspell-incorrect-face, flyspell-duplicate-face): Remove obsolete aliases. * display.texi (Face Attributes): Font family does not accept wildcards. De-document obsolete :bold and :italic attributes. (Defining Faces): Use new-style face spec format.
2012-06-09 00:39:49 +08:00
'((default :weight bold :height 1.2)
(((class color) (background dark)) :foreground "white")
(((class color) (background light)) :foreground "black"))
"Face for news feeds."
:group 'newsticker-faces)
(defface newsticker-extra-face
Face cleanups. Remove some uses of old-style face spec and :bold/:italic. * faces.el (set-face-attribute): Doc fix. (modify-face): Don't use :bold and :italic. (error, warning, success): Tweak definitions. * cus-edit.el (custom-modified, custom-invalid, custom-rogue) (custom-modified, custom-set, custom-changed, custom-themed) (custom-saved, custom-button, custom-button-mouse) (custom-button-pressed, custom-state, custom-comment-tag) (custom-variable-tag, custom-group-tag-1, custom-group-tag) (custom-group-subtitle): Use new-style face specs. (custom-invalid-face, custom-rogue-face, custom-modified-face) (custom-set-face, custom-changed-face, custom-saved-face) (custom-button-face, custom-button-pressed-face) (custom-documentation-face, custom-state-face) (custom-comment-face, custom-comment-tag-face) (custom-variable-tag-face, custom-variable-button-face) (custom-face-tag-face, custom-group-tag-face-1) (custom-group-tag-face): Remove obsolete face alias. * epa.el (epa-validity-high, epa-validity-medium) (epa-validity-low, epa-mark, epa-field-name, epa-string) (epa-field-name, epa-field-body): * font-lock.el (font-lock-comment-face, font-lock-string-face) (font-lock-keyword-face, font-lock-builtin-face) (font-lock-function-name-face, font-lock-variable-name-face) (font-lock-type-face, font-lock-constant-face): * ido.el (ido-first-match, ido-only-match, ido-subdir) (ido-virtual, ido-indicator, ido-incomplete-regexp): * speedbar.el (speedbar-button-face, speedbar-file-face) (speedbar-directory-face, speedbar-tag-face) (speedbar-selected-face, speedbar-highlight-face) (speedbar-separator-face): * whitespace.el (whitespace-newline, whitespace-space) (whitespace-hspace, whitespace-tab, whitespace-trailing) (whitespace-line, whitespace-space-before-tab) (whitespace-space-after-tab, whitespace-indentation) (whitespace-empty): * emulation/cua-base.el (cua-global-mark): * eshell/em-prompt.el (eshell-prompt): * net/newst-plainview.el (newsticker-new-item-face) (newsticker-old-item-face, newsticker-immortal-item-face) (newsticker-obsolete-item-face, newsticker-date-face) (newsticker-statistics-face, newsticker-default-face): * net/newst-reader.el (newsticker-feed-face) (newsticker-extra-face, newsticker-enclosure-face): * net/newst-treeview.el (newsticker-treeview-face) (newsticker-treeview-new-face, newsticker-treeview-old-face) (newsticker-treeview-immortal-face) (newsticker-treeview-obsolete-face) (newsticker-treeview-selection-face): * net/rcirc.el (rcirc-my-nick, rcirc-other-nick) (rcirc-bright-nick, rcirc-server, rcirc-timestamp) (rcirc-nick-in-message, rcirc-nick-in-message-full-line) (rcirc-prompt, rcirc-track-keyword, rcirc-url, rcirc-keyword): * nxml/nxml-outln.el (nxml-heading, nxml-outline-indicator) (nxml-outline-active-indicator, nxml-outline-ellipsis): * play/mpuz.el (mpuz-unsolved, mpuz-solved, mpuz-trivial) (mpuz-text): * progmodes/vera-mode.el (vera-font-lock-number) (vera-font-lock-function, vera-font-lock-interface): * textmodes/table.el (table-cell): Use new-style face specs, and don't use the old :bold and :italic attributes. * erc-button.el (erc-button): * erc-goodies.el (erc-bold-face, erc-inverse-face) (erc-underline-face, fg:erc-color-*): * erc-match.el (erc-current-nick-face, erc-dangerous-host-face) (erc-pal-face, erc-fool-face, erc-keyword-face): * erc-stamp.el (erc-timestamp-face): Likewise. * erc.el (erc-direct-msg-face, erc-header-line, erc-input-face) (erc-command-indicator-face, erc-notice-face, erc-action-face) (erc-error-face, erc-my-nick-face, erc-nick-default-face) (erc-nick-msg-face): Use new-style face specs, and avoid :bold. * progmodes/ebrowse.el (ebrowse-tree-mark, ebrowse-root-class) (ebrowse-member-attribute, ebrowse-default, ebrowse-file-name) (ebrowse-member-class, ebrowse-progress): Likewise. (ebrowse-tree-mark-face, ebrowse-root-class-face) (ebrowse-file-name-face, ebrowse-default-face) (ebrowse-member-attribute-face, ebrowse-member-class-face) (ebrowse-progress-face): Remove obsolete faces. * progmodes/flymake.el (flymake-errline, flymake-warnline): Inherit from error and warning faces respectively. * textmodes/flyspell.el (flyspell-incorrect, flyspell-duplicate): Likewise. (flyspell-incorrect-face, flyspell-duplicate-face): Remove obsolete aliases. * display.texi (Face Attributes): Font family does not accept wildcards. De-document obsolete :bold and :italic attributes. (Defining Faces): Use new-style face spec format.
2012-06-09 00:39:49 +08:00
'((default :slant italic :height 0.8)
(((class color) (background dark)) :foreground "gray50")
(((class color) (background light)) :foreground "gray50"))
"Face for newsticker dates."
:group 'newsticker-faces)
(defface newsticker-enclosure-face
Face cleanups. Remove some uses of old-style face spec and :bold/:italic. * faces.el (set-face-attribute): Doc fix. (modify-face): Don't use :bold and :italic. (error, warning, success): Tweak definitions. * cus-edit.el (custom-modified, custom-invalid, custom-rogue) (custom-modified, custom-set, custom-changed, custom-themed) (custom-saved, custom-button, custom-button-mouse) (custom-button-pressed, custom-state, custom-comment-tag) (custom-variable-tag, custom-group-tag-1, custom-group-tag) (custom-group-subtitle): Use new-style face specs. (custom-invalid-face, custom-rogue-face, custom-modified-face) (custom-set-face, custom-changed-face, custom-saved-face) (custom-button-face, custom-button-pressed-face) (custom-documentation-face, custom-state-face) (custom-comment-face, custom-comment-tag-face) (custom-variable-tag-face, custom-variable-button-face) (custom-face-tag-face, custom-group-tag-face-1) (custom-group-tag-face): Remove obsolete face alias. * epa.el (epa-validity-high, epa-validity-medium) (epa-validity-low, epa-mark, epa-field-name, epa-string) (epa-field-name, epa-field-body): * font-lock.el (font-lock-comment-face, font-lock-string-face) (font-lock-keyword-face, font-lock-builtin-face) (font-lock-function-name-face, font-lock-variable-name-face) (font-lock-type-face, font-lock-constant-face): * ido.el (ido-first-match, ido-only-match, ido-subdir) (ido-virtual, ido-indicator, ido-incomplete-regexp): * speedbar.el (speedbar-button-face, speedbar-file-face) (speedbar-directory-face, speedbar-tag-face) (speedbar-selected-face, speedbar-highlight-face) (speedbar-separator-face): * whitespace.el (whitespace-newline, whitespace-space) (whitespace-hspace, whitespace-tab, whitespace-trailing) (whitespace-line, whitespace-space-before-tab) (whitespace-space-after-tab, whitespace-indentation) (whitespace-empty): * emulation/cua-base.el (cua-global-mark): * eshell/em-prompt.el (eshell-prompt): * net/newst-plainview.el (newsticker-new-item-face) (newsticker-old-item-face, newsticker-immortal-item-face) (newsticker-obsolete-item-face, newsticker-date-face) (newsticker-statistics-face, newsticker-default-face): * net/newst-reader.el (newsticker-feed-face) (newsticker-extra-face, newsticker-enclosure-face): * net/newst-treeview.el (newsticker-treeview-face) (newsticker-treeview-new-face, newsticker-treeview-old-face) (newsticker-treeview-immortal-face) (newsticker-treeview-obsolete-face) (newsticker-treeview-selection-face): * net/rcirc.el (rcirc-my-nick, rcirc-other-nick) (rcirc-bright-nick, rcirc-server, rcirc-timestamp) (rcirc-nick-in-message, rcirc-nick-in-message-full-line) (rcirc-prompt, rcirc-track-keyword, rcirc-url, rcirc-keyword): * nxml/nxml-outln.el (nxml-heading, nxml-outline-indicator) (nxml-outline-active-indicator, nxml-outline-ellipsis): * play/mpuz.el (mpuz-unsolved, mpuz-solved, mpuz-trivial) (mpuz-text): * progmodes/vera-mode.el (vera-font-lock-number) (vera-font-lock-function, vera-font-lock-interface): * textmodes/table.el (table-cell): Use new-style face specs, and don't use the old :bold and :italic attributes. * erc-button.el (erc-button): * erc-goodies.el (erc-bold-face, erc-inverse-face) (erc-underline-face, fg:erc-color-*): * erc-match.el (erc-current-nick-face, erc-dangerous-host-face) (erc-pal-face, erc-fool-face, erc-keyword-face): * erc-stamp.el (erc-timestamp-face): Likewise. * erc.el (erc-direct-msg-face, erc-header-line, erc-input-face) (erc-command-indicator-face, erc-notice-face, erc-action-face) (erc-error-face, erc-my-nick-face, erc-nick-default-face) (erc-nick-msg-face): Use new-style face specs, and avoid :bold. * progmodes/ebrowse.el (ebrowse-tree-mark, ebrowse-root-class) (ebrowse-member-attribute, ebrowse-default, ebrowse-file-name) (ebrowse-member-class, ebrowse-progress): Likewise. (ebrowse-tree-mark-face, ebrowse-root-class-face) (ebrowse-file-name-face, ebrowse-default-face) (ebrowse-member-attribute-face, ebrowse-member-class-face) (ebrowse-progress-face): Remove obsolete faces. * progmodes/flymake.el (flymake-errline, flymake-warnline): Inherit from error and warning faces respectively. * textmodes/flyspell.el (flyspell-incorrect, flyspell-duplicate): Likewise. (flyspell-incorrect-face, flyspell-duplicate-face): Remove obsolete aliases. * display.texi (Face Attributes): Font family does not accept wildcards. De-document obsolete :bold and :italic attributes. (Defining Faces): Use new-style face spec format.
2012-06-09 00:39:49 +08:00
'((default :weight bold)
(((class color) (background dark)) :background "orange")
(((class color) (background light)) :background "orange"))
"Face for enclosed elements."
:group 'newsticker-faces)
2008-06-08 15:36:18 +00:00
;; ======================================================================
;;; Utility functions
;; ======================================================================
(defun newsticker--insert-enclosure (item keymap)
"Insert enclosure element of a news ITEM into the current buffer.
KEYMAP will be applied."
(let ((enclosure (newsticker--enclosure item))
(beg (point)))
(when enclosure
(let ((url (cdr (assoc 'url enclosure)))
(length (string-to-number (or (cdr (assoc 'length enclosure))
"-1")))
(type (cdr (assoc 'type enclosure))))
(cond ((> length 1048576)
(insert (format "Enclosed file (%s, %1.2f MBytes)" type
(/ length 1048576))))
((> length 1024)
(insert (format "Enclosed file (%s, %1.2f KBytes)" type
(/ length 1024))))
((> length 0)
(insert (format "Enclosed file (%s, %1.2f Bytes)" type
length)))
(t
(insert (format "Enclosed file (%s, unknown size)" type))))
(add-text-properties beg (point)
(list 'mouse-face 'highlight
'nt-link url
'help-echo (format
"mouse-2: visit (%s)" url)
'keymap keymap
'nt-face 'enclosure
'nt-type 'desc))
(insert "\n")))))
Newsticker: Use libxml instead of `xml-parse-region'. Fix some glitches. Clean up. * lisp/net/newst-backend.el: Remove Time-stamp. Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--sentinel-work): Move xml-workarounds to function `newsticker--do-xml-workarounds', call unless libxml-parser is used. Allow single quote in regexp for encoding. Use libxml-parser if available, else fall back to `xml-parse-region'. Take care of possibly missing namespace prefixes (like "RDF" instead of "rdf:RDF") when checking xml nodes and attributes (as libxml correctly removes the prefixes). Always use Atom 1.0 as fallback feed type. Rename `newsticker--download-logos' to `newsticker-download-logos' (newsticker--unxml, newsticker--unxml-node) (newsticker--unxml-attribute): New. (newsticker--parse-atom-1.0): Call `unxml' in case that embedded HTML code has become part of the xml parse tree. (newsticker--parse-rss-1.0, newsticker--parse-rss-2.0): Take care of possibly missing namespace prefixes. (newsticker--parse-generic-items): Code formatting. Typo. (newsticker--images-dir): Add trailing slash. (newsticker--image-get): Fix error message. * lisp/net/newst-plainview.el: Remove Time-stamp. * lisp/net/newst-reader.el: Remove Time-stamp. (newsticker-download-logos): Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--print-extra-elements): Add optional parameter 'htmlish for using html markup. Amend list of ignored elements. (newsticker--do-print-extra-element): Add parameter 'htmlish for using html markup. * lisp/net/newst-ticker.el: Remove Time-stamp. * lisp/net/newst-treeview.el (newsticker--treeview-item-show): Use html for formatting extra elements. * lisp/net/newsticker.el: Remove Time-stamp, Version. (newsticker-version): Make obsolete.
2014-10-01 19:20:00 +02:00
(defun newsticker--print-extra-elements (item keymap &optional htmlish)
2008-06-08 15:36:18 +00:00
"Insert extra-elements of ITEM in a pretty form into the current buffer.
Newsticker: Show feedicons in treeview. Small fix in opml export. * etc/images/newsticker/README: Add rss-feed.png, rss-feed.svg. * etc/images/newsticker/rss-feed.png: New. * etc/images/newsticker/rss-feed.svg: New. * lisp/net/newst-backend.el: Require url-parse. (newsticker--get-news-by-wget): Store feed name as process property. (newsticker--sentinel): Read feed name from process property. (newsticker--sentinel-work): Rename argument name to feed-name. Rename variable imageurl to image-url. Pick icon url from Atom 1.0 data. Launch download of feed icon. (newsticker--get-icon-url-atom-1.0): New. (newsticker--unxml) (newsticker--unxml-node) (newsticker--unxml-attribute): Documentation. (newsticker--icons-dir): New. (newsticker--image-get): New arguments FILENAME and DIRECTORY. Use `url-retrieve' if `newsticker-retrieval-method' is 'intern. (newsticker--image-download-by-wget): New. Use process properties for storing informations. (newsticker--image-sentinel): Read informations from process properties. (newsticker--image-save) (newsticker--image-remove) (newsticker--image-download-by-url) (newsticker--image-download-by-url-callback): New. (newsticker-opml-export): Handle url list entries containing a function instead of an url string. * lisp/net/newst-reader.el (newsticker-html-renderer): Whitespace. (newsticker--print-extra-elements) (newsticker--do-print-extra-element): Documentation (newsticker--image-read): Optionally limit image height. Use imagemagick if possible. (newsticker--icon-read): New. * lisp/net/newst-treeview.el (newsticker--treeview-item-show): Limit height of feed logo. (newsticker--treeview-tree-expand): Use feed icons in treeview. (newsticker--tree-widget-icon-create): New. Set the tree widget icon. (newsticker--tree-widget-leaf-icon): Use feed icon.
2014-10-19 18:50:15 +02:00
KEYMAP is applied. If HTMLISH is non-nil then HTML-markup is used
for formatting."
2008-06-08 15:36:18 +00:00
(let ((ignored-elements '(items link title description content
Newsticker: Use libxml instead of `xml-parse-region'. Fix some glitches. Clean up. * lisp/net/newst-backend.el: Remove Time-stamp. Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--sentinel-work): Move xml-workarounds to function `newsticker--do-xml-workarounds', call unless libxml-parser is used. Allow single quote in regexp for encoding. Use libxml-parser if available, else fall back to `xml-parse-region'. Take care of possibly missing namespace prefixes (like "RDF" instead of "rdf:RDF") when checking xml nodes and attributes (as libxml correctly removes the prefixes). Always use Atom 1.0 as fallback feed type. Rename `newsticker--download-logos' to `newsticker-download-logos' (newsticker--unxml, newsticker--unxml-node) (newsticker--unxml-attribute): New. (newsticker--parse-atom-1.0): Call `unxml' in case that embedded HTML code has become part of the xml parse tree. (newsticker--parse-rss-1.0, newsticker--parse-rss-2.0): Take care of possibly missing namespace prefixes. (newsticker--parse-generic-items): Code formatting. Typo. (newsticker--images-dir): Add trailing slash. (newsticker--image-get): Fix error message. * lisp/net/newst-plainview.el: Remove Time-stamp. * lisp/net/newst-reader.el: Remove Time-stamp. (newsticker-download-logos): Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--print-extra-elements): Add optional parameter 'htmlish for using html markup. Amend list of ignored elements. (newsticker--do-print-extra-element): Add parameter 'htmlish for using html markup. * lisp/net/newst-ticker.el: Remove Time-stamp. * lisp/net/newst-treeview.el (newsticker--treeview-item-show): Use html for formatting extra elements. * lisp/net/newsticker.el: Remove Time-stamp, Version. (newsticker-version): Make obsolete.
2014-10-01 19:20:00 +02:00
content:encoded encoded
dc:subject subject
dc:date date entry item guid pubDate
2008-06-08 15:36:18 +00:00
published updated
enclosure))
(left-column-width 1))
Newsticker: Use libxml instead of `xml-parse-region'. Fix some glitches. Clean up. * lisp/net/newst-backend.el: Remove Time-stamp. Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--sentinel-work): Move xml-workarounds to function `newsticker--do-xml-workarounds', call unless libxml-parser is used. Allow single quote in regexp for encoding. Use libxml-parser if available, else fall back to `xml-parse-region'. Take care of possibly missing namespace prefixes (like "RDF" instead of "rdf:RDF") when checking xml nodes and attributes (as libxml correctly removes the prefixes). Always use Atom 1.0 as fallback feed type. Rename `newsticker--download-logos' to `newsticker-download-logos' (newsticker--unxml, newsticker--unxml-node) (newsticker--unxml-attribute): New. (newsticker--parse-atom-1.0): Call `unxml' in case that embedded HTML code has become part of the xml parse tree. (newsticker--parse-rss-1.0, newsticker--parse-rss-2.0): Take care of possibly missing namespace prefixes. (newsticker--parse-generic-items): Code formatting. Typo. (newsticker--images-dir): Add trailing slash. (newsticker--image-get): Fix error message. * lisp/net/newst-plainview.el: Remove Time-stamp. * lisp/net/newst-reader.el: Remove Time-stamp. (newsticker-download-logos): Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--print-extra-elements): Add optional parameter 'htmlish for using html markup. Amend list of ignored elements. (newsticker--do-print-extra-element): Add parameter 'htmlish for using html markup. * lisp/net/newst-ticker.el: Remove Time-stamp. * lisp/net/newst-treeview.el (newsticker--treeview-item-show): Use html for formatting extra elements. * lisp/net/newsticker.el: Remove Time-stamp, Version. (newsticker-version): Make obsolete.
2014-10-01 19:20:00 +02:00
(if htmlish (insert "<ul>"))
2008-06-08 15:36:18 +00:00
(mapc (lambda (extra-element)
(when (listp extra-element) ;; take care of broken xml
;; data, 2007-05-25
(unless (memq (car extra-element) ignored-elements)
(setq left-column-width (max left-column-width
(length (symbol-name
(car extra-element))))))))
(newsticker--extra item))
(mapc (lambda (extra-element)
(when (listp extra-element) ;; take care of broken xml
;; data, 2007-05-25
(unless (memq (car extra-element) ignored-elements)
(newsticker--do-print-extra-element extra-element
left-column-width
Newsticker: Use libxml instead of `xml-parse-region'. Fix some glitches. Clean up. * lisp/net/newst-backend.el: Remove Time-stamp. Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--sentinel-work): Move xml-workarounds to function `newsticker--do-xml-workarounds', call unless libxml-parser is used. Allow single quote in regexp for encoding. Use libxml-parser if available, else fall back to `xml-parse-region'. Take care of possibly missing namespace prefixes (like "RDF" instead of "rdf:RDF") when checking xml nodes and attributes (as libxml correctly removes the prefixes). Always use Atom 1.0 as fallback feed type. Rename `newsticker--download-logos' to `newsticker-download-logos' (newsticker--unxml, newsticker--unxml-node) (newsticker--unxml-attribute): New. (newsticker--parse-atom-1.0): Call `unxml' in case that embedded HTML code has become part of the xml parse tree. (newsticker--parse-rss-1.0, newsticker--parse-rss-2.0): Take care of possibly missing namespace prefixes. (newsticker--parse-generic-items): Code formatting. Typo. (newsticker--images-dir): Add trailing slash. (newsticker--image-get): Fix error message. * lisp/net/newst-plainview.el: Remove Time-stamp. * lisp/net/newst-reader.el: Remove Time-stamp. (newsticker-download-logos): Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--print-extra-elements): Add optional parameter 'htmlish for using html markup. Amend list of ignored elements. (newsticker--do-print-extra-element): Add parameter 'htmlish for using html markup. * lisp/net/newst-ticker.el: Remove Time-stamp. * lisp/net/newst-treeview.el (newsticker--treeview-item-show): Use html for formatting extra elements. * lisp/net/newsticker.el: Remove Time-stamp, Version. (newsticker-version): Make obsolete.
2014-10-01 19:20:00 +02:00
keymap
htmlish))))
(newsticker--extra item))
(if htmlish (insert "</ul>"))))
2008-06-08 15:36:18 +00:00
Newsticker: Use libxml instead of `xml-parse-region'. Fix some glitches. Clean up. * lisp/net/newst-backend.el: Remove Time-stamp. Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--sentinel-work): Move xml-workarounds to function `newsticker--do-xml-workarounds', call unless libxml-parser is used. Allow single quote in regexp for encoding. Use libxml-parser if available, else fall back to `xml-parse-region'. Take care of possibly missing namespace prefixes (like "RDF" instead of "rdf:RDF") when checking xml nodes and attributes (as libxml correctly removes the prefixes). Always use Atom 1.0 as fallback feed type. Rename `newsticker--download-logos' to `newsticker-download-logos' (newsticker--unxml, newsticker--unxml-node) (newsticker--unxml-attribute): New. (newsticker--parse-atom-1.0): Call `unxml' in case that embedded HTML code has become part of the xml parse tree. (newsticker--parse-rss-1.0, newsticker--parse-rss-2.0): Take care of possibly missing namespace prefixes. (newsticker--parse-generic-items): Code formatting. Typo. (newsticker--images-dir): Add trailing slash. (newsticker--image-get): Fix error message. * lisp/net/newst-plainview.el: Remove Time-stamp. * lisp/net/newst-reader.el: Remove Time-stamp. (newsticker-download-logos): Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--print-extra-elements): Add optional parameter 'htmlish for using html markup. Amend list of ignored elements. (newsticker--do-print-extra-element): Add parameter 'htmlish for using html markup. * lisp/net/newst-ticker.el: Remove Time-stamp. * lisp/net/newst-treeview.el (newsticker--treeview-item-show): Use html for formatting extra elements. * lisp/net/newsticker.el: Remove Time-stamp, Version. (newsticker-version): Make obsolete.
2014-10-01 19:20:00 +02:00
(defun newsticker--do-print-extra-element (extra-element width keymap htmlish)
2008-06-08 15:36:18 +00:00
"Actually print an EXTRA-ELEMENT using the given WIDTH.
Newsticker: Show feedicons in treeview. Small fix in opml export. * etc/images/newsticker/README: Add rss-feed.png, rss-feed.svg. * etc/images/newsticker/rss-feed.png: New. * etc/images/newsticker/rss-feed.svg: New. * lisp/net/newst-backend.el: Require url-parse. (newsticker--get-news-by-wget): Store feed name as process property. (newsticker--sentinel): Read feed name from process property. (newsticker--sentinel-work): Rename argument name to feed-name. Rename variable imageurl to image-url. Pick icon url from Atom 1.0 data. Launch download of feed icon. (newsticker--get-icon-url-atom-1.0): New. (newsticker--unxml) (newsticker--unxml-node) (newsticker--unxml-attribute): Documentation. (newsticker--icons-dir): New. (newsticker--image-get): New arguments FILENAME and DIRECTORY. Use `url-retrieve' if `newsticker-retrieval-method' is 'intern. (newsticker--image-download-by-wget): New. Use process properties for storing informations. (newsticker--image-sentinel): Read informations from process properties. (newsticker--image-save) (newsticker--image-remove) (newsticker--image-download-by-url) (newsticker--image-download-by-url-callback): New. (newsticker-opml-export): Handle url list entries containing a function instead of an url string. * lisp/net/newst-reader.el (newsticker-html-renderer): Whitespace. (newsticker--print-extra-elements) (newsticker--do-print-extra-element): Documentation (newsticker--image-read): Optionally limit image height. Use imagemagick if possible. (newsticker--icon-read): New. * lisp/net/newst-treeview.el (newsticker--treeview-item-show): Limit height of feed logo. (newsticker--treeview-tree-expand): Use feed icons in treeview. (newsticker--tree-widget-icon-create): New. Set the tree widget icon. (newsticker--tree-widget-leaf-icon): Use feed icon.
2014-10-19 18:50:15 +02:00
KEYMAP is applied. If HTMLISH is non-nil then HTML-markup is used
for formatting."
2008-06-08 15:36:18 +00:00
(let ((name (symbol-name (car extra-element))))
Newsticker: Use libxml instead of `xml-parse-region'. Fix some glitches. Clean up. * lisp/net/newst-backend.el: Remove Time-stamp. Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--sentinel-work): Move xml-workarounds to function `newsticker--do-xml-workarounds', call unless libxml-parser is used. Allow single quote in regexp for encoding. Use libxml-parser if available, else fall back to `xml-parse-region'. Take care of possibly missing namespace prefixes (like "RDF" instead of "rdf:RDF") when checking xml nodes and attributes (as libxml correctly removes the prefixes). Always use Atom 1.0 as fallback feed type. Rename `newsticker--download-logos' to `newsticker-download-logos' (newsticker--unxml, newsticker--unxml-node) (newsticker--unxml-attribute): New. (newsticker--parse-atom-1.0): Call `unxml' in case that embedded HTML code has become part of the xml parse tree. (newsticker--parse-rss-1.0, newsticker--parse-rss-2.0): Take care of possibly missing namespace prefixes. (newsticker--parse-generic-items): Code formatting. Typo. (newsticker--images-dir): Add trailing slash. (newsticker--image-get): Fix error message. * lisp/net/newst-plainview.el: Remove Time-stamp. * lisp/net/newst-reader.el: Remove Time-stamp. (newsticker-download-logos): Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--print-extra-elements): Add optional parameter 'htmlish for using html markup. Amend list of ignored elements. (newsticker--do-print-extra-element): Add parameter 'htmlish for using html markup. * lisp/net/newst-ticker.el: Remove Time-stamp. * lisp/net/newst-treeview.el (newsticker--treeview-item-show): Use html for formatting extra elements. * lisp/net/newsticker.el: Remove Time-stamp, Version. (newsticker-version): Make obsolete.
2014-10-01 19:20:00 +02:00
(if htmlish
(insert (format "<li>%s: " name))
(insert (format "%s: " name))
(insert (make-string (- width (length name)) ? ))))
2008-06-08 15:36:18 +00:00
(let (;;(attributes (cadr extra-element)) ;FIXME!!!!
(contents (cddr extra-element)))
(cond ((listp contents)
(mapc (lambda (i)
(if (and (stringp i)
(string-match "^http://.*" i))
(let ((pos (point)))
(insert i " ") ; avoid self-reference from the
; nt-link thing
(add-text-properties
pos (point)
(list 'mouse-face 'highlight
'nt-link i
'help-echo
(format "mouse-2: visit (%s)" i)
'keymap keymap)))
(insert (format "%s" i))))
contents))
(t
(insert (format "%s" contents))))
Newsticker: Use libxml instead of `xml-parse-region'. Fix some glitches. Clean up. * lisp/net/newst-backend.el: Remove Time-stamp. Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--sentinel-work): Move xml-workarounds to function `newsticker--do-xml-workarounds', call unless libxml-parser is used. Allow single quote in regexp for encoding. Use libxml-parser if available, else fall back to `xml-parse-region'. Take care of possibly missing namespace prefixes (like "RDF" instead of "rdf:RDF") when checking xml nodes and attributes (as libxml correctly removes the prefixes). Always use Atom 1.0 as fallback feed type. Rename `newsticker--download-logos' to `newsticker-download-logos' (newsticker--unxml, newsticker--unxml-node) (newsticker--unxml-attribute): New. (newsticker--parse-atom-1.0): Call `unxml' in case that embedded HTML code has become part of the xml parse tree. (newsticker--parse-rss-1.0, newsticker--parse-rss-2.0): Take care of possibly missing namespace prefixes. (newsticker--parse-generic-items): Code formatting. Typo. (newsticker--images-dir): Add trailing slash. (newsticker--image-get): Fix error message. * lisp/net/newst-plainview.el: Remove Time-stamp. * lisp/net/newst-reader.el: Remove Time-stamp. (newsticker-download-logos): Rename variable `newsticker--download-logos' to `newsticker-download-logos' and make it customizable. (newsticker--print-extra-elements): Add optional parameter 'htmlish for using html markup. Amend list of ignored elements. (newsticker--do-print-extra-element): Add parameter 'htmlish for using html markup. * lisp/net/newst-ticker.el: Remove Time-stamp. * lisp/net/newst-treeview.el (newsticker--treeview-item-show): Use html for formatting extra elements. * lisp/net/newsticker.el: Remove Time-stamp, Version. (newsticker-version): Make obsolete.
2014-10-01 19:20:00 +02:00
(if htmlish
(insert "</li>")
(insert "\n"))))
2008-06-08 15:36:18 +00:00
Newsticker: Show feedicons in treeview. Small fix in opml export. * etc/images/newsticker/README: Add rss-feed.png, rss-feed.svg. * etc/images/newsticker/rss-feed.png: New. * etc/images/newsticker/rss-feed.svg: New. * lisp/net/newst-backend.el: Require url-parse. (newsticker--get-news-by-wget): Store feed name as process property. (newsticker--sentinel): Read feed name from process property. (newsticker--sentinel-work): Rename argument name to feed-name. Rename variable imageurl to image-url. Pick icon url from Atom 1.0 data. Launch download of feed icon. (newsticker--get-icon-url-atom-1.0): New. (newsticker--unxml) (newsticker--unxml-node) (newsticker--unxml-attribute): Documentation. (newsticker--icons-dir): New. (newsticker--image-get): New arguments FILENAME and DIRECTORY. Use `url-retrieve' if `newsticker-retrieval-method' is 'intern. (newsticker--image-download-by-wget): New. Use process properties for storing informations. (newsticker--image-sentinel): Read informations from process properties. (newsticker--image-save) (newsticker--image-remove) (newsticker--image-download-by-url) (newsticker--image-download-by-url-callback): New. (newsticker-opml-export): Handle url list entries containing a function instead of an url string. * lisp/net/newst-reader.el (newsticker-html-renderer): Whitespace. (newsticker--print-extra-elements) (newsticker--do-print-extra-element): Documentation (newsticker--image-read): Optionally limit image height. Use imagemagick if possible. (newsticker--icon-read): New. * lisp/net/newst-treeview.el (newsticker--treeview-item-show): Limit height of feed logo. (newsticker--treeview-tree-expand): Use feed icons in treeview. (newsticker--tree-widget-icon-create): New. Set the tree widget icon. (newsticker--tree-widget-leaf-icon): Use feed icon.
2014-10-19 18:50:15 +02:00
(defun newsticker--image-read (feed-name-symbol disabled &optional max-height)
2008-06-08 15:36:18 +00:00
"Read the cached image for FEED-NAME-SYMBOL from disk.
If DISABLED is non-nil the image will be converted to a disabled look
\(unless `newsticker-enable-logo-manipulations' is not t\).
Newsticker: Show feedicons in treeview. Small fix in opml export. * etc/images/newsticker/README: Add rss-feed.png, rss-feed.svg. * etc/images/newsticker/rss-feed.png: New. * etc/images/newsticker/rss-feed.svg: New. * lisp/net/newst-backend.el: Require url-parse. (newsticker--get-news-by-wget): Store feed name as process property. (newsticker--sentinel): Read feed name from process property. (newsticker--sentinel-work): Rename argument name to feed-name. Rename variable imageurl to image-url. Pick icon url from Atom 1.0 data. Launch download of feed icon. (newsticker--get-icon-url-atom-1.0): New. (newsticker--unxml) (newsticker--unxml-node) (newsticker--unxml-attribute): Documentation. (newsticker--icons-dir): New. (newsticker--image-get): New arguments FILENAME and DIRECTORY. Use `url-retrieve' if `newsticker-retrieval-method' is 'intern. (newsticker--image-download-by-wget): New. Use process properties for storing informations. (newsticker--image-sentinel): Read informations from process properties. (newsticker--image-save) (newsticker--image-remove) (newsticker--image-download-by-url) (newsticker--image-download-by-url-callback): New. (newsticker-opml-export): Handle url list entries containing a function instead of an url string. * lisp/net/newst-reader.el (newsticker-html-renderer): Whitespace. (newsticker--print-extra-elements) (newsticker--do-print-extra-element): Documentation (newsticker--image-read): Optionally limit image height. Use imagemagick if possible. (newsticker--icon-read): New. * lisp/net/newst-treeview.el (newsticker--treeview-item-show): Limit height of feed logo. (newsticker--treeview-tree-expand): Use feed icons in treeview. (newsticker--tree-widget-icon-create): New. Set the tree widget icon. (newsticker--tree-widget-leaf-icon): Use feed icon.
2014-10-19 18:50:15 +02:00
Optional argument MAX-HEIGHT specifies the maximal image height.
2008-06-08 15:36:18 +00:00
Return the image."
2008-11-24 19:40:35 +00:00
(let ((image-name (concat (newsticker--images-dir)
(symbol-name feed-name-symbol))))
2008-06-08 15:36:18 +00:00
(when (file-exists-p image-name)
(condition-case error-data
(create-image
image-name
(and (fboundp 'imagemagick-types)
(imagemagick-types)
'imagemagick)
nil
:conversion (and newsticker-enable-logo-manipulations
disabled
'disabled)
:mask (and newsticker-enable-logo-manipulations
'heuristic)
:ascent 100
:max-height max-height)
2008-06-08 15:36:18 +00:00
(error
(message "Error: cannot create image for %s: %s"
feed-name-symbol error-data))))))
2008-06-08 15:36:18 +00:00
Newsticker: Show feedicons in treeview. Small fix in opml export. * etc/images/newsticker/README: Add rss-feed.png, rss-feed.svg. * etc/images/newsticker/rss-feed.png: New. * etc/images/newsticker/rss-feed.svg: New. * lisp/net/newst-backend.el: Require url-parse. (newsticker--get-news-by-wget): Store feed name as process property. (newsticker--sentinel): Read feed name from process property. (newsticker--sentinel-work): Rename argument name to feed-name. Rename variable imageurl to image-url. Pick icon url from Atom 1.0 data. Launch download of feed icon. (newsticker--get-icon-url-atom-1.0): New. (newsticker--unxml) (newsticker--unxml-node) (newsticker--unxml-attribute): Documentation. (newsticker--icons-dir): New. (newsticker--image-get): New arguments FILENAME and DIRECTORY. Use `url-retrieve' if `newsticker-retrieval-method' is 'intern. (newsticker--image-download-by-wget): New. Use process properties for storing informations. (newsticker--image-sentinel): Read informations from process properties. (newsticker--image-save) (newsticker--image-remove) (newsticker--image-download-by-url) (newsticker--image-download-by-url-callback): New. (newsticker-opml-export): Handle url list entries containing a function instead of an url string. * lisp/net/newst-reader.el (newsticker-html-renderer): Whitespace. (newsticker--print-extra-elements) (newsticker--do-print-extra-element): Documentation (newsticker--image-read): Optionally limit image height. Use imagemagick if possible. (newsticker--icon-read): New. * lisp/net/newst-treeview.el (newsticker--treeview-item-show): Limit height of feed logo. (newsticker--treeview-tree-expand): Use feed icons in treeview. (newsticker--tree-widget-icon-create): New. Set the tree widget icon. (newsticker--tree-widget-leaf-icon): Use feed icon.
2014-10-19 18:50:15 +02:00
(defun newsticker--icon-read (feed-name-symbol)
"Read the cached icon for FEED-NAME-SYMBOL from disk.
Return the image."
(catch 'icon
(when (file-exists-p (newsticker--icons-dir))
(dolist (file (directory-files (newsticker--icons-dir) t
(concat (symbol-name feed-name-symbol) "\\..*")))
(condition-case error-data
(throw 'icon (create-image
file (and (fboundp 'imagemagick-types)
(imagemagick-types)
'imagemagick)
nil
:ascent 'center
:max-width 16
:max-height 16))
(error
(message "Error: cannot create icon for %s: %s"
feed-name-symbol error-data)))))
;; Fallback: default icon.
Newsticker: Show feedicons in treeview. Small fix in opml export. * etc/images/newsticker/README: Add rss-feed.png, rss-feed.svg. * etc/images/newsticker/rss-feed.png: New. * etc/images/newsticker/rss-feed.svg: New. * lisp/net/newst-backend.el: Require url-parse. (newsticker--get-news-by-wget): Store feed name as process property. (newsticker--sentinel): Read feed name from process property. (newsticker--sentinel-work): Rename argument name to feed-name. Rename variable imageurl to image-url. Pick icon url from Atom 1.0 data. Launch download of feed icon. (newsticker--get-icon-url-atom-1.0): New. (newsticker--unxml) (newsticker--unxml-node) (newsticker--unxml-attribute): Documentation. (newsticker--icons-dir): New. (newsticker--image-get): New arguments FILENAME and DIRECTORY. Use `url-retrieve' if `newsticker-retrieval-method' is 'intern. (newsticker--image-download-by-wget): New. Use process properties for storing informations. (newsticker--image-sentinel): Read informations from process properties. (newsticker--image-save) (newsticker--image-remove) (newsticker--image-download-by-url) (newsticker--image-download-by-url-callback): New. (newsticker-opml-export): Handle url list entries containing a function instead of an url string. * lisp/net/newst-reader.el (newsticker-html-renderer): Whitespace. (newsticker--print-extra-elements) (newsticker--do-print-extra-element): Documentation (newsticker--image-read): Optionally limit image height. Use imagemagick if possible. (newsticker--icon-read): New. * lisp/net/newst-treeview.el (newsticker--treeview-item-show): Limit height of feed logo. (newsticker--treeview-tree-expand): Use feed icons in treeview. (newsticker--tree-widget-icon-create): New. Set the tree widget icon. (newsticker--tree-widget-leaf-icon): Use feed icon.
2014-10-19 18:50:15 +02:00
(find-image '((:type png :file "newsticker/rss-feed.png" :ascent center)))))
2008-06-08 15:36:18 +00:00
;; the functions we need for retrieval and display
;;;###autoload
(defun newsticker-show-news ()
"Start reading news. You may want to bind this to a key."
(interactive)
(newsticker-start t) ;; will start only if not running
;; Load the html rendering packages
(if newsticker-html-renderer
(cond ((eq newsticker-html-renderer 'w3m-region)
(require 'w3m))
((eq newsticker-html-renderer 'w3-region)
(require 'w3-auto))
((eq newsticker-html-renderer 'newsticker-htmlr-render)
(require 'htmlr))))
2008-06-08 15:36:18 +00:00
(funcall newsticker-frontend))
;; ======================================================================
;;; Toolbar
;; ======================================================================
2008-08-25 17:41:16 +00:00
(defun newsticker-browse-url-item (feed item)
"Convert FEED ITEM to html and call `browse-url' on result."
(interactive)
(let ((t-file (make-temp-file "newsticker")))
(with-temp-file t-file
(insert "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<body>")
(insert "<h1>" feed ": " (newsticker--title item) "</h1>")
(insert (format-time-string newsticker-date-format
(newsticker--time item)))
(insert "<br/>")
(insert (or (newsticker--desc item) "[No Description]"))
(when (newsticker--enclosure item)
(insert "<br/><hr/><i>")
(newsticker--insert-enclosure item nil)
(insert "</i>"))
(when (newsticker--extra item)
(insert "<br/><hr/><tt>")
(newsticker--print-extra-elements item nil)
(insert "</tt>"))
(insert "</body></html>"))
(browse-url t-file)))
2009-12-06 19:49:04 +00:00
(provide 'newst-reader)
2008-06-08 18:09:06 +00:00
2008-06-13 17:08:25 +00:00
;;; newst-reader.el ends here