This commit is contained in:
19 files changed
+559
-57
No files matched your search
@@ -12,8 +12,6 @@ type SubjectSet struct {
|
||||
event.IsEvent `json:"-"`
|
||||
}
|
||||
|
||||
var _ event.Event = (*SubjectSet)(nil)
|
||||
|
||||
type SubjectDeleted struct {
|
||||
Subject string `json:"subject"`
|
||||
|
||||
@@ -29,6 +27,7 @@ type LinkSet struct {
|
||||
HRef string `json:"href,omitempty"`
|
||||
Titles map[string]string `json:"titles,omitempty"`
|
||||
Properties map[string]*string `json:"properties,omitempty"`
|
||||
Template string `json:"template,omitempty"`
|
||||
|
||||
event.IsEvent `json:"-"`
|
||||
}
|
||||
|
||||
+10
-16
@@ -54,6 +54,7 @@ type Link struct {
|
||||
HRef string `json:"href,omitempty"`
|
||||
Titles map[string]string `json:"titles,omitempty"`
|
||||
Properties map[string]*string `json:"properties,omitempty"`
|
||||
Template string `json:"template,omitempty"`
|
||||
}
|
||||
|
||||
type Links []*Link
|
||||
@@ -198,6 +199,7 @@ func (a *JRD) ApplyEvent(events ...event.Event) {
|
||||
link.Type = e.Type
|
||||
link.Titles = e.Titles
|
||||
link.Properties = e.Properties
|
||||
link.Template = e.Template
|
||||
|
||||
case *LinkDeleted:
|
||||
a.Links = slice.FilterFn(func(link *Link) bool { return link.Index != e.Index }, a.Links...)
|
||||
@@ -249,8 +251,8 @@ func (a *JRD) OnClaims(jrd *JRD) error {
|
||||
}
|
||||
|
||||
for _, z := range slice.Align(
|
||||
jrd.Links,
|
||||
a.Links,
|
||||
a.Links, // old
|
||||
jrd.Links, // new
|
||||
func(l, r *Link) bool { return l.Index < r.Index },
|
||||
) {
|
||||
// Not in new == delete
|
||||
@@ -270,6 +272,7 @@ func (a *JRD) OnClaims(jrd *JRD) error {
|
||||
HRef: link.HRef,
|
||||
Titles: link.Titles,
|
||||
Properties: link.Properties,
|
||||
Template: link.Template,
|
||||
})
|
||||
continue
|
||||
}
|
||||
@@ -336,23 +339,20 @@ func (a *JRD) OnLinkSet(o, n *Link) error {
|
||||
HRef: n.HRef,
|
||||
Titles: n.Titles,
|
||||
Properties: n.Properties,
|
||||
Template: n.Template,
|
||||
}
|
||||
|
||||
// if n.Index != o.Index {
|
||||
// fmt.Println(342)
|
||||
// modified = true
|
||||
// }
|
||||
if n.Rel != o.Rel {
|
||||
fmt.Println(346)
|
||||
modified = true
|
||||
}
|
||||
if n.Type != o.Type {
|
||||
fmt.Println(350)
|
||||
|
||||
modified = true
|
||||
}
|
||||
if n.HRef != o.HRef {
|
||||
fmt.Println(355)
|
||||
modified = true
|
||||
}
|
||||
if n.Template != o.Template {
|
||||
fmt.Println(360, n.Template, o.Template, e.Template)
|
||||
|
||||
modified = true
|
||||
}
|
||||
@@ -368,8 +368,6 @@ func (a *JRD) OnLinkSet(o, n *Link) error {
|
||||
slice.Zip(oKeys, slice.FromMapValues(o.Titles, oKeys)),
|
||||
) {
|
||||
if z.Key != z.Value {
|
||||
fmt.Println(365)
|
||||
|
||||
modified = true
|
||||
break
|
||||
}
|
||||
@@ -389,15 +387,11 @@ func (a *JRD) OnLinkSet(o, n *Link) error {
|
||||
curValue := z.Value
|
||||
|
||||
if newValue.Key != curValue.Key {
|
||||
fmt.Println(380, newValue.Key, curValue.Key)
|
||||
|
||||
modified = true
|
||||
break
|
||||
}
|
||||
|
||||
if !cmpPtr(newValue.Value, curValue.Value) {
|
||||
fmt.Println(387)
|
||||
|
||||
modified = true
|
||||
break
|
||||
}
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
/*!
|
||||
* Bootstrap v3.3.6 (http://getbootstrap.com)
|
||||
* Copyright 2011-2015 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
*//*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{margin:0;font:inherit;color:inherit}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}input{line-height:normal}input[type=checkbox],input[type=radio]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid silver}legend{padding:0;border:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-spacing:0;border-collapse:collapse}td,th{padding:0}/*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */@media print{*,:after,:before{color:#000!important;text-shadow:none!important;background:0 0!important;-webkit-box-shadow:none!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}a[href^="javascript:"]:after,a[href^="#"]:after{content:""}blockquote,pre{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}img,tr{page-break-inside:avoid}img{max-width:100%!important}h2,h3,p{orphans:3;widows:3}h2,h3{page-break-after:avoid}.navbar{display:none}.btn>.caret,.dropup>.btn>.caret{border-top-color:#000!important}.label{border:1px solid #000}.table{border-collapse:collapse!important}.table td,.table th{background-color:#fff!important}.table-bordered td,.table-bordered th{border:1px solid #ddd!important}}@font-face{font-family:'Glyphicons Halflings';src:url(../fonts/glyphicons-halflings-regular.eot);src:url(../fonts/glyphicons-halflings-regular.eot?#iefix) format('embedded-opentype'),url(../fonts/glyphicons-halflings-regular.woff2) format('woff2'),url(../fonts/glyphicons-halflings-regular.woff) format('woff'),url(../fonts/glyphicons-halflings-regular.ttf) format('truetype'),url(../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular) format('svg')}.glyphicon{position:relative;top:1px;display:inline-block;font-family:'Glyphicons Halflings';font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.glyphicon-asterisk:before{content:"\002a"}.glyphicon-plus:before{content:"\002b"}.glyphicon-eur:before,.glyphicon-euro:before{content:"\20ac"}.glyphicon-minus:before{content:"\2212"}.glyphicon-cloud:before{content:"\2601"}.glyphicon-envelope:before{content:"\2709"}.glyphicon-pencil:before{content:"\270f"}.glyphicon-glass:before{content:"\e001"}.glyphicon-music:before{content:"\e002"}.glyphicon-search:before{content:"\e003"}.glyphicon-heart:before{content:"\e005"}.glyphicon-star:before{content:"\e006"}.glyphicon-star-empty:before{content:"\e007"}.glyphicon-user:before{content:"\e008"}.glyphicon-film:before{content:"\e009"}.glyphicon-th-large:before{content:"\e010"}.glyphicon-th:before{content:"\e011"}.glyphicon-th-list:before{content:"\e012"}.glyphicon-ok:before{content:"\e013"}.glyphicon-remove:before{content:"\e014"}.glyphicon-zoom-in:before{content:"\e015"}.glyphicon-zoom-out:before{content:"\e016"}.glyphicon-off:before{content:"\e017"}.glyphicon-signal:before{content:"\e018"}.glyphicon-cog:before{content:"\e019"}.glyphicon-trash:before{content:"\e020"}.glyphicon-home:before{content:"\e021"}.glyphicon-file:before{content:"\e022"}.glyphicon-time:before{content:"\e023"}.glyphicon-road:before{content:"\e024"}.glyphicon-download-alt:before{content:"\e025"}.glyphicon-download:before{content:"\Line truncated
|
||||
/*# sourceMappingURL=bootstrap.min.css.map */
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["less/normalize.less","less/print.less","bootstrap.css","dist/css/bootstrap.css","less/glyphicons.less","less/scaffolding.less","less/mixins/vendor-prefixes.less","less/mixins/tab-focus.less","less/mixins/image.less","less/type.less","less/mixins/text-emphasis.less","less/mixins/background-variant.less","less/mixins/text-overflow.less","less/code.less","less/grid.less","less/mixins/grid.less","less/mixins/grid-framework.less","less/tables.less","less/mixins/table-row.less","less/forms.less","less/mixins/forms.less","less/buttons.less","less/mixins/buttons.less","less/mixins/opacity.less","less/component-animations.less","less/dropdowns.less","less/mixins/nav-divider.less","less/mixins/reset-filter.less","less/button-groups.less","less/mixins/border-radius.less","less/input-groups.less","less/navs.less","less/navbar.less","less/mixins/nav-vertical-align.less","less/utilities.less","less/breadcrumbs.less","less/pagination.less","less/mixins/pagination.less","less/pager.less","less/labels.less","less/mixins/labels.less","less/badges.less","less/jumbotron.less","less/thumbnails.less","less/alerts.less","less/mixins/alerts.less","less/progress-bars.less","less/mixins/gradients.less","less/mixins/progress-bar.less","less/media.less","less/list-group.less","less/mixins/list-group.less","less/panels.less","less/mixins/panels.less","less/responsive-embed.less","less/wells.less","less/close.less","less/modals.less","less/tooltip.less","less/mixins/reset-text.less","less/popovers.less","less/carousel.less","less/mixins/clearfix.less","less/mixins/center-block.less","less/mixins/hide-text.less","less/responsive-utilities.less","less/mixins/responsive-visibility.less"],"names":[],"mappings":";;;;4EAQA,KACE,YAAA,WACA,yBAAA,KACA,qBAAA,KAOF,KACE,OAAA,EAaF,QAAA,MAAA,QAAA,WAAA,OAAA,OAAA,OAAA,OAAA,KAAA,KAAA,IAAA,QAAA,QAaE,QAAA,MAQF,MAA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AA,QACX,uBAAW,QAAA,QACX,uBAAW,QAAA,QACX,+BAAW,QAAA,QACX,2BAAW,QAAA,QACX,yBAAW,QAAA,QACX,wBAAW,QAAA,QACX,8BAAW,QAAA,QACX,yBAAW,QAAA,QACX,0BAAW,QAAA,QACX,2BAAW,QAAA,QACX,uBAAW,QAAA,QACX,uBAAW,QAAA,QACX,6BAAW,QAAA,QACX,6BAAW,QAAA,QACX,8BAAW,QAAA,QACX,4BAAW,QAAA,QACX,yBAAW,QAAA,QACX,0BAAW,QAAA,QACX,sBAAW,QAAA,QACX,uBAAW,QAAA,QACX,uBAAW,QAAA,QACX,2BAAW,QAAA,QACX,wBAAW,QAAA,QACX,yBAAW,QAAA,QACX,uBAAW,QAAA,QACX,uBAAW,QAAA,QACX,yBAAW,QAAA,QACX,8BAAW,QAAA,QACX,6BAAW,QAAA,QACX,6BAAW,QAAA,QACX,+BAAW,QAAA,QACX,8BAAW,QAAA,QACX,gCAAW,QAAA,QACX,uBAAW,QAAA,QACX,8BAAW,QAAA,QACX,+BAAW,QAAA,QACX,iCAAW,QAAA,QACX,0BAAW,QAAA,QACX,6BAAW,QAAA,QACX,yBAAW,QAAA,QACX,uBAAW,QAAA,QACX,uBAAW,QAAA,QACX,wBAAW,QAAA,QACX,wBAAW,QAAA,QACX,uBAAW,QAAA,QACX,gCAAW,QAAA,QACX,gCAAW,QAAA,QACX,2BAAW,QAAA,QACX,uBAAW,QAAA,QACX,wBAAW,QAAA,QACX,uBAAW,QAAA,QACX,0BAAW,QAAA,QACX,+BAAW,QAAA,QACX,+BAAW,QAAA,QACX,wBAAW,QAAA,QACX,+BAAW,QAAA,QACX,gCAAW,QAAA,QACX,4BAAW,QAAA,QACX,6BAAW,QAAA,QACX,8BAAW,QAAA,QACX,0BAAW,QAAA,QACX,gCAAW,QAAA,QACX,4BLine truncated
|
||||
@@ -0,0 +1,95 @@
|
||||
/* Space out content a bit */
|
||||
body {
|
||||
padding-top: 20px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
/* Everything but the jumbotron gets side spacing for mobile first views */
|
||||
.header,
|
||||
.footer {
|
||||
padding-right: 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
/* Custom page header */
|
||||
.header {
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
}
|
||||
/* Make the masthead heading the same height as the navigation */
|
||||
.header h3 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
/* Custom page footer */
|
||||
.footer {
|
||||
padding-top: 19px;
|
||||
color: #777;
|
||||
border-top: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.panel-heading a {
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.container-narrow > hr {
|
||||
margin: 30px 0;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body, .panel-body {
|
||||
color: white;
|
||||
background-color: #222;
|
||||
}
|
||||
nav.navbar-default {
|
||||
background-color: rgb(35, 29, 71);
|
||||
}
|
||||
.navbar-default .navbar-brand {
|
||||
color: white;
|
||||
}
|
||||
.panel-primary, .list-group, .list-group-item {
|
||||
color: white;
|
||||
background-color: #16181c;
|
||||
}
|
||||
.table > tbody > tr.active > th, .table > tbody > tr.active > td {
|
||||
background-color: rgb(35, 29, 71);
|
||||
}
|
||||
.table-striped > tbody > tr:nth-of-type(2n+1) {
|
||||
background-color: rgb(35, 29, 71);
|
||||
}
|
||||
.panel pre {
|
||||
color: white;
|
||||
background-color: #16181c;
|
||||
}
|
||||
.panel .panel-primary > .panel-heading {
|
||||
background-color: rgb(35, 29, 71);
|
||||
}
|
||||
|
||||
.panel a {
|
||||
color: cornflowerblue;
|
||||
}
|
||||
|
||||
code {
|
||||
color: white;
|
||||
background-color: #282b32;
|
||||
}
|
||||
}
|
||||
|
||||
@import url(https://cdn.jsdelivr.net/npm/firacode@6.2.0/distr/fira_code.css);
|
||||
|
||||
code { font-family: 'Fira Code', monospace; }
|
||||
|
||||
@media (min-width: 100) {
|
||||
.truncate {
|
||||
width: 750px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.container {
|
||||
width: 750px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{{define "main"}}
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
{{template "meta" .}}
|
||||
<title>👉 Webfinger 👈</title>
|
||||
|
||||
|
||||
<link href="/webfinger/assets/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
|
||||
<link href="/webfinger/assets/webfinger.css" rel="stylesheet" crossorigin="anonymous">
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/webfinger">👉 Webfinger 👈</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class=container>
|
||||
{{template "content" .}}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
{{end}}
|
||||
@@ -0,0 +1,131 @@
|
||||
{{template "main" .}}
|
||||
|
||||
{{define "meta"}}{{end}}
|
||||
|
||||
{{define "content"}}
|
||||
<form method="GET">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" id="basic-addon1">resource</span>
|
||||
<input name="resource" class="form-control" placeholder="acct:..."/>
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="submit">Go!</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<br/>
|
||||
|
||||
{{ if ne .Err nil }}
|
||||
<div class="alert alert-danger" role="alert">
|
||||
{{ .Err }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ if ne .JRD nil }}
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">Webfinger Result</div>
|
||||
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th style="width:98px">Subject</th>
|
||||
<td>
|
||||
<div class="media">
|
||||
<div class="media-body">
|
||||
{{ .JRD.Subject }}
|
||||
</div>
|
||||
|
||||
{{ with .JRD.GetLinkByRel "http://webfinger.net/rel/avatar" }}
|
||||
{{ if ne . nil }}
|
||||
<div class="media-left media-middle">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<img src="{{ .HRef }}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{{if ne (len .JRD.Aliases) 0}}
|
||||
<tr>
|
||||
<th>Aliases</th>
|
||||
<td>
|
||||
<ul class="list-group">
|
||||
{{ range .JRD.Aliases }}<li class="list-group-item">{{ . }}</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
|
||||
{{ if ne (len .JRD.Properties) 0 }}
|
||||
<tr>
|
||||
<th>Properties</th>
|
||||
<td>
|
||||
<div class="list-group truncate">
|
||||
{{ range $key, $value := .JRD.Properties }}<div class="list-group-item">
|
||||
<h5 class="list-group-item-heading" title="{{ $key }}">{{ propName $key }}</h5>
|
||||
<code class="list-group-item-text">{{ $value }}</code>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
|
||||
{{ if ne (len .JRD.Links) 0 }}
|
||||
{{ range .JRD.Links }}
|
||||
<tr class="active">
|
||||
{{ if ne (len .Template) 0 }}
|
||||
<th> Template </th>
|
||||
<td>{{ .Template }}</td>
|
||||
{{ else }}
|
||||
<th> Link </th>
|
||||
<td>{{ if ne (len .HRef) 0 }}<a href="{{ .HRef }}" target="_blank">{{ .HRef }}</a>{{ end }}</td>
|
||||
{{ end }}
|
||||
<tr>
|
||||
<tr>
|
||||
<th> Properties </th>
|
||||
<td>
|
||||
<div class="list-group">
|
||||
<div class="list-group-item truncate">
|
||||
<h5 class="list-group-item-heading">rel<h5>
|
||||
<code class="list-group-item-text">{{ .Rel }}</code>
|
||||
</div>
|
||||
|
||||
{{ if ne (len .Type) 0 }}<div class="list-group-item truncate">
|
||||
<h5 class="list-group-item-heading">type</h5>
|
||||
<code class="list-group-item-text">{{ .Type }}</code>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ range $key, $value := .Properties }}<div class="list-group-item truncate">
|
||||
<h5 class="list-group-item-heading" title="{{ $key }}">{{ propName $key }}</h5>
|
||||
<code class="list-group-item-text">{{ $value }}</code>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
</table>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">Raw JRD</div>
|
||||
|
||||
<pre style="height: 15em; overflow-y: auto; border: 0px">
|
||||
Status: {{ .Status }}
|
||||
|
||||
{{ .Body | printf "%s" }}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
{{end}}
|
||||
+98
-26
@@ -3,13 +3,20 @@ package webfinger
|
||||
import (
|
||||
"context"
|
||||
"crypto/ed25519"
|
||||
"embed"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"html"
|
||||
"html/template"
|
||||
"io"
|
||||
"io/fs"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
@@ -19,6 +26,12 @@ import (
|
||||
"go.sour.is/ev/pkg/set"
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed ui/*/*
|
||||
files embed.FS
|
||||
templates map[string]*template.Template
|
||||
)
|
||||
|
||||
type service struct {
|
||||
es *ev.EventStore
|
||||
self set.Set[string]
|
||||
@@ -63,7 +76,13 @@ func New(ctx context.Context, es *ev.EventStore, opts ...Option) (*service, erro
|
||||
return svc, nil
|
||||
}
|
||||
|
||||
func (s *service) RegisterHTTP(mux *http.ServeMux) {}
|
||||
func (s *service) RegisterHTTP(mux *http.ServeMux) {
|
||||
a, _ := fs.Sub(files, "ui/assets")
|
||||
assets := http.StripPrefix("/webfinger/assets/", http.FileServer(http.FS(a)))
|
||||
|
||||
mux.Handle("/webfinger", s.ui())
|
||||
mux.Handle("/webfinger/assets/", assets)
|
||||
}
|
||||
func (s *service) RegisterWellKnown(mux *http.ServeMux) {
|
||||
mux.Handle("/webfinger", lg.Htrace(s, "webfinger"))
|
||||
}
|
||||
@@ -153,6 +172,8 @@ func (s *service) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
json.NewEncoder(os.Stdout).Encode(c.JRD)
|
||||
|
||||
for i := range c.JRD.Links {
|
||||
c.JRD.Links[i].Index = uint64(i)
|
||||
}
|
||||
@@ -307,37 +328,88 @@ func (s *service) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
span.AddEvent("method not allow: " + r.Method)
|
||||
}
|
||||
}
|
||||
func (s *service) ui() http.HandlerFunc {
|
||||
loadTemplates()
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
args := struct {
|
||||
Req *http.Request
|
||||
Status int
|
||||
Body []byte
|
||||
JRD *JRD
|
||||
Err error
|
||||
}{Status: http.StatusOK}
|
||||
|
||||
if r.URL.Query().Has("resource") {
|
||||
args.Req, args.Err = http.NewRequestWithContext(r.Context(), http.MethodGet, r.URL.String(), nil)
|
||||
if args.Err != nil {
|
||||
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
wr := httptest.NewRecorder()
|
||||
s.ServeHTTP(wr, args.Req)
|
||||
|
||||
args.Status = wr.Code
|
||||
|
||||
switch wr.Code {
|
||||
case http.StatusSeeOther:
|
||||
res, err := http.DefaultClient.Get(wr.Header().Get("location"))
|
||||
args.Err = err
|
||||
if err == nil {
|
||||
args.Status = res.StatusCode
|
||||
args.Body, args.Err = io.ReadAll(res.Body)
|
||||
}
|
||||
case http.StatusOK:
|
||||
args.Body, args.Err = io.ReadAll(wr.Body)
|
||||
if args.Err == nil {
|
||||
args.JRD, args.Err = ParseJRD(args.Body)
|
||||
}
|
||||
}
|
||||
if args.Err == nil && args.Body != nil {
|
||||
args.JRD, args.Err = ParseJRD(args.Body)
|
||||
}
|
||||
}
|
||||
|
||||
t := templates["home.go.tpl"]
|
||||
err := t.Execute(w, args)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func dec(s string) ([]byte, error) {
|
||||
s = strings.TrimSpace(s)
|
||||
return base64.RawURLEncoding.DecodeString(s)
|
||||
}
|
||||
|
||||
// func splitHostPort(hostPort string) (host, port string) {
|
||||
// host = hostPort
|
||||
var funcMap = map[string]any{
|
||||
"propName": func(in string) string { return in[strings.LastIndex(in, "/")+1:] },
|
||||
"escape": html.EscapeString,
|
||||
}
|
||||
|
||||
// colon := strings.LastIndexByte(host, ':')
|
||||
// if colon != -1 && validOptionalPort(host[colon:]) {
|
||||
// host, port = host[:colon], host[colon+1:]
|
||||
// }
|
||||
func loadTemplates() error {
|
||||
if templates != nil {
|
||||
return nil
|
||||
}
|
||||
templates = make(map[string]*template.Template)
|
||||
tmplFiles, err := fs.ReadDir(files, "ui/pages")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// if strings.HasPrefix(host, "[") && strings.HasSuffix(host, "]") {
|
||||
// host = host[1 : len(host)-1]
|
||||
// }
|
||||
for _, tmpl := range tmplFiles {
|
||||
if tmpl.IsDir() {
|
||||
continue
|
||||
}
|
||||
pt := template.New(tmpl.Name())
|
||||
pt.Funcs(funcMap)
|
||||
pt, err = pt.ParseFS(files, "ui/pages/"+tmpl.Name(), "ui/layouts/*.go.tpl")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
|
||||
// return
|
||||
// }
|
||||
// func validOptionalPort(port string) bool {
|
||||
// if port == "" {
|
||||
// return true
|
||||
// }
|
||||
// if port[0] != ':' {
|
||||
// return false
|
||||
// }
|
||||
// for _, b := range port[1:] {
|
||||
// if b < '0' || b > '9' {
|
||||
// return false
|
||||
// }
|
||||
// }
|
||||
// return true
|
||||
// }
|
||||
return err
|
||||
}
|
||||
templates[tmpl.Name()] = pt
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user