gobookmarks

package module
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: AGPL-3.0 Imports: 19 Imported by: 0

README

gobookmarks

logo.png

The purpose of the site is to display a list of links for you to see every time you open your browser. I have tried to move as much of the work into the app as possible with minimal effort but you will need to use github occasionally.

img_4.png

This project is a converstion of a project: goa4web-bookmarks to remove the SQL and replace it with Github. Which itself is extract from goa4web, which is a Go port of a C++ site I made in 2003. Ported using ChatGPT: a4web. It's all been minimally modified and as close to the original as I could get but with the changes I required. I made modifications to this because StartHere my SPA version using modern tech failed because of Github Oauth2 restrictions on SPA sites. You can read more about this here: https://arranubels.substack.com/p/quicklinks

How to use

  1. Create a (private or public doesn't matter) repo in github under your user name called: "MyBookmarks"
  2. Create 1 file in it called bookmarks.txt Put the following content (or anything you want really):
Category: Search
http://www.google.com.au Google
Category: Wikies
http://en.wikipedia.org/wiki/Main_Page Wikipedia
http://mathworld.wolfram.com/ Math World
http://gentoo-wiki.com/Main_Page Gentoo-wiki

Ie: img_3.png 3. Goto the URL this app is deployed at, your private instance or: https://bookmarks.arran.net.au 4. Enjoy

File format

It's a basic file format. Every command must be on it's own line empty lines are ignored.

Code Meaning
Category: <category> Will create a category title.
<Link> Will create a link to <Link> with the display name <Link>
<Link> <Name> Will create a link to <Link> with the display name <Name>
Column Will create a column

img.png

img_1.png

img_2.png

How to setup for yourself

You can run this yourself. There is a docker version available under my github packages. There are also precompiled versions under the releases section of this git repo: https://github.com/arran4/StartHere/releases

You will require 3 environment arguments:

Arg Value
OAUTH2_CLIENT_ID The Client ID generated from setting up Oauth2 on github: https://github.com/settings/developers
OAUTH2_SECRET Secret ID generated from setting up Oauth2 on github: https://github.com/settings/developers
EXTERNAL_URL The fully qualified URL that it is to accept connections from. Ie http://localhost:8080

Oauth2 setup

Visit: https://github.com/settings/developers

Create an application, call it what ever you like. Set the Callback URL what ever you put in EXTERNAL_URL and add: /oauth2Callback to the end, ie if you entered: http://localhost:8080 it should be: http://localhost:8080/oauth2Callback

Upload logo.png for the logo.

Generate a secret key and use it for the environment variables with the Client Id.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Oauth2Config *oauth2.Config
	SessionStore sessions.Store
	SessionName  string
)
View Source
var (
	FaviconCache = struct {
		sync.RWMutex
		cache map[string]*FavIcon
	}{/* contains filtered or unexported fields */}
)
View Source
var (
	RepoName = GetBookmarksRepoName()
)

Functions

func BP added in v1.0.2

func BP(b bool) *bool

func Bookmarks

func Bookmarks(r *http.Request) (string, error)

func BookmarksEditCreateAction

func BookmarksEditCreateAction(w http.ResponseWriter, r *http.Request) error

func BookmarksEditSaveAction

func BookmarksEditSaveAction(w http.ResponseWriter, r *http.Request) error

func CoreAdderMiddleware

func CoreAdderMiddleware(next http.Handler) http.Handler

func CreateBookmarks

func CreateBookmarks(ctx context.Context, githubUser string, userToken *oauth2.Token, branch, text string) error

func CreateRef added in v1.0.2

func CreateRef(ctx context.Context, githubUser string, client *github.Client, sourceRef string, branchRef string) error

func CreateRepo added in v1.0.2

func CreateRepo(ctx context.Context, githubUser string, client *github.Client) (*github.Repository, error)

func FaviconProxyHandler added in v1.0.4

func FaviconProxyHandler(w http.ResponseWriter, r *http.Request)

func GetBookmarks

func GetBookmarks(ctx context.Context, githubUser string, ref string, userToken *oauth2.Token) (string, error)

func GetBookmarksRepoName added in v1.0.2

func GetBookmarksRepoName() string

func GetBranches

func GetBranches(ctx context.Context, githubUser string, userToken *oauth2.Token) ([]*github.Branch, error)

func GetCommits

func GetCommits(ctx context.Context, githubUser string, userToken *oauth2.Token) ([]*github.RepositoryCommit, error)

func GetCompiledTemplates

func GetCompiledTemplates(funcs template.FuncMap) *template.Template

func GetDefaultBranch added in v1.0.2

func GetDefaultBranch(ctx context.Context, githubUser string, client *github.Client, branch string) (string, bool, error)

func GetFavicon

func GetFavicon() []byte

func GetMainCSSData

func GetMainCSSData() []byte

func GetTags

func GetTags(ctx context.Context, githubUser string, userToken *oauth2.Token) ([]*github.RepositoryTag, error)

func NewFuncs

func NewFuncs(r *http.Request) template.FuncMap

func Oauth2CallbackPage

func Oauth2CallbackPage(w http.ResponseWriter, r *http.Request) error

func SP

func SP(s string) *string

func SetVersion added in v1.0.6

func SetVersion(pVersion, pCommit, pDate string)

func TaskDoneAutoRefreshPage

func TaskDoneAutoRefreshPage(w http.ResponseWriter, r *http.Request) error

func UpdateBookmarks

func UpdateBookmarks(ctx context.Context, githubUser string, userToken *oauth2.Token, sourceRef, branch, text string) error

func UserAdderMiddleware

func UserAdderMiddleware(next http.Handler) http.Handler

func UserLogoutAction

func UserLogoutAction(w http.ResponseWriter, r *http.Request) error

Types

type BookmarkCategory

type BookmarkCategory struct {
	Name    string
	Entries []*BookmarkEntry
}

type BookmarkColumn

type BookmarkColumn struct {
	Categories []*BookmarkCategory
}

func PreprocessBookmarks

func PreprocessBookmarks(bookmarks string) []*BookmarkColumn

type BookmarkEntry

type BookmarkEntry struct {
	Url  string
	Name string
}

type Configuration

type Configuration struct {
	// contains filtered or unexported fields
}

func NewConfiguration

func NewConfiguration() *Configuration

TODO use for settings

type ContextValues

type ContextValues string

type CoreData

type CoreData struct {
	Title       string
	AutoRefresh bool
	UserRef     string
}

type FavIcon added in v1.0.9

type FavIcon struct {
	Data        []byte
	ContentType string
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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