mirror of
https://github.com/yungcalibri/prism.git
synced 2024-10-05 23:08:02 +03:00
Compare commits
4 Commits
726ac713bb
...
131f24f499
Author | SHA1 | Date | |
---|---|---|---|
|
131f24f499 | ||
|
478b99b1aa | ||
|
486bb62f72 | ||
|
ce2929dc28 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
tgt*
|
41
README.md
Normal file
41
README.md
Normal 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.
|
@ -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])
|
@ -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]
|
@ -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,10 +245,12 @@
|
||||
=/ 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)
|
||||
=/ 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
|
||||
@ -286,6 +290,46 @@
|
||||
==
|
||||
==
|
||||
==
|
||||
;hr;
|
||||
;section(class "shortlink new")
|
||||
;stack-l
|
||||
;h3: New shortlink
|
||||
;form#new-shortlink
|
||||
=hx-post "/apps/prism/direct"
|
||||
=hx-target "#content"
|
||||
=hx-select "#content"
|
||||
;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
|
||||
==
|
||||
==
|
||||
==
|
||||
==
|
||||
==
|
||||
==
|
||||
:: end content
|
||||
==
|
||||
::
|
||||
@ -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;
|
||||
}
|
||||
'''
|
||||
--
|
@ -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)
|
Loading…
Reference in New Issue
Block a user