This commit is contained in:
polwex 2024-06-29 02:14:46 +07:00
parent 9a55f89650
commit 51c078429a
10 changed files with 163 additions and 32 deletions

View File

@ -27,7 +27,9 @@
:_ this init-cards:hd :_ this init-cards:hd
++ on-load |= old=vase ++ on-load |= old=vase
:_ this(state !<(versioned-state old)) ~ :_ this(state !<(versioned-state old))
:: :- cache-root:cache cache-static:cache
~
++ on-watch ++ on-watch
|= =(pole knot) |= =(pole knot)
?+ pole !! ?+ pole !!
@ -49,8 +51,33 @@
?: ?=(%seed a) teds:seed ?: ?=(%seed a) teds:seed
?: ?=(%seed2 a) coms:seed ?: ?=(%seed2 a) coms:seed
?: ?=(%seed3 a) reps:seed ?: ?=(%seed3 a) reps:seed
:: admin
?: ?=([%hr @p ?] a) (handle-hr +.a)
?: ?=([%ban @p ?] a) (handle-ban +.a)
?: ?=([%del-ted @t] a) (handle-del .y +.a)
?: ?=([%del-com @t] a) (handle-del .n +.a)
~& wtf=a ~& wtf=a
`this `this
++ handle-del |= [is-ted=? uidt=@t]
=/ uid (slaw:sr %uw uidt) ?~ uid !!
=/ cued (cue u.uid)
=/ pid %- (soft pid:tp) cued
?~ pid !!
=^ cards state
%+ handle-del:cache is-ted u.pid
[cards this]
++ handle-hr |= [=ship w=?]
?> .=(src.bowl our.bowl)
=. admins ?: w
(~(put in admins) ship)
(~(del in admins) ship)
`this
++ handle-ban |= [=ship w=?]
?> (~(has in admins) src.bowl)
=. blacklist ?: w
(~(put in blacklist) ship)
(~(del in blacklist) ship)
`this
++ handle-cache |= a=* :_ this ++ handle-cache |= a=* :_ this
=/ which ($?(%root %ted %sta %all) a) =/ which ($?(%root %ted %sta %all) a)
?- which ?- which
@ -75,6 +102,7 @@
=/ rng ~(. og eny.bowl) =/ rng ~(. og eny.bowl)
|% |%
++ teds ++ teds
=. admins admins:const
=/ titles titles:seeds =/ titles titles:seeds
=. state =. state
|- ?~ titles state |- ?~ titles state
@ -170,7 +198,6 @@
:: ::
++ serve ++ serve
^- (quip card _this) ^- (quip card _this)
~& eyre-poke=now.bowl
=/ order !<(order:router vase) =/ order !<(order:router vase)
=/ address address.req.order =/ address address.req.order
:: ?: (~(has in banned.admin) address) `this :: ?: (~(has in banned.admin) address) `this

View File

@ -11,6 +11,7 @@
|= noun=* ^- [(list card) _state] |= noun=* ^- [(list card) _state]
=/ poke (pokes:sur noun) =/ poke (pokes:sur noun)
~& ui-poke=poke ~& ui-poke=poke
=. src ship.poke
=/ eyre-id eyre-id.poke =/ eyre-id eyre-id.poke
|^ |^
?- -.p.poke ?- -.p.poke
@ -18,15 +19,17 @@
%submit-comment (handle-comment +.p.poke) %submit-comment (handle-comment +.p.poke)
%submit-reply (handle-reply +.p.poke) %submit-reply (handle-reply +.p.poke)
%vote (handle-vote +.p.poke) %vote (handle-vote +.p.poke)
%del (handle-del +.p.poke)
== ==
++ handle-thread |= [title=@t url=@t text=@t] ++ handle-thread |= [title=@t url=@t text=@t]
=/ =content:sur ?. .=('' url) [%link url] [%text (build-content:lib text)] =/ =content:sur ?. .=('' url) [%link url] [%text (build-content:lib text)]
=/ ted (build-thread:lib title src now content) =/ ted (build-thread:lib title src now content)
=. state (save-ted ted) =. state (save-ted ted)
:_ state :+ :_ state :+
cache-root cache-root
(cache-ted ted) (cache-ted pid.ted)
(redirect-ted ted) (redirect-ted pid.ted)
++ handle-comment |= [ted=thread:sur text=@t] ++ handle-comment |= [ted=thread:sur text=@t]
@ -35,8 +38,8 @@
=. state (save-com com ted) =. state (save-com com ted)
:_ state :+ :_ state :+
cache-root cache-root
(cache-ted ted) (cache-ted pid.ted)
(redirect-ted ted) (redirect-ted pid.ted)
@ -49,7 +52,7 @@
=. state (save-rep com par) =. state (save-rep com par)
:_ state :* :_ state :*
cache-root cache-root
(cache-ted u.ted) (cache-ted pid.u.ted)
(cache-com com) (cache-com com)
(cache-com par) (cache-com par)
(redirect-com par) (redirect-com par)
@ -74,9 +77,9 @@
=. state (save-karma ship.pid.ted vote) =. state (save-karma ship.pid.ted vote)
:_ state :~ :_ state :~
cache-root cache-root
(cache-ted ted) (cache-ted pid.ted)
(cache-user ship.pid.ted) (cache-user ship.pid.ted)
:: (redirect-ted ted) :: (redirect-ted pid.ted)
== ==
++ handle-com-vote |= [=pid:tp vote=?] ++ handle-com-vote |= [=pid:tp vote=?]
=/ votesi=@si (new:si vote 1) =/ votesi=@si (new:si vote 1)
@ -102,8 +105,8 @@
:: redirectors :: redirectors
++ redirect-root (redirect:router eyre-id "") ++ redirect-root (redirect:router eyre-id "")
++ redirect-ted |= ted=thread:sur ++ redirect-ted |= =pid:tp
=/ link (scow:sr %uw (jam pid.ted)) =/ link (scow:sr %uw (jam pid))
=/ url "/ted/{link}" =/ url "/ted/{link}"
(redirect:router eyre-id url) (redirect:router eyre-id url)
++ redirect-com |= com=comment:tp ++ redirect-com |= com=comment:tp
@ -113,8 +116,8 @@
-- --
:: cache builders :: cache builders
++ cache-root (cache-card "") ++ cache-root (cache-card "")
++ cache-ted |= ted=thread:sur ++ cache-ted |= =pid:tp
=/ link (scow:sr %uw (jam pid.ted)) =/ link (scow:sr %uw (jam pid))
=/ url "/ted/{link}" =/ url "/ted/{link}"
(cache-card url) (cache-card url)
++ cache-com |= com=comment:tp ++ cache-com |= com=comment:tp
@ -127,7 +130,7 @@
=/ teds (tap:torm:sur threads) =/ teds (tap:torm:sur threads)
=. l |- ?~ teds l =. l |- ?~ teds l
=/ ted=thread:sur +.i.teds =/ ted=thread:sur +.i.teds
=/ car (cache-ted ted) =/ car (cache-ted pid.ted)
$(teds t.teds, l [car l]) $(teds t.teds, l [car l])
:- cache-root l :- cache-root l
++ cache-user |= who=@p ++ cache-user |= who=@p
@ -148,7 +151,7 @@
=/ teds (tap:torm:sur threads) =/ teds (tap:torm:sur threads)
=. l |- ?~ teds l =. l |- ?~ teds l
=/ ted=thread:sur +.i.teds =/ ted=thread:sur +.i.teds
=/ car (cache-ted ted) =/ car (cache-ted pid.ted)
$(teds t.teds, l [car l]) $(teds t.teds, l [car l])
=/ coms (tap:gorm:tp comments) =/ coms (tap:gorm:tp comments)
=. l |- ?~ coms l =. l |- ?~ coms l
@ -179,6 +182,22 @@
=. par par(children nc) =. par par(children nc)
=. comments (put:gorm:tp comments ppid par) =. comments (put:gorm:tp comments ppid par)
state state
++ wipe-coms
|= [ted=pid:tp]
=/ coms (tap:gorm:tp comments)
|- ?~ coms comments
=/ com=comment:tp +.i.coms
?. .=(ted thread.com) $(coms t.coms)
=. comments +:(del:gorm:tp comments [author.com id.com])
$(coms t.coms)
++ wipe-reps
|= [par=pid:tp]
=/ coms (tap:gorm:tp comments)
|- ?~ coms comments
=/ com=comment:tp +.i.coms
?. .=(par parent.com) $(coms t.coms)
=. comments +:(del:gorm:tp comments [author.com id.com])
$(coms t.coms)
++ save-karma |= [who=@p vote=?] ++ save-karma |= [who=@p vote=?]
=/ curr (~(get by karma) who) =/ curr (~(get by karma) who)
=/ cur ?~ curr `@sd`0 u.curr =/ cur ?~ curr `@sd`0 u.curr
@ -193,4 +212,42 @@
=/ pl=simple-payload:http (render:rout router-path) =/ pl=simple-payload:http (render:rout router-path)
=/ entry=cache-entry:eyre [.n %payload pl] =/ entry=cache-entry:eyre [.n %payload pl]
[%pass /root %arvo %e %set-response pathc `entry] [%pass /root %arvo %e %set-response pathc `entry]
++ handle-del |= [is-ted=? =pid:tp]
?: is-ted
=/ ted (get-thread:lib pid state)
?~ ted `state
=. threads +:(del:torm:sur threads pid)
=. comments (wipe-coms pid)
:_ state :+
cache-root
(cache-ted pid)
~
:: redirect-root
::
=| l=(list card)
=/ ucom (get-comment:lib pid state)
?~ ucom `state =/ com u.ucom
=. comments (wipe-reps pid)
=. l [(cache-com com) l]
=/ upar (get-comment:lib parent.com state)
:: delete from child of parent
=. comments ?~ upar comments
=/ par u.upar
=/ nc (~(del in children.par) pid)
=. par par(children nc)
=. l [(cache-com par) l]
(put:gorm:tp comments [author.par id.par] par)
:: delete from reply of thread
=/ uted (get-thread:lib thread.com state)
=. threads ?~ uted threads
=/ ted u.uted
=/ nr %+ skip replies.ted |= rp=pid:tp .=(rp pid)
=. ted ted(replies nr)
=. l [(cache-ted pid.ted) l]
(put:torm:sur threads pid.ted ted)
:_ state :-
cache-root
l
-- --

View File

@ -36,7 +36,7 @@
'South Korean telecom company attacks torrent users with malware ' 'South Korean telecom company attacks torrent users with malware '
'Show HN: R2R V2 A open source RAG engine with prod features ' 'Show HN: R2R V2 A open source RAG engine with prod features '
'From RSS to My Kindle ' 'From RSS to My Kindle '
'How the STL Uses Explicit (quuxplusone.github.io)' 'How the STL Uses Explicit'
'The brain makes a lot of waste. Now scientists think they know where it goes' 'The brain makes a lot of waste. Now scientists think they know where it goes'
'The plan-execute pattern ' 'The plan-execute pattern '
'1Living Computers Museum to permanently close, auction vintage items ' '1Living Computers Museum to permanently close, auction vintage items '

View File

@ -1,11 +1,12 @@
/- tp=post /- tp=post
|% |%
+$ pokes [%ui eyre-id=@ta p=ui-pokes] +$ pokes [%ui ship=@p eyre-id=@ta p=ui-pokes]
+$ ui-pokes +$ ui-pokes
$% [%submit-comment ted=thread text=@t] $% [%submit-comment ted=thread text=@t]
[%submit-reply =comment:tp text=@t] [%submit-reply =comment:tp text=@t]
[%submit-thread title=@t url=@t text=@t] [%submit-thread title=@t url=@t text=@t]
[%vote ted=? =pid:tp vote=?] [%vote ted=? =pid:tp vote=?]
[%del ted=? =pid:tp]
== ==
+$ state +$ state
$% state-0 $% state-0
@ -19,6 +20,7 @@ $: %0
:: ::
mods=(set @p) mods=(set @p)
admins=(set @p) admins=(set @p)
blacklist=(set @p)
== ==
+$ threads ((mop pid:tp thread) ggth:tp) +$ threads ((mop pid:tp thread) ggth:tp)
++ torm ((on pid:tp thread) ggth:tp) ++ torm ((on pid:tp thread) ggth:tp)

View File

@ -39,14 +39,12 @@
;< res=client-response:iris bind:m take-client-response:strandio ;< res=client-response:iris bind:m take-client-response:strandio
?. ?=(%finished -.res) (strand-fail:strand %no-body ~) ?. ?=(%finished -.res) (strand-fail:strand %no-body ~)
=/ headers headers.response-header.res =/ headers headers.response-header.res
~& > header=headers
=/ redirect (get-header:http 'location' headers) =/ redirect (get-header:http 'location' headers)
~& >> red=redirect ~& >> red=redirect
?^ redirect (pure:m [%| u.redirect]) ?^ redirect (pure:m [%| u.redirect])
:: ::
?~ full-file.res (strand-fail:strand %no-body ~) ?~ full-file.res (strand-fail:strand %no-body ~)
~& mime=-.u.full-file.res
=/ htmls=@t q.data.u.full-file.res =/ htmls=@t q.data.u.full-file.res
=/ json [%s htmls] =/ json [%s htmls]
(pure:m [%& json]) (pure:m [%& json])

View File

@ -33,9 +33,20 @@
=pid post-link =pid post-link
;+ (votes v) ;+ (votes v)
;div:"{author}" ;div:"{author}"
;a/"/forum/com/{post-link}":"{ago} ago" ;a/"/forum/ted/{post-link}":"{ago} ago"
;* comments ;* comments
== ==
:: ++ delete-button
:: |= [is-admin=? is-ted=? post-link=tape]
:: ?. is-admin ~
:: =/ action ?: is-ted
:: "/del-ted/{post-link}"
:: "/del-com/{post-link}"
:: ;+
:: ;form(action action, method "post")
:: ;input(type "submit"):"Delete"
:: ==
++ post-metadata ++ post-metadata
|= [=pid:tp now=@da v=votes:tp reply-count=@ud is-ted=?] |= [=pid:tp now=@da v=votes:tp reply-count=@ud is-ted=?]
=/ teds ?: is-ted "yeah" "nope" =/ teds ?: is-ted "yeah" "nope"

View File

@ -1,5 +1,6 @@
/- sur=forum
/+ sig=sigil-sigil /+ sig=sigil-sigil
|_ =bowl:gall |_ [=state:sur =bowl:gall]
++ login ^- manx ++ login ^- manx
?- (clan:title src.bowl) ?- (clan:title src.bowl)
%czar sigil %czar sigil
@ -10,22 +11,27 @@
== ==
++ login-prompt ^- manx ++ login-prompt ^- manx
;a/"/forum/log":"Log In" ;a/"/forum/log":"Log In"
++ new-post-link ^- marl
:: TODO reverse this
:: ?: (~(has in admins.state) src.bowl) ~
;+ ;a/"/forum/add":"new post"
++ sigil ++ sigil
:: ;+ (sig(size 48) src.bowl) :: ;+ (sig(size 48) src.bowl)
=/ p (scow %p src.bowl) =/ p (scow %p src.bowl)
;div.f.g2 ;div.f.g2
;a/"/forum/add":"new post" ;* new-post-link
;a/"/forum/usr/{p}":"{p}" ;a/"/forum/usr/{p}":"{p}"
== ==
++ $ ++ $
;nav#topnav.fs.g2 ;nav#topnav.fs.g2
;div.f.g2 ;div.f.g2
;div#nav-main.fs ;div#nav-main.fs
;a/"/":"~ Technical Journal" ;a/"https://urbitsystems.tech/":"~ Technical Journal"
;div#nav-dropdown:"↓" ;div#nav-dropdown:"↓"
== ==
;div#nav-links ;div#nav-links
;a/"/information":"Information" ;a/"https://urbitsystems.tech/information":"Information"
;a.active/"/forum":"Forum" ;a.active/"/forum":"Forum"
== ==
== ==

View File

@ -20,11 +20,13 @@
== ==
++ script ^~ %- trip ++ script ^~ %- trip
''' '''
function autoSave(){ function listeners(){
const form = document.getElementById("form"); const form = document.getElementById("form");
const draftID = "new-thread"; const draftID = "new-thread";
const linkDiv = document.getElementById("thread-url");
const area = document.getElementById("textarea"); const area = document.getElementById("textarea");
// autosave
window.addEventListener("load", () => { window.addEventListener("load", () => {
const savedContent = localStorage.getItem(draftID); const savedContent = localStorage.getItem(draftID);
console.log(savedContent, "saved") console.log(savedContent, "saved")
@ -37,7 +39,12 @@
console.log("saving", area.value) console.log("saving", area.value)
localStorage.setItem(draftID, area.value); localStorage.setItem(draftID, area.value);
}) })
// toggler
linkDiv.addEventListener("input", () => {
if (linkDiv.value) textarea.disabled = true;
else textarea.disabled = false;
});
} }
autoSave(); listeners();
''' '''
-- --

View File

@ -17,5 +17,9 @@
;input(type "hidden", name "redirect", value redirect-str); ;input(type "hidden", name "redirect", value redirect-str);
;button(name "eauth", type "submit"):"Login" ;button(name "eauth", type "submit"):"Login"
== ==
;div.tc.nudge
;p:"If you don't have an Urbit ID, click on this link to get one for free."
;a.button/"https://redhorizon.com/join/2d55b768-a5f4-45cf-a4e5-a4302e05a1f9":"Get Urbit ID"
==
== ==
-- --

View File

@ -102,13 +102,13 @@
== ==
++ add-layout |= m=manx ++ add-layout |= m=manx
%- layout :~ %- layout :~
(navbar bowl) (navbar state bowl)
m m
== ==
++ serve-fragment |= =(pole knot) ^- manx ++ serve-fragment |= =(pole knot) ^- manx
?+ pole !! ?+ pole !!
[%sigil ~] [%sigil ~]
=/ navb ~(. navbar bowl) =/ navb ~(. navbar [state bowl])
=/ userdiv login:navb =/ userdiv login:navb
userdiv userdiv
== ==
@ -121,6 +121,7 @@
++ serve-index |= t=@t ^- manx ++ serve-index |= t=@t ^- manx
=/ pag (slaw %ud t) ?~ pag manx-bail =/ pag (slaw %ud t) ?~ pag manx-bail
=/ threads (get-thread-page:lib u.pag state) =/ threads (get-thread-page:lib u.pag state)
(index [u.pag threads] state bowl) (index [u.pag threads] state bowl)
++ serve-comment |= uidt=@t ^- manx ++ serve-comment |= uidt=@t ^- manx
=/ uid (slaw:sr %uw uidt) ?~ uid manx-bail =/ uid (slaw:sr %uw uidt) ?~ uid manx-bail
@ -165,14 +166,32 @@
[%new-thread ~] handle-thread [%new-thread ~] handle-thread
[%vote %ted uid=@t vote=@t ~] (handle-vote .y uid.p vote.p) [%vote %ted uid=@t vote=@t ~] (handle-vote .y uid.p vote.p)
[%vote %com uid=@t vote=@t ~] (handle-vote .n uid.p vote.p) [%vote %com uid=@t vote=@t ~] (handle-vote .n uid.p vote.p)
:: admin
[%del-ted uid=@t ~] (del .y uid.p)
[%del-com uid=@t ~] (del .n uid.p)
== ==
++ del
|= [is-ted=? uidt=@t]
=/ uid (slaw:sr %uw uidt) ?~ uid ~
=/ cued (cue u.uid)
=/ pid %- (soft pid:tp) cued
?~ pid ~
?: is-ted
=/ ted (get-thread:lib u.pid state)
?~ ted ~
(self-poke [%ui src.bowl eyre-id %del is-ted u.ted])
::
=/ com (get-comment:lib u.pid state)
?~ com ~
(self-poke [%ui src.bowl eyre-id %del is-ted u.com])
++ handle-vote |= [is-ted=? uidt=@t vote=@t] ++ handle-vote |= [is-ted=? uidt=@t vote=@t]
=/ vot=? .=(vote 'gud') =/ vot=? .=(vote 'gud')
=/ uid (slaw:sr %uw uidt) ?~ uid ~ =/ uid (slaw:sr %uw uidt) ?~ uid ~
=/ cued (cue u.uid) =/ cued (cue u.uid)
=/ pid %- (soft pid:tp) cued =/ pid %- (soft pid:tp) cued
?~ pid ~ ?~ pid ~
(self-poke [%ui eyre-id %vote is-ted u.pid vot]) (self-poke [%ui src.bowl eyre-id %vote is-ted u.pid vot])
++ handle-thread ++ handle-thread
?~ body ~ ?~ body ~
@ -184,7 +203,7 @@
?~ title ~ ?~ title ~
=/ url (~(get by bod) 'url') =/ url (~(get by bod) 'url')
?~ url ~ ?~ url ~
(self-poke [%ui eyre-id %submit-thread u.title u.url u.md]) (self-poke [%ui src.bowl eyre-id %submit-thread u.title u.url u.md])
++ handle-reply |= top=? ++ handle-reply |= top=?
?~ body ~ ?~ body ~
@ -201,11 +220,11 @@
?: top ?: top
=/ ted (get-thread:lib u.pid state) =/ ted (get-thread:lib u.pid state)
?~ ted ~ ?~ ted ~
(self-poke [%ui eyre-id %submit-comment u.ted u.md]) (self-poke [%ui src.bowl eyre-id %submit-comment u.ted u.md])
:: ::
=/ com (get-comment:lib u.pid state) =/ com (get-comment:lib u.pid state)
?~ com ~ ?~ com ~
(self-poke [%ui eyre-id %submit-reply u.com u.md]) (self-poke [%ui src.bowl eyre-id %submit-reply u.com u.md])
-- --
:: ::
++ self-poke |= noun=* ++ self-poke |= noun=*