From d1bb961ae72f08578cf302fbaad045839d064de5 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Thu, 18 Sep 2003 03:24:56 +0000 Subject: [PATCH] r7876: initial import --- debian/changelog | 5 +++ debian/compat | 1 + debian/control | 14 +++++++ debian/copyright | 37 +++++++++++++++++ debian/postinst | 47 ++++++++++++++++++++++ debian/prerm | 37 +++++++++++++++++ debian/rules | 80 +++++++++++++++++++++++++++++++++++++ debian/upload.sh | 3 ++ main.lisp | 101 +++++++++++++++++++++++++++++++++++++++++++++++ package.lisp | 19 +++++++++ 10 files changed, 344 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100755 debian/postinst create mode 100755 debian/prerm create mode 100755 debian/rules create mode 100755 debian/upload.sh create mode 100644 main.lisp create mode 100644 package.lisp diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..ae33aaf --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +cl-rss (0.1-1) unstable; urgency=low + + * Initial upload + + -- Kevin M. Rosenberg Wed, 17 Sep 2003 20:50:37 -0600 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +4 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..f9a291e --- /dev/null +++ b/debian/control @@ -0,0 +1,14 @@ +Source: cl-rss +Section: devel +Priority: optional +Maintainer: Kevin M. Rosenberg +Build-Depends-Indep: debhelper (>> 4.0.0) +Standards-Version: 3.6.1.0 + +Package: cl-rss +Architecture: all +Depends: ${shlibs:Depends}, common-lisp-controller (>= 3.37), cl-kmrcl, cl-xmls, cl-aserve, cl-ptester +Description: Common Lisp RSS processor + This package provides a Common Lisp library for fetching and parsing + Remote Site Summary data via HTTP. Currently, it supports RSS versions + 0.90, 0.91, and 0.92. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..c978b66 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,37 @@ +Debian Copyright Section +======================== + +Upstream Source URL: http://files.b9.com/cl-rss/ +Upstream Authors: Kevin M. Rosenberg +Debian Maintainer: Kevin M. Rosenberg + + +Upstream Copyright Statement +============================ +Copyright (c) 2003 Kevin M. Rosenberg + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name of the author nor the names of the contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. diff --git a/debian/postinst b/debian/postinst new file mode 100755 index 0000000..d8a0f6c --- /dev/null +++ b/debian/postinst @@ -0,0 +1,47 @@ +#! /bin/sh +set -e + +LISP_PKG=rss + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package +# +# quoting from the policy: +# Any necessary prompting should almost always be confined to the +# post-installation script, and should be protected with a conditional +# so that unnecessary prompting doesn't happen if a package's +# installation fails and the `postinst' is called with `abort-upgrade', +# `abort-remove' or `abort-deconfigure'. + +case "$1" in + configure) + /usr/sbin/register-common-lisp-source ${LISP_PKG} + + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + diff --git a/debian/prerm b/debian/prerm new file mode 100755 index 0000000..a9ee25d --- /dev/null +++ b/debian/prerm @@ -0,0 +1,37 @@ +#! /bin/sh +set -e + +LISP_PKG=rss + +# summary of how this script can be called: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + remove|upgrade|deconfigure) + /usr/sbin/unregister-common-lisp-source ${LISP_PKG} + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..b835ee2 --- /dev/null +++ b/debian/rules @@ -0,0 +1,80 @@ +#!/usr/bin/make -f + +pkg := rss +debpkg := cl-rss + + +clc-source := usr/share/common-lisp/source +clc-systems := usr/share/common-lisp/systems +clc-rss := $(clc-source)/$(pkg) + +doc-dir := usr/share/doc/$(debpkg) + + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + # Add here commands to compile the package. + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + # Add here commands to clean up after the build process. + rm -f debian/cl-rss.postinst.* debian/cl-rss.prerm.* + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + # Add here commands to install the package into debian/rss. + dh_installdirs $(clc-systems) $(clc-rss) $(doc-dir) + dh_install rss.asd $(shell echo *.lisp) $(clc-rss) + dh_link $(clc-rss)/rss.asd $(clc-systems)/rss.asd + +# Build architecture-independent files here. +binary-indep: build install + + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot +# dh_installdebconf + dh_installdocs + dh_installexamples example.lisp +# dh_installmenu +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_installinit +# dh_installcron +# dh_installman +# dh_installinfo +# dh_undocumented + dh_installchangelogs + dh_strip + dh_compress + dh_fixperms +# dh_makeshlibs + dh_installdeb +# dh_perl + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure + diff --git a/debian/upload.sh b/debian/upload.sh new file mode 100755 index 0000000..bb49b4c --- /dev/null +++ b/debian/upload.sh @@ -0,0 +1,3 @@ +#!/bin/bash -e + +dup cl-rss -Uftp.med-info.com -D/home/ftp/xlunit -C"/home/kevin/bin/remove-old-versions cl-rss latest" -su $* diff --git a/main.lisp b/main.lisp new file mode 100644 index 0000000..e458724 --- /dev/null +++ b/main.lisp @@ -0,0 +1,101 @@ +;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- +;;;; ************************************************************************* +;;;; FILE IDENTIFICATION +;;;; +;;;; Name: main.lisp +;;;; Purpose: Main RSS functions +;;;; Programmer: Kevin M. Rosenberg +;;;; Date Started: Sep 2003 +;;;; +;;;; $Id: rss.asd 7061 2003-09-07 06:34:45Z kevin $ +;;;; ************************************************************************* + +(in-package #:rss) + +(defclass rss-0.9x-channel () + ((title :accessor title :initform nil) + (link :accessor link :initform nil) + (description :accessor description) + (items :accessor items :initform nil))) + +(defclass rss-0.9x-item () + ((title :accessor title :initform nil ) + (link :accessor link :initform nil))) + +(defvar *sites* + '("http://www.cliki.net/recent-changes.rdf")) + +(defun show-sites (&optional (sites *sites*)) + (dolist (site sites) + (awhen (rss-site site) + (display-site it)))) + +(defun display-site (site &key (stream *standard-output*)) + (format stream "Site: ~A~%" (title site)) + (dolist (item (items site)) + (format stream " ~A~%" (title item)))) + +(defun rss-site (uri) + (multiple-value-bind (body response headers true-uri) + (net.aserve.client:do-http-request uri) + (declare (ignore true-uri headers)) + (when (eql 200 response) + (with-input-from-string (strm body) + (parse-rss-0.9x-stream strm))))) + +(defun parse-rss-0.9x-file (file) + (with-open-file (stream file :direction :input) + (parse-rss-0.9x-stream stream))) + +(defun is-rss-version-supported (attributes) + (awhen (position "version" attributes :key #'car :test #'string=) + (let ((version (second (nth it attributes)))) + (= 4 (length version)) + (string= "0.9" (subseq version 0 3))))) + +(defun parse-rss-0.9x-stream (stream) + (let* ((*package* (find-package 'kmrcl)) + (tree (remove-from-tree-if + (lambda (x) (and (stringp x) (is-string-whitespace x))) + (xmls:parse stream :compress-whitespace t)))) + (unless (and (string= "rss" (first tree)) + (is-rss-version-supported (second tree))) + (return-from parse-rss-0.9x-stream nil)) + (let* ((content (third tree)) + (pos 0) + (len (length content)) + (rss (make-instance 'rss-0.9x-channel))) + (when (string= "channel" (nth pos content)) + (incf pos) + (while (and (< pos len) + (or (string= "title" (car (nth pos content))) + (string= "link" (car (nth pos content))) + (string= "description" (car (nth pos content))))) + (let ((slot (nth pos content))) + (cond + ((string= "title" (car slot)) + (setf (title rss) (second slot))) + ((string= "link" (car slot)) + (setf (link rss) (second slot))) + ((string= "description" (car slot)) + (setf (description rss) (second slot))))) + (incf pos))) + (while (< pos len) + (when (string= "item" (car (nth pos content))) + (let ((item (make-instance 'rss-0.9x-item))) + (dolist (pair (cdr (nth pos content))) + (cond + ((string= "title" (car pair)) + (setf (title item) (second pair))) + ((string= "links" (car pair)) + (setf (link item) (second pair))))) + (push item (items rss)))) + (incf pos)) + (setf (items rss) (nreverse (items rss))) + rss))) + + + + + + diff --git a/package.lisp b/package.lisp new file mode 100644 index 0000000..e4fe907 --- /dev/null +++ b/package.lisp @@ -0,0 +1,19 @@ +;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- +;;;; ************************************************************************* +;;;; FILE IDENTIFICATION +;;;; +;;;; Name: package.lisp +;;;; Purpose: Package definition for RSS +;;;; Programmer: Kevin M. Rosenberg +;;;; Date Started: Sep 2003 +;;;; +;;;; $Id: rss.asd 7061 2003-09-07 06:34:45Z kevin $ +;;;; ************************************************************************* + +(in-package cl-user) +(defpackage rss + (:use #:cl #:kmrcl) + (:export + #:show-sites + )) + -- 2.34.1