Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
paste.db
pastiche.build.sh
pastiche.import.*
pastiche.install.sh
pastiche.link
pastiche.so
pastiche.static.o
9 changes: 2 additions & 7 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Using a recent CHICKEN scheme version (>4.6.0), do
2. cd pastiche
3. chicken-install -s

This will fetch all dependencies and installs pastiche and awful.
This will fetch all dependencies and install pastiche and awful.
To run it load the example-app in awful:

$ awful --development-mode example-app
Expand All @@ -24,12 +24,9 @@ It is also possible to run pastiche without having to install the
module. This is useful if you are working on pastiche itself. To do so
install all the required modules first:

$ chicken-install awful:0.39 awful-sql-de-lite:0.4 simple-sha1:0.1 colorize miscmacros utf8
$ chicken-install -n
$ awful --development-mode example-app.scm

/Note:/ The versions required may have changed in the meantime, please
have a look at the depends clause in the pastiche.meta file.

* License

Copyright © 2011 Christian Kellermann
Expand Down Expand Up @@ -61,5 +58,3 @@ 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.


6 changes: 3 additions & 3 deletions example-app.scm
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
(include "pastiche.scm")
(import pastiche)
(import awful doctype)
(import awful)

(pastiche "/" "paste.db"
awful-settings:
(lambda (handler)
(parameterize
((debug-file "/tmp/paste")
(page-css "chicken.css")
(page-doctype doctype-html)
(page-doctype "<!DOCTYPE html>")
(page-charset "UTF-8"))
(handler))))

15 changes: 7 additions & 8 deletions pastiche.scm
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@

(define espeak-available-languages '())

(define bad-words '())
(define bad-words-irx #f)

(define (is-it-spam? nick title paste)
(define (is-it-spam? nick title paste bad-words-irx)
;; bad-words-irx is either a regex or #f
(define (url? s)
(and-let* ((uri (uri-reference s))
(s (uri-scheme uri)))
Expand Down Expand Up @@ -235,9 +233,10 @@

(set! captchas (and use-captcha? (create-captchas num-captchas)))

(when bad-words-path
(set! bad-words (call-with-input-file bad-words-path read-lines))
(set! bad-words-irx (irregex `(: (w/nocase (or ,@bad-words))))))
(define bad-words-irx
(and bad-words-path
(let ((bad-words (call-with-input-file bad-words-path read-lines)))
(irregex `(: (w/nocase (or ,@bad-words)))))))

;; The database needs to be initialised once
(unless (file-exists? db-file)
Expand Down Expand Up @@ -490,7 +489,7 @@
(list nick title time paste))))
(cond ((string-null? paste)
(bail-out "I am not storing empty pastes."))
((is-it-spam? nick title paste)
((is-it-spam? nick title paste bad-words-irx)
(when ($ 'notify-irc) (send-to-irc (string-append "SPAM! SPAM! SPAM! by " nick)))
`((h2 (@ (align "center")) "Thanks for your paste!")
(p "Hi " ,nick ", thanks for pasting: " (em ,title) (br))))
Expand Down
Binary file removed tests/pastiche.db
Binary file not shown.
1 change: 1 addition & 0 deletions tests/run.scm
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
(lambda ()
(load "client.scm")))

(delete-file* pastiche-db)
(test-exit)