···11+# Binaries for programs and plugins
22+*.exe
33+*.exe~
44+*.dll
55+*.so
66+*.dylib
77+88+# Test binary, built with `go test -c`
99+*.test
1010+1111+# Output of the go coverage tool, specifically when used with LiteIDE
1212+*.out
1313+1414+# Dependency directories (remove the comment below to include it)
1515+# vendor/
1616+1717+# Go workspace file
1818+go.work
+373
LICENSE
···11+Mozilla Public License Version 2.0
22+==================================
33+44+1. Definitions
55+--------------
66+77+1.1. "Contributor"
88+ means each individual or legal entity that creates, contributes to
99+ the creation of, or owns Covered Software.
1010+1111+1.2. "Contributor Version"
1212+ means the combination of the Contributions of others (if any) used
1313+ by a Contributor and that particular Contributor's Contribution.
1414+1515+1.3. "Contribution"
1616+ means Covered Software of a particular Contributor.
1717+1818+1.4. "Covered Software"
1919+ means Source Code Form to which the initial Contributor has attached
2020+ the notice in Exhibit A, the Executable Form of such Source Code
2121+ Form, and Modifications of such Source Code Form, in each case
2222+ including portions thereof.
2323+2424+1.5. "Incompatible With Secondary Licenses"
2525+ means
2626+2727+ (a) that the initial Contributor has attached the notice described
2828+ in Exhibit B to the Covered Software; or
2929+3030+ (b) that the Covered Software was made available under the terms of
3131+ version 1.1 or earlier of the License, but not also under the
3232+ terms of a Secondary License.
3333+3434+1.6. "Executable Form"
3535+ means any form of the work other than Source Code Form.
3636+3737+1.7. "Larger Work"
3838+ means a work that combines Covered Software with other material, in
3939+ a separate file or files, that is not Covered Software.
4040+4141+1.8. "License"
4242+ means this document.
4343+4444+1.9. "Licensable"
4545+ means having the right to grant, to the maximum extent possible,
4646+ whether at the time of the initial grant or subsequently, any and
4747+ all of the rights conveyed by this License.
4848+4949+1.10. "Modifications"
5050+ means any of the following:
5151+5252+ (a) any file in Source Code Form that results from an addition to,
5353+ deletion from, or modification of the contents of Covered
5454+ Software; or
5555+5656+ (b) any new file in Source Code Form that contains any Covered
5757+ Software.
5858+5959+1.11. "Patent Claims" of a Contributor
6060+ means any patent claim(s), including without limitation, method,
6161+ process, and apparatus claims, in any patent Licensable by such
6262+ Contributor that would be infringed, but for the grant of the
6363+ License, by the making, using, selling, offering for sale, having
6464+ made, import, or transfer of either its Contributions or its
6565+ Contributor Version.
6666+6767+1.12. "Secondary License"
6868+ means either the GNU General Public License, Version 2.0, the GNU
6969+ Lesser General Public License, Version 2.1, the GNU Affero General
7070+ Public License, Version 3.0, or any later versions of those
7171+ licenses.
7272+7373+1.13. "Source Code Form"
7474+ means the form of the work preferred for making modifications.
7575+7676+1.14. "You" (or "Your")
7777+ means an individual or a legal entity exercising rights under this
7878+ License. For legal entities, "You" includes any entity that
7979+ controls, is controlled by, or is under common control with You. For
8080+ purposes of this definition, "control" means (a) the power, direct
8181+ or indirect, to cause the direction or management of such entity,
8282+ whether by contract or otherwise, or (b) ownership of more than
8383+ fifty percent (50%) of the outstanding shares or beneficial
8484+ ownership of such entity.
8585+8686+2. License Grants and Conditions
8787+--------------------------------
8888+8989+2.1. Grants
9090+9191+Each Contributor hereby grants You a world-wide, royalty-free,
9292+non-exclusive license:
9393+9494+(a) under intellectual property rights (other than patent or trademark)
9595+ Licensable by such Contributor to use, reproduce, make available,
9696+ modify, display, perform, distribute, and otherwise exploit its
9797+ Contributions, either on an unmodified basis, with Modifications, or
9898+ as part of a Larger Work; and
9999+100100+(b) under Patent Claims of such Contributor to make, use, sell, offer
101101+ for sale, have made, import, and otherwise transfer either its
102102+ Contributions or its Contributor Version.
103103+104104+2.2. Effective Date
105105+106106+The licenses granted in Section 2.1 with respect to any Contribution
107107+become effective for each Contribution on the date the Contributor first
108108+distributes such Contribution.
109109+110110+2.3. Limitations on Grant Scope
111111+112112+The licenses granted in this Section 2 are the only rights granted under
113113+this License. No additional rights or licenses will be implied from the
114114+distribution or licensing of Covered Software under this License.
115115+Notwithstanding Section 2.1(b) above, no patent license is granted by a
116116+Contributor:
117117+118118+(a) for any code that a Contributor has removed from Covered Software;
119119+ or
120120+121121+(b) for infringements caused by: (i) Your and any other third party's
122122+ modifications of Covered Software, or (ii) the combination of its
123123+ Contributions with other software (except as part of its Contributor
124124+ Version); or
125125+126126+(c) under Patent Claims infringed by Covered Software in the absence of
127127+ its Contributions.
128128+129129+This License does not grant any rights in the trademarks, service marks,
130130+or logos of any Contributor (except as may be necessary to comply with
131131+the notice requirements in Section 3.4).
132132+133133+2.4. Subsequent Licenses
134134+135135+No Contributor makes additional grants as a result of Your choice to
136136+distribute the Covered Software under a subsequent version of this
137137+License (see Section 10.2) or under the terms of a Secondary License (if
138138+permitted under the terms of Section 3.3).
139139+140140+2.5. Representation
141141+142142+Each Contributor represents that the Contributor believes its
143143+Contributions are its original creation(s) or it has sufficient rights
144144+to grant the rights to its Contributions conveyed by this License.
145145+146146+2.6. Fair Use
147147+148148+This License is not intended to limit any rights You have under
149149+applicable copyright doctrines of fair use, fair dealing, or other
150150+equivalents.
151151+152152+2.7. Conditions
153153+154154+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155155+in Section 2.1.
156156+157157+3. Responsibilities
158158+-------------------
159159+160160+3.1. Distribution of Source Form
161161+162162+All distribution of Covered Software in Source Code Form, including any
163163+Modifications that You create or to which You contribute, must be under
164164+the terms of this License. You must inform recipients that the Source
165165+Code Form of the Covered Software is governed by the terms of this
166166+License, and how they can obtain a copy of this License. You may not
167167+attempt to alter or restrict the recipients' rights in the Source Code
168168+Form.
169169+170170+3.2. Distribution of Executable Form
171171+172172+If You distribute Covered Software in Executable Form then:
173173+174174+(a) such Covered Software must also be made available in Source Code
175175+ Form, as described in Section 3.1, and You must inform recipients of
176176+ the Executable Form how they can obtain a copy of such Source Code
177177+ Form by reasonable means in a timely manner, at a charge no more
178178+ than the cost of distribution to the recipient; and
179179+180180+(b) You may distribute such Executable Form under the terms of this
181181+ License, or sublicense it under different terms, provided that the
182182+ license for the Executable Form does not attempt to limit or alter
183183+ the recipients' rights in the Source Code Form under this License.
184184+185185+3.3. Distribution of a Larger Work
186186+187187+You may create and distribute a Larger Work under terms of Your choice,
188188+provided that You also comply with the requirements of this License for
189189+the Covered Software. If the Larger Work is a combination of Covered
190190+Software with a work governed by one or more Secondary Licenses, and the
191191+Covered Software is not Incompatible With Secondary Licenses, this
192192+License permits You to additionally distribute such Covered Software
193193+under the terms of such Secondary License(s), so that the recipient of
194194+the Larger Work may, at their option, further distribute the Covered
195195+Software under the terms of either this License or such Secondary
196196+License(s).
197197+198198+3.4. Notices
199199+200200+You may not remove or alter the substance of any license notices
201201+(including copyright notices, patent notices, disclaimers of warranty,
202202+or limitations of liability) contained within the Source Code Form of
203203+the Covered Software, except that You may alter any license notices to
204204+the extent required to remedy known factual inaccuracies.
205205+206206+3.5. Application of Additional Terms
207207+208208+You may choose to offer, and to charge a fee for, warranty, support,
209209+indemnity or liability obligations to one or more recipients of Covered
210210+Software. However, You may do so only on Your own behalf, and not on
211211+behalf of any Contributor. You must make it absolutely clear that any
212212+such warranty, support, indemnity, or liability obligation is offered by
213213+You alone, and You hereby agree to indemnify every Contributor for any
214214+liability incurred by such Contributor as a result of warranty, support,
215215+indemnity or liability terms You offer. You may include additional
216216+disclaimers of warranty and limitations of liability specific to any
217217+jurisdiction.
218218+219219+4. Inability to Comply Due to Statute or Regulation
220220+---------------------------------------------------
221221+222222+If it is impossible for You to comply with any of the terms of this
223223+License with respect to some or all of the Covered Software due to
224224+statute, judicial order, or regulation then You must: (a) comply with
225225+the terms of this License to the maximum extent possible; and (b)
226226+describe the limitations and the code they affect. Such description must
227227+be placed in a text file included with all distributions of the Covered
228228+Software under this License. Except to the extent prohibited by statute
229229+or regulation, such description must be sufficiently detailed for a
230230+recipient of ordinary skill to be able to understand it.
231231+232232+5. Termination
233233+--------------
234234+235235+5.1. The rights granted under this License will terminate automatically
236236+if You fail to comply with any of its terms. However, if You become
237237+compliant, then the rights granted under this License from a particular
238238+Contributor are reinstated (a) provisionally, unless and until such
239239+Contributor explicitly and finally terminates Your grants, and (b) on an
240240+ongoing basis, if such Contributor fails to notify You of the
241241+non-compliance by some reasonable means prior to 60 days after You have
242242+come back into compliance. Moreover, Your grants from a particular
243243+Contributor are reinstated on an ongoing basis if such Contributor
244244+notifies You of the non-compliance by some reasonable means, this is the
245245+first time You have received notice of non-compliance with this License
246246+from such Contributor, and You become compliant prior to 30 days after
247247+Your receipt of the notice.
248248+249249+5.2. If You initiate litigation against any entity by asserting a patent
250250+infringement claim (excluding declaratory judgment actions,
251251+counter-claims, and cross-claims) alleging that a Contributor Version
252252+directly or indirectly infringes any patent, then the rights granted to
253253+You by any and all Contributors for the Covered Software under Section
254254+2.1 of this License shall terminate.
255255+256256+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
257257+end user license agreements (excluding distributors and resellers) which
258258+have been validly granted by You or Your distributors under this License
259259+prior to termination shall survive termination.
260260+261261+************************************************************************
262262+* *
263263+* 6. Disclaimer of Warranty *
264264+* ------------------------- *
265265+* *
266266+* Covered Software is provided under this License on an "as is" *
267267+* basis, without warranty of any kind, either expressed, implied, or *
268268+* statutory, including, without limitation, warranties that the *
269269+* Covered Software is free of defects, merchantable, fit for a *
270270+* particular purpose or non-infringing. The entire risk as to the *
271271+* quality and performance of the Covered Software is with You. *
272272+* Should any Covered Software prove defective in any respect, You *
273273+* (not any Contributor) assume the cost of any necessary servicing, *
274274+* repair, or correction. This disclaimer of warranty constitutes an *
275275+* essential part of this License. No use of any Covered Software is *
276276+* authorized under this License except under this disclaimer. *
277277+* *
278278+************************************************************************
279279+280280+************************************************************************
281281+* *
282282+* 7. Limitation of Liability *
283283+* -------------------------- *
284284+* *
285285+* Under no circumstances and under no legal theory, whether tort *
286286+* (including negligence), contract, or otherwise, shall any *
287287+* Contributor, or anyone who distributes Covered Software as *
288288+* permitted above, be liable to You for any direct, indirect, *
289289+* special, incidental, or consequential damages of any character *
290290+* including, without limitation, damages for lost profits, loss of *
291291+* goodwill, work stoppage, computer failure or malfunction, or any *
292292+* and all other commercial damages or losses, even if such party *
293293+* shall have been informed of the possibility of such damages. This *
294294+* limitation of liability shall not apply to liability for death or *
295295+* personal injury resulting from such party's negligence to the *
296296+* extent applicable law prohibits such limitation. Some *
297297+* jurisdictions do not allow the exclusion or limitation of *
298298+* incidental or consequential damages, so this exclusion and *
299299+* limitation may not apply to You. *
300300+* *
301301+************************************************************************
302302+303303+8. Litigation
304304+-------------
305305+306306+Any litigation relating to this License may be brought only in the
307307+courts of a jurisdiction where the defendant maintains its principal
308308+place of business and such litigation shall be governed by laws of that
309309+jurisdiction, without reference to its conflict-of-law provisions.
310310+Nothing in this Section shall prevent a party's ability to bring
311311+cross-claims or counter-claims.
312312+313313+9. Miscellaneous
314314+----------------
315315+316316+This License represents the complete agreement concerning the subject
317317+matter hereof. If any provision of this License is held to be
318318+unenforceable, such provision shall be reformed only to the extent
319319+necessary to make it enforceable. Any law or regulation which provides
320320+that the language of a contract shall be construed against the drafter
321321+shall not be used to construe this License against a Contributor.
322322+323323+10. Versions of the License
324324+---------------------------
325325+326326+10.1. New Versions
327327+328328+Mozilla Foundation is the license steward. Except as provided in Section
329329+10.3, no one other than the license steward has the right to modify or
330330+publish new versions of this License. Each version will be given a
331331+distinguishing version number.
332332+333333+10.2. Effect of New Versions
334334+335335+You may distribute the Covered Software under the terms of the version
336336+of the License under which You originally received the Covered Software,
337337+or under the terms of any subsequent version published by the license
338338+steward.
339339+340340+10.3. Modified Versions
341341+342342+If you create software not governed by this License, and you want to
343343+create a new license for such software, you may create and use a
344344+modified version of this License if you rename the license and remove
345345+any references to the name of the license steward (except to note that
346346+such modified license differs from this License).
347347+348348+10.4. Distributing Source Code Form that is Incompatible With Secondary
349349+Licenses
350350+351351+If You choose to distribute Source Code Form that is Incompatible With
352352+Secondary Licenses under the terms of this version of the License, the
353353+notice described in Exhibit B of this License must be attached.
354354+355355+Exhibit A - Source Code Form License Notice
356356+-------------------------------------------
357357+358358+ This Source Code Form is subject to the terms of the Mozilla Public
359359+ License, v. 2.0. If a copy of the MPL was not distributed with this
360360+ file, You can obtain one at https://mozilla.org/MPL/2.0/.
361361+362362+If it is not possible or desirable to put the notice in a particular
363363+file, then You may include the notice in a location (such as a LICENSE
364364+file in a relevant directory) where a recipient would be likely to look
365365+for such a notice.
366366+367367+You may add additional accurate notices of copyright ownership.
368368+369369+Exhibit B - "Incompatible With Secondary Licenses" Notice
370370+---------------------------------------------------------
371371+372372+ This Source Code Form is "Incompatible With Secondary Licenses", as
373373+ defined by the Mozilla Public License, v. 2.0.
+14
README.md
···11+# GoAT Site
22+33+GoAT Site implements [standard.site](https://standard.site/) in Go.
44+55+Use official [`bluesky-social/indigo`](https://github.com/bluesky-social/indigo/).
66+77+## Usage
88+99+Get the module with:
1010+```bash
1111+go get -u tangled.org/anhgelus.world/goat-site
1212+```
1313+1414+
+49
document.go
···11+package site
22+33+import "time"
44+55+const LexiconDocument = LexiconBase + ".document"
66+77+// Document may be standalone or associated with a [Publication].
88+// This lexicon can be used to store a document's content and its associated metadata.
99+type Document struct {
1010+ // Site points to a [Publication] record `at://` or a [Publication.URL] `https://` for loose documents.
1111+ // Avoid trailing slashes.
1212+ Site string `json:"site"`
1313+ // Title of the [Document].
1414+ // Max length: 5000.
1515+ // Max graphemes: 500.
1616+ Title string `json:"title"`
1717+ // PublishedAt is the [time.Time] of the [Document]'s publish time.
1818+ PublishedAt time.Time `json:"-"`
1919+ // Path is combined with [Document.Site] or [Publication.URL] to construct a canonical URL to the document.
2020+ // A slash should be included at the beginning of this value.
2121+ Path *string `json:"path,omitempty"`
2222+ // A brief Description or excerpt from the [Document].
2323+ // Max length: 30000.
2424+ // Max graphemes: 3000.
2525+ Description *string `json:"description,omitempty"`
2626+ // CoverImage to used for thumbnail or cover.
2727+ // Less than 1MB is size.
2828+ CoverImage any `json:"-"`
2929+ // Content is an open union used to define the [Document]'s content.
3030+ // Each entry must specify a `$type`.
3131+ Content []any `json:"-"`
3232+ // TextContent is a plaintext representation of the [Document.Content].
3333+ // Should not contain markdown or other formatting.
3434+ TextContent string `json:"textContent,omitempty"`
3535+ // BlueskyPostRef is a strong reference to a Bluesky post.
3636+ // Useful to keep track of comments off-platform.
3737+ BlueskyPostRef any `json:"bskyPostRef,omitempty"`
3838+ // Tags is an array of strings used to tag or categorize the [Document].
3939+ // Avoid prepending tags with hashtags.
4040+ // Max length: 1280.
4141+ // Max graphemes: 128.
4242+ Tags []string `json:"tags,omitempty"`
4343+ // UpdatedAt is the [time.Time] of the [Document]'s last edit.
4444+ UpdatedAt *time.Time `json:"-"`
4545+}
4646+4747+func (d *Document) Type() string {
4848+ return LexiconDocument
4949+}
···11+package site
22+33+import (
44+ "encoding/json"
55+ "errors"
66+)
77+88+type Lexicon interface {
99+ Type() string
1010+}
1111+1212+const LexiconBase = "site.standard"
1313+1414+// LexiconJSON is used to convert [Lexicon] into JSON.
1515+type LexiconJSON struct {
1616+ Lexicon
1717+}
1818+1919+func (l LexiconJSON) MarshalJSON() ([]byte, error) {
2020+ v := struct {
2121+ any
2222+ Type string `json:"$type"`
2323+ }{nil, l.Type()}
2424+ switch l.Type() {
2525+ case LexiconPublication:
2626+ v.any = l.Lexicon.(*Publication)
2727+ case LexiconDocument:
2828+ v.any = l.Lexicon.(*Document)
2929+ case LexiconSubscription:
3030+ v.any = l.Lexicon.(*Subscription)
3131+ case LexiconTheme:
3232+ v.any = l.Lexicon.(*Theme)
3333+ case LexiconThemeColorRGB:
3434+ v.any = l.Lexicon.(*RGB)
3535+ case LexiconThemeColorRGBA:
3636+ v.any = l.Lexicon.(*RGBA)
3737+ default:
3838+ return nil, errors.New("unsupported lexicon type")
3939+ }
4040+ return json.Marshal(v)
4141+}
4242+4343+func (l LexiconJSON) UnmarshalJSON(b []byte) error {
4444+ var v struct {
4545+ Type string `json:"$type"`
4646+ }
4747+ err := json.Unmarshal(b, &v)
4848+ if err != nil {
4949+ return err
5050+ }
5151+ switch v.Type {
5252+ case LexiconPublication:
5353+ l.Lexicon = l.Lexicon.(*Publication)
5454+ case LexiconDocument:
5555+ l.Lexicon = l.Lexicon.(*Document)
5656+ case LexiconSubscription:
5757+ l.Lexicon = l.Lexicon.(*Subscription)
5858+ case LexiconTheme:
5959+ l.Lexicon = l.Lexicon.(*Theme)
6060+ case LexiconThemeColorRGB:
6161+ l.Lexicon = l.Lexicon.(*RGB)
6262+ case LexiconThemeColorRGBA:
6363+ l.Lexicon = l.Lexicon.(*RGBA)
6464+ default:
6565+ return errors.New("unsupported lexicon type")
6666+ }
6767+ return json.Unmarshal(b, l.Lexicon)
6868+}
+41
publication.go
···11+package site
22+33+const LexiconPublication = LexiconBase + ".publication"
44+55+// Publication represents a collection of documents published to the web.
66+// It includes important information about a publication including its location on the web, theming information, user
77+// preferences, and more.
88+//
99+// The publication lexicon is not a requirement, but is recommended when publishing collections of related documents.
1010+type Publication struct {
1111+ // Base URL of the [Publication].
1212+ // This value will be combined with the [Document.Path] to construct a full URL for the document.
1313+ // Avoid trailing slashes.
1414+ URL string `json:"string"`
1515+ // Name of the [Publication].
1616+ // Max length: 5000.
1717+ // Max graphemes: 500.
1818+ Name string `json:"name"`
1919+ // Icon to identify the [Publication].
2020+ // Must be a square image and should be at least 256x256.
2121+ Icon any `json:"-"`
2222+ // Description of the [Publication].
2323+ // Max length: 30000.
2424+ // Max graphemes: 3000.
2525+ Description *string `json:"description,omitempty"`
2626+ // Simplified theme for tools and apps to utilize when displaying content.
2727+ // Ref to `site.standard.theme.basic`.
2828+ BasicTheme any `json:"basicTheme,omitempty"`
2929+ // Platform-specific [Preferences] for the [Publication], including discovery and visibility settings.
3030+ Preferences *Preferences `json:"preferences,omitempty"`
3131+}
3232+3333+// Preferences of the [Publication].
3434+type Preferences struct {
3535+ // ShowInDiscover decides whether the [Publication] should appear in discovery feeds.
3636+ ShowInDiscover bool `json:"showInDiscover"`
3737+}
3838+3939+func (p *Publication) Type() string {
4040+ return LexiconPublication
4141+}
+15
subscription.go
···11+package site
22+33+const LexiconSubscription = LexiconBase + ".graph.subscription"
44+55+// Subscription enable users to follow publications and receive updates about new content.
66+// They represent the social connection between readers and the publications they're interested in.
77+type Subscription struct {
88+ // Publication is an AT-URI reference to the publication record being subscribed to.
99+ // E.g., `at://did:plc:abc123/site.standard.publication/xyz789`.
1010+ Publication string `json:"publication"`
1111+}
1212+1313+func (s *Subscription) Type() string {
1414+ return LexiconSubscription
1515+}
+64
theme.go
···11+package site
22+33+import (
44+ "image/color"
55+ "math"
66+)
77+88+const (
99+ LexiconTheme = LexiconBase + ".theme"
1010+ LexiconThemeColor = LexiconTheme + ".color"
1111+ LexiconThemeColorRGB = LexiconThemeColor + "#rgb"
1212+ LexiconThemeColorRGBA = LexiconThemeColor + "#rgba"
1313+)
1414+1515+// Theme ensures [Publication]s maintain their visual identity across different reading applications and platforms by
1616+// defining core colors for content display.
1717+type Theme struct {
1818+ // Background is the color used for content background.
1919+ Background any `json:"background"`
2020+ // Foreground is the color used for content text.
2121+ Foreground any `json:"foreground"`
2222+ // Accent is the color used for links and button backgrounds.
2323+ Accent any `json:"accent"`
2424+ // AccentForeground is the color used for button text.
2525+ AccentForeground any `json:"accentForeground"`
2626+}
2727+2828+func (t *Theme) Type() string {
2929+ return LexiconTheme
3030+}
3131+3232+// RGB represents a RGB color.
3333+type RGB struct {
3434+ Red uint8 `json:"r"`
3535+ Green uint8 `json:"g"`
3636+ Blue uint8 `json:"b"`
3737+}
3838+3939+func (r *RGB) Type() string {
4040+ return LexiconThemeColorRGB
4141+}
4242+4343+func (r *RGB) RGBA() *RGBA {
4444+ return &RGBA{*r, 100}
4545+}
4646+4747+// RGBA represents a [color.RGBA].
4848+type RGBA struct {
4949+ RGB
5050+ // Alpha is the alpha channel where 0 is transparent and 100 is opaque.
5151+ Alpha uint8 `json:"a"`
5252+}
5353+5454+func (r *RGBA) Type() string {
5555+ return LexiconThemeColorRGBA
5656+}
5757+5858+func NewRGBA(r *color.RGBA) *RGBA {
5959+ red, g, b, a := r.RGBA()
6060+ return &RGBA{
6161+ RGB: RGB{uint8(red), uint8(g), uint8(b)},
6262+ Alpha: uint8(math.Floor(float64(a)/float64(255)) * 100),
6363+ }
6464+}