├── .gitignore ├── LICENSE ├── README.org ├── main.lisp └── nx-reader.asd /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore compiled lisp files 2 | *.FASL 3 | *.fasl 4 | *.lisp-temp 5 | *.dfsl 6 | *.pfsl 7 | *.d64fsl 8 | *.p64fsl 9 | *.lx64fsl 10 | *.lx32fsl 11 | *.dx64fsl 12 | *.dx32fsl 13 | *.fx64fsl 14 | *.fx32fsl 15 | *.sx64fsl 16 | *.sx32fsl 17 | *.wx64fsl 18 | *.wx32fsl 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2017-2020, Atlas Engineer LLC. 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | * NX-Reader 2 | NX-Reader is a simple RSS feed reader for the Next browser. Please see 3 | the source code for more documentation. 4 | * Usage 5 | Set the =nx-reader:feed-urls= variable to a list of URLs you would 6 | like to retrieve feeds for, then invoke the command =show-rss-feeds=. 7 | 8 | Example configuration: 9 | 10 | #+NAME: set-urls 11 | #+BEGIN_SRC lisp 12 | (setf nx-reader:rss-urls (list "https://www.abc.xyz" 13 | "https://www.cde.qrt")) 14 | #+END_SRC 15 | 16 | Then, invoke =show-rss-feeds= to view your configured feeds. 17 | -------------------------------------------------------------------------------- /main.lisp: -------------------------------------------------------------------------------- 1 | (in-package :cl-user) 2 | 3 | (defpackage :nx-reader 4 | (:use :common-lisp :nyxt) 5 | (:export 6 | #:rss-site 7 | #:rss-generate-html 8 | #:rss-urls 9 | #:rss-feeds-generate-html)) 10 | 11 | (in-package :nx-reader) 12 | 13 | (defparameter rss-urls (list)) 14 | 15 | (defun rss-site (url) 16 | "Retrieve the RSS from a specific feed and parse it into an RSS object." 17 | (rss:parse-rss-stream (dex:get url :want-stream t))) 18 | 19 | (defun rss-generate-html (rss-object) 20 | "Generate the HTML representing a particular RSS feed." 21 | (markup:markup 22 | (:details 23 | :open "open" 24 | (:summary (:h1 :style "display:inline" (rss:title rss-object))) 25 | (:p (:a :href (rss:link rss-object) (rss:link rss-object))) 26 | (:p (rss:description rss-object)) 27 | (:ul (loop for item in (rss:items rss-object) 28 | collect 29 | (markup:markup (:li (:p (:b (rss:title item))) 30 | (:p (:a :href (rss:link item) (rss:link item))) 31 | (:p (markup:raw (rss:description item)))))))))) 32 | 33 | (defun rss-feeds-generate-html (&optional (rss-urls rss-urls)) 34 | "Generate the HTML representing a list of RSS feeds." 35 | (markup:markup 36 | (:span (loop for rss-url in rss-urls collect 37 | (rss-generate-html (rss-site rss-url)))))) 38 | 39 | ;; Commands must be defined in the Nyxt package 40 | (in-package :nyxt) 41 | (define-command show-rss-feeds () 42 | "Show RSS Feeds. To set your RSS feeds, set RSS-URLS in the 43 | NX-READER package." 44 | (let* ((rss-buffer (make-buffer :title "*RSS Feed*")) 45 | (rss-buffer-contents (nx-reader:rss-feeds-generate-html nx-reader:rss-urls)) 46 | (insert-contents (ps:ps (setf (ps:@ document Body |innerHTML|) 47 | (ps:lisp rss-buffer-contents))))) 48 | (ffi-buffer-evaluate-javascript rss-buffer insert-contents) 49 | (set-current-buffer rss-buffer) 50 | rss-buffer)) 51 | -------------------------------------------------------------------------------- /nx-reader.asd: -------------------------------------------------------------------------------- 1 | (asdf:defsystem nx-reader 2 | :depends-on (:nyxt 3 | :cl-markup 4 | :rss 5 | :dexador) 6 | :components ((:file "main"))) 7 | --------------------------------------------------------------------------------