papernet

package module
v0.0.0-...-8a4eff6 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2017 License: MIT Imports: 16 Imported by: 0

README

Build Status

Papernet

Papernet is a very simple tool to keep track of the papers you read.

Setup

Go

Usual go installation (1.7.5)

I use the gvm, but you can install golang any way you prefer

bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
gvm install go1.7.5 --binary

then add the following to your bashrc (or the equivalent for your terminal)

source $HOME/.gvm/scripts/gvm
gvm use go1.7.5
export GOPATH=/path/to/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Dependencies

The dependencies are handled with godep:

go get -u github.com/kardianos/govendor/...
govendor sync

Auth

Key file

You need to generate your shared secret for the authentication. You can use this site to do so: https://mkjwk.org/, with the following settings: image You decide what you want to use as key ID

Google oauth

If you want to use Google to handle the auth, you need credentials for the project. Follow the instructions here: https://developers.google.com/identity/protocols/OAuth2, to create those credentials.

If you do not want to use google for oauth, you can simply set enabled=false in the configuration file and use the simple email/password login system. It does not include email confirmation or password reset, but it will avoid you having to register Papernet on Google.

Web server

To start the web server, you have to create the data folder, and setup the index:

mkdir data
go run cmd/cli/*.go index create --index=data/papernet.index --mapping=bleve/mapping.json

Now that everything is ready, you can start the server:

go run cmd/web/main.go

Front-end

This repository contains the backend of the Papernet project, for the front-end check out https://github.com/bobinette/papernet-front

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean(str string, cleanFuncs ...CleanFunc) string

func OneLine

func OneLine(str string) string

Types

type ArxivResult

type ArxivResult struct {
	Papers     []*Paper
	Pagination Pagination
}

type ArxivSearch

type ArxivSearch struct {
	Q          string
	IDs        []string
	Start      int
	MaxResults int
}

type ArxivSpider

type ArxivSpider struct {
	Client *http.Client
}

func (*ArxivSpider) Import

func (s *ArxivSpider) Import(url string) (*Paper, error)

func (*ArxivSpider) Search

func (s *ArxivSpider) Search(search ArxivSearch) (ArxivResult, error)

type CleanFunc

type CleanFunc func(string) string

func CleaningPipe

func CleaningPipe(cleanFuncs ...CleanFunc) CleanFunc

func RemovePrefix

func RemovePrefix(prefix string) CleanFunc

type EndPoint

type EndPoint struct {
	// Name uniquely identifies the end point
	Name string

	// URL defines the url of the end point. It can contain parameters,
	// the form depending on the framework used for implementation
	URL string

	// Method of the endpoint. Typically GET, PUT, POST, DELETE, etc.
	Method string

	// Renderer defines the renderer used to marshal the first returned
	// value of the handler. Typically JSON, Text, etc.
	Renderer string

	// Authenticated should be set to true so the server activates
	// authentication for that route, i.e. loads the user that will
	// be available in the context.
	Authenticated bool

	// HandlerFunc is the function used to handle incoming requests on
	// that route.
	HandlerFunc HandlerFunc
}

EndPoint defines

type HandlerFunc

type HandlerFunc func(*Request) (interface{}, error)

HandlerFunc defines the signature of a web endpoint

type Importer

type Importer interface {
	Import(string) (*Paper, error)
}

type ImporterRegistry

type ImporterRegistry map[string]Importer

func (ImporterRegistry) Import

func (reg ImporterRegistry) Import(addr string) (*Paper, error)

func (ImporterRegistry) Register

func (reg ImporterRegistry) Register(host string, imp Importer)

type MediumImporter

type MediumImporter struct {
}

func (MediumImporter) Import

func (MediumImporter) Import(addr string) (*Paper, error)

type Pagination

type Pagination struct {
	Total  uint64 `json:"total"`
	Limit  uint64 `json:"limit"`
	Offset uint64 `json:"offset"`
}

type Paper

type Paper struct {
	ID      int      `json:"id"`
	Title   string   `json:"title"`
	Summary string   `json:"summary"`
	Authors []string `json:"authors"`

	Tags       []string `json:"tags"`
	References []string `json:"references"`

	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`

	// External ids
	ArxivID string `json:"arxivId"`
}

func ImportChromeBookmarks

func ImportChromeBookmarks(r io.Reader) ([]Paper, error)

type PaperIndex

type PaperIndex interface {
	Index(*Paper) error
	Search(PaperSearch) (PaperSearchResults, error)
	Delete(int) error
}

type PaperSearch

type PaperSearch struct {
	IDs []int  `json:"ids"`
	Q   string `json:"q"`

	Authors  []string `json:"authors"`
	Tags     []string `json:"tags"`
	ArxivIDs []string `json:"arxiv_ids"`

	Limit   uint64 `json:"limit"`
	Offset  uint64 `json:"offset"`
	OrderBy string `json:"orderBy"`
}

type PaperSearchFacets

type PaperSearchFacets struct {
	Tags PaperSearchTagsFacet `json:"tags,omitempty"`
}

type PaperSearchResults

type PaperSearchResults struct {
	IDs        []int
	Facets     PaperSearchFacets
	Pagination Pagination
}

type PaperSearchTagsFacet

type PaperSearchTagsFacet []struct {
	Tag   string `json:"tag"`
	Count int    `json:"count"`
}

type PaperStore

type PaperStore interface {
	Get(...int) ([]*Paper, error)
	List() ([]*Paper, error)
	Upsert(*Paper) error
	Delete(int) error
}

type PermissionManager

type PermissionManager interface {
	UserCanSee(string, int) (bool, error)
	UserCanEdit(string, int) (bool, error)

	AllowUserToSee(string, int) error
	AllowUserToEdit(string, int) error
}

type Request

type Request struct {
	*http.Request

	Params map[string]string
}

func (*Request) Param

func (r *Request) Param(k string) string

func (*Request) Query

func (r *Request) Query(k string) string

func (*Request) WithContext

func (r *Request) WithContext(ctx context.Context) *Request

type Server

type Server interface {
	Register(EndPoint) error
	Start() error
}

type SigningKey

type SigningKey struct {
	Key string `json:"k"`
}

type TagIndex

type TagIndex interface {
	Index(string) error
	Search(string) ([]string, error)
}

type Team

type Team struct {
	ID   int    `json:"id"`
	Name string `json:"name"`

	Admins  []string `json:"admins"`
	Members []string `json:"members"`

	CanSee  []int `json:"canSee"`
	CanEdit []int `json:"canEdit"`
}

type TeamStore

type TeamStore interface {
	Get(int) (Team, error)
	Upsert(*Team) error
	Delete(int) error

	List(userID string) ([]Team, error)
}

type User

type User struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`

	Bookmarks []int `json:"bookmarks"`

	CanSee  []int `json:"canSee"`
	CanEdit []int `json:"canEdit"`
}

type UserStore

type UserStore interface {
	Get(string) (*User, error)
	Upsert(*User) error

	Search(email string) (*User, error)
}

Jump to

Keyboard shortcuts

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