ral

package module
v0.0.0-...-eeb3f6b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2019 License: MIT Imports: 11 Imported by: 1

README

RAL Textboard API for Golang

This Golang library exposes the API of the RAL textboard software.

Executive Summary

RAL is a textboard software; the mothership instance is running at RalEE.org. Here, anyone can post an idea to the textboard and other users can reply and contribute to the continuity of ideas; the site is organized hierarchically by Continuities, Years, Topics and Replies like so:

+--------+
| Replies \ e.g. 1, 2...
|..............
| Topics       \ e.g. 1, 2...
|....................
| Years              \ e.g. 2019, 2018...
|...........................
| Continuities              \ e.g. [Anime], [Music]...
+----------------------------+

So Continuities are composed of Years composed of Topics which are finally composed of Replies. This is analagous to a threaded e-mail inbox or even other textboards, simply with more layers... Continuities can be thought of as boards and Topics are the threads, with Replies naturally being posts in the threads.

The RAL software exposes a web API at /api (documentation) which this library uses to fetch posts and information from any site running RAL.

Installation

If you are using any derivative software which leverages this package, a go get will pull in my package automaticaly so there is no need to install this repository explicity. Furthermore this package has no binaries (if you thought it did you might be looking for my RalEExplorer or RAL (CLI Tool) packages) so you shouldn't go get this if you are expecting an executable.

However if you are building a totally new application then feel free to pull this one using:

go get github.com/wesleycoakley/ral-api

You don't need to worry about dependencies but if you are curious:

Contributing

Contributions / PRs are welcome; e-mail me at w@wesleycoakley.com if you have a suggestion or want to work together.

License

X11 License (available in the source tree as /LICENSE)

Documentation

Overview

Provides access to the posts and other information on the RAL textboard (https://ralee.org) using its API

Index

Constants

View Source
const USER_AGENT = "GoRAL"

Defines the user agent projected by the package

Variables

This section is empty.

Functions

func EscapeShSingle

func EscapeShSingle(s string) string

Escape single quotes in a string for shell

func ShQuote

func ShQuote(s string) string

Single quote a phrase for shell

func SurroundQuoteSingle

func SurroundQuoteSingle(s string) string

Surround string with single quotes

Types

type APIAction

type APIAction string

Functions exposed by the RAL API

const (
	View APIAction = "view"
)

type APIRequest

type APIRequest struct {
	URL url.URL
	// Action APIAction
	// Endpoint string
	UserAgent string
	// Parameters map[string]string
	Client http.Client
}

Defines a single request to the RAL API

func (APIRequest) Go

func (areq APIRequest) Go() (body []byte, err error)

Execute a single request to the RAL API

func (APIRequest) URI

func (a APIRequest) URI() string

Serialize the API request into a URI

type Continuity

type Continuity struct {
	Name        string
	PostCount   int
	Description string
}

type ContinuityList

type ContinuityList []Continuity

Continuities represent discussion topics like "Anime" or "Music"

func (ContinuityList) Print

func (cl ContinuityList) Print(f Format)

Serialize ContinuityList to console

type Format

type Format int

Describes an output format

const (
	FormatSimple Format = iota
	FormatCSV
	FormatJson
)

type Reply

type Reply struct {
	Id         int
	Topic      int
	Created    string
	Continuity string
	Content    string
	Year       int
}

type ReplyList

type ReplyList []Reply

Replies are posted to Topics; a reply looks like Anime/2019/1/3, which specifies the third reply to the first topic on [Anime] in 2019.

func (ReplyList) Print

func (rl ReplyList) Print(f Format, wrap int)

Serialize ReplyList to console

type Site

type Site struct {
	URL       url.URL
	Timeout   int
	UserAgent string
}

Defines site-wide parameters for accessing information from RAL

func New

func New() Site

Creates a new site with sane defaults

func (Site) APIRequest

func (s Site) APIRequest(action APIAction, params map[string]string) (a APIRequest)

Generates a single request for information on the given site, representing exactly one transaction / HTTP request

func (Site) Continuities

func (s Site) Continuities() (ret ContinuityList, err error)

Generate and execute an API request which returns the full list of Continuities on the given Site

func (Site) Replies

func (s Site) Replies(continuity string, year int, topic int) (ret ReplyList, err error)

Generate and execute an API request which returns all Replies to a given topic

func (Site) Topics

func (s Site) Topics(continuity string, year int) (ret TopicList, err error)

Generate and execute an API request which returns the full list of Topics on the given Site and given Continuity for the given Year

func (Site) Years

func (s Site) Years(continuity string) (ret YearList, err error)

Generate and execute an API request which returns the full list of Years on the given Site and given Continuity

type Topic

type Topic struct {
	Id         int
	Topic      int
	Created    string
	Continuity string
	Content    string
	Replies    int
	Year       int
}

type TopicList

type TopicList []Topic

Topics are posted to a certain Continuity/Year Example: Anime/2019/1 is the first Topic posted on the Anime continuity this year

func (TopicList) Print

func (tl TopicList) Print(f Format, wrap int)

Serialize TopicList to console

type Year

type Year struct {
	Year       int
	Continuity string
	Count      int
}

type YearList

type YearList []Year

Years are subsets of Continuities; they represent all Topics posted in that Continuity in a given year

func (YearList) Print

func (yl YearList) Print(f Format)

Serialize YearList to console

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL