shortcut

package
v0.0.0-...-5f9f732 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package Shortcut contains types and methods for manipulating shortcuts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeURL

func NormalizeURL(s string) string

NormalizeURL takes the urls that we get and puts some sane defaults to it.

Types

type Index

type Index struct {
	bleve.Index
}

An Index is a searchable collection of shortcuts.

func NewIndex

func NewIndex(indexFilePath string) Index

NewIndex creates a new Shotcut.Index, initialized from a file.

func (Index) AddShortcut

func (i Index) AddShortcut(s Shortcut) (normalizedURL string)

AddShortcut adds a given shortcut to this index, and returns the normalized URL string.

func (Index) FindShortcut

func (i Index) FindShortcut(query string) (results []Shortcut, sole bool, err error)

FindShortcut attempts to find a given string by first searching for an absolute match. If that doesn't exist, it will perform a partial match on all the text. Results is a list of 0, 1 or more shortcuts that were found. If sole is true, that result was an absolute match.

type Shortcut

type Shortcut struct {
	URL,
	ShortForm,
	Description string
}

A Shortcut is a mapping from a shortform string to an alternative url.

func FromFields

func FromFields(fields map[string]interface{}) Shortcut

FromFields creates a Shortcut from a dictionary of fields.

func (Shortcut) Type

func (Shortcut) Type() string

Type ensures that Shortcut implements bleve.Classifier

Jump to

Keyboard shortcuts

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