a4webbm

package module
v1.0.2 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: 16 Imported by: 0

README

goa4web-bookmarks

Goa4webb-ookmarks is a Spin out from goa4web, which is a chatGPT aided (with slight enhancement) conversion of a4web (a c++ website I made while in university in 2005-6) into go.

This project isn't designed to be used directly. Feel free to fork, copy, or submit PRs if you wish to use it for yourself.

There will be a blog post on this and the related tech, log an issue if I fail to update this with it.

What it does

The purpose of this component of the website was to allow users to create a list of links they would be able to use as soon as they opened their browser. The idea was that users would set it as their "Home Page". This was of course written instead of using iGoogle, or before Google Chrome started pushing "search as the home page."

It allowed you to provide a list of categorized links as such:

img.png

It supported columns and categories in a simplistic way:

img_3.png

You require a category for any links. So in the language (new errors could exist b/c chatgpt did the conversion:)

Category: <Category Name>

Then each link provided in:

<link> <Text>

Format. Where the dividor is the first (space) character.

To create a new column use:

Column

Such as a complete config could look like:

Category: Example 1
http://www.google.com.au Google
Column
Category: Example 2
http://www.google.com.au Google
http://www.google.com.au Google

A video of use:

Video

Tech

It uses Google Oauth2 for authentication, and either SQLite or Mysql for the backend.

It has its own configuration file format in it, which isn't being used. Future expansion could be to use that so the properties don't have to be passed around using environment variables.

As it uses CGo because of sqlite there is a bit of effort required for new compile targets, they can be provided upon request.

Installation

Currently, it's built and packaged using goreleaser, and a docker container. The docker container version is the only version which is configured to start, if you install it using the .deb, or .rpm you will have to provide the environment variables yourself.

The docker container is available in ghcr.io:

You can get the binaries directly from the release tag:

Motivation:

See: https://open.substack.com/pub/arranubels/p/quicklinks?r=1ner06&utm_campaign=post&utm_medium=web

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Oauth2Config *oauth2.Config
	SessionStore sessions.Store
	SessionName  string
)
View Source
var (
	DbConnectionString   = os.Getenv("DB_CONNECTION_STRING")
	DbConnectionProvider = os.Getenv("DB_CONNECTION_PROVIDER")
)

Functions

func BookmarksEditCreateAction

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

func BookmarksEditSaveAction

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

func CoreAdderMiddleware

func CoreAdderMiddleware(next http.Handler) http.Handler

func DBAdderMiddleware

func DBAdderMiddleware(next http.Handler) http.Handler

func GetCompiledTemplates

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

func GetFavicon added in v1.0.1

func GetFavicon() []byte

func GetMainCSSData

func GetMainCSSData() []byte

func NewFuncs

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

func Oauth2CallbackPage

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

func TaskDoneAutoRefreshPage

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

func UserAdderMiddleware

func UserAdderMiddleware(next http.Handler) http.Handler

func UserLogoutAction

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

Types

type Bookmark

type Bookmark struct {
	Idbookmarks   int32
	Userreference string
	List          sql.NullString
}

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 CreateBookmarksParams

type CreateBookmarksParams struct {
	Userreference string
	List          sql.NullString
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type GetBookmarksForUserRow

type GetBookmarksForUserRow struct {
	Idbookmarks int32
	List        sql.NullString
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateBookmarks

func (q *Queries) CreateBookmarks(ctx context.Context, arg CreateBookmarksParams) error

This query adds a new entry to the "bookmarks" table and returns the last inserted ID as "returnthis".

func (*Queries) GetBookmarksForUser

func (q *Queries) GetBookmarksForUser(ctx context.Context, userreference string) (*GetBookmarksForUserRow, error)

This query retrieves the "list" from the "bookmarks" table for a specific user based on their "users_idusers".

func (*Queries) UpdateBookmarks

func (q *Queries) UpdateBookmarks(ctx context.Context, arg UpdateBookmarksParams) error

This query updates the "list" column in the "bookmarks" table for a specific user based on their "users_idusers".

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type UpdateBookmarksParams

type UpdateBookmarksParams struct {
	List          sql.NullString
	Userreference string
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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