Documentation ¶
Overview ¶
* Virtualpaper is a service to manage users paper documents in virtual format. * Copyright (C) 2022 Tero Vierimaa * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.
Index ¶
- Variables
- func DeleteDocument(docId string) error
- func GetFileHash(file *os.File) (string, error)
- func GetHash(fileName string) (string, error)
- func GetImagickVersion() string
- func GetPandocInstalled() bool
- func GetPdfToTextIsInstalled() bool
- func GetTesseractVersion() string
- func MimeTypeFromName(fileName string) string
- func MimeTypeIsSupported(mimetype, filename string) bool
- func RequiredProcessingSteps(startingStep models.ProcessStep) []models.ProcessStep
- func SupportedFileTypes() (mimetypes []string, filetypes []string)
- type DocumentRule
- type Manager
- type QueueStatus
- type RuleTestAction
- type RuleTestConditionResult
- type RuleTestResult
- type Task
- type TaskReport
Constants ¶
This section is empty.
Variables ¶
var SupportedLanguages = map[string]string{
"af": "Afrikaans",
"sq": "Albanian",
"ar": "Arabic",
"hy": "Armenian",
"az": "Azerbaijani",
"eu": "Basque",
"be": "Belarusian",
"bn": "Bengali",
"nb": "Bokmal",
"bs": "Bosnian",
"bg": "Bulgarian",
"ca": "Catalan",
"zh": "Chinese",
"hr": "Croatian",
"cs": "Czech",
"da": "Danish",
"nl": "Dutch",
"en": "English",
"eo": "Esperanto",
"et": "Estonian",
"fi": "Finnish",
"fr": "French",
"lg": "Ganda",
"ka": "Georgian",
"de": "German",
"el": "Greek",
"gu": "Gujarati",
"he": "Hebrew",
"hi": "Hindi",
"hu": "Hungarian",
"is": "Icelandic",
"id": "Indonesian",
"ga": "Irish",
"it": "Italian",
"ja": "Japanese",
"kk": "Kazakh",
"ko": "Korean",
"la": "Latin",
"lv": "Latvian",
"lt": "Lithuanian",
"mk": "Macedonian",
"ms": "Malay",
"mi": "Maori",
"mr": "Marathi",
"mn": "Mongolian",
"nn": "Nynorsk",
"fa": "Persian",
"pl": "Polish",
"pt": "Portuguese",
"pa": "Punjabi",
"rm": "Romanian",
"ru": "Russian",
"sr": "Serbian",
"sn": "Shona",
"sk": "Slovak",
"sl": "Slovene",
"so": "Somali",
"st": "Sotho",
"es": "Spanish",
"sw": "Swahili",
"sv": "Swedish",
"tl": "Tagalog",
"ta": "Tamil",
"te": "Telugu",
"th": "Thai",
"ts": "Tsonga",
"tn": "Tswana",
"tr": "Turkish",
"uk": "Ukrainian",
"ur": "Urdu",
"vi": "Vietnamese",
"cy": "Welsh",
"xh": "Xhosa",
"yo": "Yoruba",
"zu": "Zulu",
}
Functions ¶
func DeleteDocument ¶
DeleteDocument deletes original document and its preview file.
func GetFileHash ¶
GetFileHash returns unique hash for file. It uses md5 for hashing.
func GetImagickVersion ¶
func GetImagickVersion() string
func GetPandocInstalled ¶
func GetPandocInstalled() bool
func GetPdfToTextIsInstalled ¶
func GetPdfToTextIsInstalled() bool
func GetTesseractVersion ¶
func GetTesseractVersion() string
func MimeTypeFromName ¶
func MimeTypeIsSupported ¶
MimeTypeIsSupported returns true if mime type or file ending is supported. Either one, or both, can be filled. If both are "", return false. If both are filled, return true if expected file ending matches argument. If either one is filled, return true if that is supported.
func RequiredProcessingSteps ¶
func RequiredProcessingSteps(startingStep models.ProcessStep) []models.ProcessStep
RequiredProcessingSteps returns list of steps that are required to be execute after a given step.
func SupportedFileTypes ¶
SupportedFileTypes returns a list of supported file endings.
Types ¶
type DocumentRule ¶
type DocumentRule struct { Rule *models.Rule Document *models.Document // contains filtered or unexported fields }
func NewDocumentRule ¶
func NewDocumentRule(document *models.Document, rule *models.Rule) DocumentRule
func (*DocumentRule) Match ¶
func (d *DocumentRule) Match() (bool, error)
func (*DocumentRule) MatchTest ¶
func (d *DocumentRule) MatchTest() *RuleTestResult
run rule in test mode, logging all results
func (*DocumentRule) RunActions ¶
func (d *DocumentRule) RunActions() error
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages multiple goroutines processing files.
func NewManager ¶
func (*Manager) AddDocumentForProcessing ¶
AddDocumentForProcessing marks document as available for processing.
func (*Manager) ProcessingStatus ¶
func (m *Manager) ProcessingStatus() []QueueStatus
func (*Manager) PullDocumentsToProcess ¶
func (m *Manager) PullDocumentsToProcess()
type QueueStatus ¶
type QueueStatus struct { TaskId int `json:"task_id"` QueueCapacity int `json:"queue_capacity"` Queued int `json:"queued"` ProcessingOngoing bool `json:"processing_ongoing"` ProcessingDocumentId string `json:"processing_document_id"` Running bool `json:"task_running"` DurationMs int `json:"duration_ms"` }
type RuleTestAction ¶
type RuleTestConditionResult ¶
type RuleTestResult ¶
type RuleTestResult struct { Conditions []RuleTestConditionResult `json:"conditions"` Actions []RuleTestAction `json:"actions"` RuleId int `json:"rule_id"` Match bool `json:"matched"` TookMs int `json:"took_ms"` Log string `json:"log"` Error string `json:"error"` StartedAt int `json:"started_at"` StoppedAt int `json:"stopped_at"` ConditionOutput [][]string `json:"condition_output"` ActionOutput [][]string `json:"action_output"` }
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task is a background worker. Define runFunc and run it with Start(). Task calls runFunc in a loop until Stop() is called. Task can communicate via report channel, which is up to user to set correctly.
type TaskReport ¶
type TaskReport struct {
// contains filtered or unexported fields
}