Compare commits

...

4 Commits

Author SHA1 Message Date
yung calibri
131f24f499 update docket 2023-08-30 10:41:01 -04:00
yung calibri
478b99b1aa v0.6.0 2023-08-30 10:39:46 -04:00
yung calibri
486bb62f72 move everything to desk subfolder 2023-08-26 10:49:23 -04:00
yung calibri
ce2929dc28 add HTTP endpoint and form UI for %direct 2023-07-29 20:56:18 -04:00
98 changed files with 169 additions and 40 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
tgt*

41
README.md Normal file
View File

@ -0,0 +1,41 @@
# Prism
A URL shortener for your Urbit.
-----
## Usage
Boot it up, open the web UI at /apps/prism. Interactions are all documented
there.
Use `direct` to create a redirect.
```
dojo> :prism|direct ~.dev 'https://developers.urbit.org/'
```
Use `defect` to disable an existing redirect.
```
dojo> :prism|defect ~.dev
```
Use `renege` to re-enable a previously disabled redirect.
```
dojo> :prism|renege ~.dev
```
Use `delete` to delete a redirect.
```
dojo> :prism|delete ~.dev
```
-----
## Development
This is very much a work in progress. I don't have any special insight
into who's using the app, what they're using it for, or what could be
improved to make it better for users. So if you have a suggestion,
please do create an issue for it.
I'm working on a way to provide feedback directly from within the web
UI, but that's still a little ways off.

View File

@ -97,6 +97,7 @@
++ handle-http
|_ [eyre-id=@ta =inbound-request:eyre]
+* req (parse-request-line:server url.request.inbound-request)
body body.request.inbound-request
send (cury response:schooner eyre-id)
beth (cury update-breath inbound-request)
dump [(send [404 ~ [%none ~]]) state]
@ -143,9 +144,24 @@
^- (quip card _state)
=/ site site.req
?+ site dump
::
::
[%apps %prism %direct ~]
?~ body.request.inbound-request derp
=/ jon=(unit json)
(de:json:html q.u.body.request.inbound-request)
?~ jon derp
=/ act=prism-action (dejs-direct +.jon)
=/ scat=(unit (quip card _state))
%- mole
|. (handle-action act)
?~ scat derp
:_ +.u.scat
%+ weld
-.u.scat
(send [200 ~ [%manx ~(shortlinks view +.u.scat)]])
::
[%apps %prism @t %defect ~]
:: attempt to handle the defect action
:: attempt to handle the %defect action
=/ scat=(unit (quip card _state))
%- mole
|. (handle-action `prism-action`[%defect i.t.t.site])

View File

@ -2,7 +2,7 @@
[%info 'A URL shortener for your urbit']
[%color 0xff.ffff]
[%image 'https://s3.us-west-004.backblazeb2.com/demiurge/normul-postem/2023.7.18..04.42.00-d735aaec09f5d1c0079f22e577591157.png']
[%version [0 5 0]]
[%version [0 6 0]]
[%website 'https://github.com/yungcalibri/prism']
[%license 'MIT']
[%site /apps/prism]

View File

@ -231,11 +231,13 @@
++ shortlinks
^- manx
%- page
?. (gth ~(wyt by paths) 0)
;+ ;h2: No redirects created yet
;* ;=
:: begin content
;h2: Shortlinks
;h2
;+ ?: (gth ~(wyt by paths) 0)
;/ "Shortlinks"
;/ "No shortlinks created yet"
==
;stack-l(space "var(--s0)")
;* %+ turn
~(tap by paths)
@ -243,45 +245,87 @@
=/ beth=breath (~(got by snoop) wright)
=/ hits (~(gut bi beth) '' '' 0)
=/ brat (~(has in brats) wright)
=/ delete-link (spud ~[%apps %prism wright %delete])
=/ toggle-link (spud ~[%apps %prism wright ?.(brat 'defect' 'renege')])
=/ box-class ?:(brat "shortlink disabled" "shortlink")
;sidebar-l(side "right", sideWidth "5em", class box-class)
;stack-l
;section
;div
; From:
;code
;+ ;/ "/apps/prism/"
;em:"{(trip wright)}"
=/ delete-link (spud /apps/prism/[wright]/delete)
=/ toggle-link
(spud ~[%apps %prism wright ?.(brat 'defect' 'renege')])
:: =/ box-class ?:(brat "shortlink disabled" "shortlink")
;section(class "shortlink {(trip ?:(brat 'disabled' ''))}")
;sidebar-l(side "right", sideWidth "5em")
;stack-l
;section
;div
; From:
;code
;+ ;/ "/apps/prism/"
;em:"{(trip wright)}"
==
==
;div
; To:
;a/"{(trip toward)}"
;code: {(trip toward)}
==
==
==
;div
; To:
;a/"{(trip toward)}"
;code: {(trip toward)}
==
;+ ;/ ?.(brat "Enabled" "Disabled")
;+ ;/ " — {<hits>} "
;+ ;/ ?:(=(hits 1) "visitor" "visitors")
==
==
;div
;+ ;/ ?.(brat "Enabled" "Disabled")
;+ ;/ " — {<hits>} "
;+ ;/ ?:(=(hits 1) "visitor" "visitors")
;stack-l(space "var(--s-1)", splitAfter "1")
;button.danger
=hx-post delete-link
=hx-confirm "Are you sure you want to delete this link?"
=hx-target "#content"
=hx-select "#content"
; Delete
==
;button
=hx-post toggle-link
=hx-target "#content"
=hx-select "#content"
;+ ;/ ?.(brat "Disable" "Enable")
==
==
==
;stack-l(space "var(--s-1)", splitAfter "1")
;button.danger
=hx-post delete-link
=hx-confirm "Are you sure you want to delete this link?"
=hx-target "#content"
=hx-select "#content"
; Delete
==
;button
=hx-post toggle-link
==
;hr;
;section(class "shortlink new")
;stack-l
;h3: New shortlink
;form#new-shortlink
=hx-post "/apps/prism/direct"
=hx-target "#content"
=hx-select "#content"
;+ ;/ ?.(brat "Disable" "Enable")
;sidebar-l(side "right", sideWidth "5em")
;stack-l(space "var(--s-2)")
;label
; From:
;br;
;code: /apps/prism/
;input
=name "wright"
=type "text"
=pattern "[a-zA-Z-._~]+"
=required ""
=placeholder "vienna"
=style "color: #f95";
==
;label
; To:
;br;
;input
=name "toward"
=type "url"
=required ""
=placeholder "https://vienna.earth/";
==
==
;stack-l(class "justify-content:end")
;button: Create
==
==
==
==
==
@ -308,9 +352,8 @@
}
code {
font-family: 'Cousine', monospace;
padding-inline: 0.25ch;
padding: 0.25ch;
margin-inline: 0.25ch;
padding-block: 0.25ch;
margin-block: calc(-1 * 0.25ch);
border-radius: 0.25ch;
background-color: #335;
@ -332,15 +375,25 @@
padding-block: 0.25rem;
color: inherit;
filter: brightness(110%);
cursor: pointer;
}
button.danger {
background-color: #a32;
}
button:hover {
filter: brightness(90%) contrast(120%);
filter: brightness(110%) contrast(120%);
}
button:active {
filter: brightness(110%) contrast(120%);
border-style: solid;
filter: brightness(90%) contrast(120%);
}
input {
background-color: #335;
color: inherit;
font-size: inherit;
font-family: 'Cousine', monospace;
padding: 0.25ch;
border-color: #4e3d54;
}
#usage {
font-family: 'Anybody', sans-serif;
@ -406,5 +459,15 @@
background-color: inherit;
border-color: darkgray;
}
.shortlink.new input[name=toward]{
inline-size: 35ch;
}
.shortlink.new h3 {
margin-top: 0;
}
.shortlink.new form {
margin-top: 0;
margin-bottom: 0;
}
'''
--

View File

@ -2,6 +2,14 @@
/+ mip, server
|%
::
++ dejs-direct
|= jon=json
=, dejs:format
^- prism-action
:- %direct
%. jon
(ot ~[wright+so toward+so])
::
++ utm-parameters
^~
^- (set @t)