Skip to content

Commit

Permalink
Merge pull request arclanguage#200 from kennethrapp/master
Browse files Browse the repository at this point in the history
fixed search bar
  • Loading branch information
kennethrapp authored Apr 25, 2021
2 parents 617669c + 3689e25 commit 80cf57e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 40 deletions.
30 changes: 30 additions & 0 deletions apps/news/news.arc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
(require "search.arc")
(= this-site* "Anarki"
site-url* "http://site.example.com";your domain name
parent-url* "http://github.com/arclanguage/anarki"
Expand Down Expand Up @@ -659,6 +660,8 @@
(procrast-msg ,gu ,gw)))
)))))))



;(mac shortpage (user label title whence . body)
; `(longpage ,user ,label ,title ,whence ,@body))

Expand Down Expand Up @@ -791,6 +794,33 @@
(admin&newsadmin-page user)))
(single-input "" 'ip 20 "ban ip"))))

; Search bar for News
; Copyright (C) 2017 Pelle Hjek

(newsop search (q)
(search-page user q))

(def search-bar (user)
(tag (form action "search")
(pr "Search: ")
(input 'q "" 18 )))

(def search-page (user terms)
(listpage user (search (join stories* comments*) tokens.terms) "search"
(string "Search results for \"" terms #\")))

(def search (stories terms)
(keep [match-all? _ terms] stories))

(def match-all? (story terms)
(all idfn (map [match? story _] terms)))

(def match? (story term)
(some [match-ignoring-case? (string story._) term] '(title url by text)))

(def match-ignoring-case? (s pat)
(re-match (re:string "(?i:" pat ")")
s))

; Users

Expand Down
40 changes: 0 additions & 40 deletions apps/news/search.arc

This file was deleted.

0 comments on commit 80cf57e

Please sign in to comment.