fixed bookmarks; announcements broke it
for now just skip irregular links
This commit is contained in:
parent
41649d47c9
commit
d51647c671
@ -1,6 +1,5 @@
|
||||
(ns clojsa.saparser
|
||||
(:require [clojsa.saclient :refer [thread-url thread-response]]
|
||||
[clojure.string :as string]
|
||||
(:require [clojure.string :as string]
|
||||
[hickory.core :refer :all]
|
||||
[hickory.select :as s]
|
||||
[hickory.convert :refer [hickory-to-hiccup]]))
|
||||
@ -36,9 +35,9 @@
|
||||
(string/trim (last (hickory-to-hiccup pd))))
|
||||
|
||||
(defn hickory-div [class content]
|
||||
{:type :element,
|
||||
:attrs {:class class},
|
||||
:tag :div,
|
||||
{:type :element
|
||||
:attrs {:class class}
|
||||
:tag :div
|
||||
:content content})
|
||||
|
||||
(defn parse-pb [pb]
|
||||
@ -71,10 +70,10 @@
|
||||
htree))
|
||||
|
||||
(defn parse-row [htree]
|
||||
(let [link (-> (s/select (s/descendant (s/class :info) (s/tag :a)) htree) first)
|
||||
thread-id (re-find #"\d+$" (:href (:attrs link)))
|
||||
(when-let [link (-> (s/select (s/descendant (s/class :info) (s/tag :a)) htree) first)]
|
||||
(let [thread-id (re-find #"\d+$" (:href (:attrs link)))
|
||||
title (-> link :content first string/trim)]
|
||||
{:id thread-id :title title}))
|
||||
{:id thread-id :title title})))
|
||||
|
||||
(defn bookmarks-map [page doc]
|
||||
(let [htree (hickory-doc doc)
|
||||
@ -85,5 +84,7 @@
|
||||
:page page
|
||||
:page-count page-count
|
||||
:content
|
||||
(for [row bookmarks-tree]
|
||||
(parse-row row))}))
|
||||
(for [row bookmarks-tree
|
||||
:let [parsed-row (parse-row row)]
|
||||
:when parsed-row]
|
||||
parsed-row)}))
|
||||
|
Loading…
Reference in New Issue
Block a user