From 7f7c34f9e05d08ebd4ccc14406d6a3a0ab9547a4 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Thu, 20 Feb 2025 18:13:44 +0100 Subject: [PATCH] Begin transferring scope document into documented functions --- .gitignore | 1 + go.mod | 3 ++ src/configLoader.go | 83 +++++++++++++++++++++++++++++++++++++++++++++ src/main.go | 34 +++++++++++++++++++ src/setup.go | 15 ++++++++ 5 files changed, 136 insertions(+) create mode 100644 .gitignore create mode 100644 go.mod create mode 100644 src/configLoader.go create mode 100644 src/main.go create mode 100644 src/setup.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b9014e6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +go.work diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..36564e6 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module MDWebDavUploader + +go 1.24.0 diff --git a/src/configLoader.go b/src/configLoader.go new file mode 100644 index 0000000..e70358c --- /dev/null +++ b/src/configLoader.go @@ -0,0 +1,83 @@ +package main + +type MDWebDavUploaderConfig struct { + InstanceLink string `json:"instance"` + Mail string `json:"mail"` + WebDavAuthToken string `json:"token"` + InstitutionId int `json:"institution_id"` + Parser string `json:"parser"` + MetadataFolder string `json:"metadata_folder"` + MediaFolder string `json:"media_folder"` + PublishOnImport bool `json:"visible"` +} + +type ParserListItem struct { + name string + +} + +// Returns a uniform filepath for the configuration of this tool. +// To be compatible across operating systems, this will be a JSON +// file in the same directory as the current programm. +func getConfigFilepath() string { + +} + +// Loads configuration from the configuration file (located using +// getConfigFilepath()). +func loadFromFile() MDWebDavUploaderConfig { + +} + +// Returns a uniform filepath for the cache for the list of +// available parsers. +func getParserCacheFilepath() string { + +} + +// Stores a parser list to a cache file (located via +// getParserCacheFilepath()). +func storeParserList(parserList []ParserListItem) { + +} + +// Returns a list of the available parsers. +func listParsers() []ParserListItem { + +} + + +// Checks if inputParser is in the list of available parsers. +// Returns the parser name or an error. +func validateParser(inputParser string) (string, error) { + +} + +// Checks if a directory is the entered directory can be used +// as an source directory for export data. As such, it does need +// to exist. +// Returns the directory name or an error. +func validateDir(dir string) (string, error) { + +} + +// Validates an input mail address. +// Returns the valid mail address or an eQueries therror. +func validateMail(mail string) (string, error) { + +} + +// Validates an entered instance URL. +// Returns the entered URL in a unified form (minus optional +// trailing slashes and the /musdb suffix) or an error. +func validateInstanceLink(instanceUrl string) (string, error) { + +} + +// Validates an institution ID. +// A valid institution ID returns a HTTP 200 response code when queried +// + "/institution/" + institution_id. +// Returns either the entered instance URL or an error. +func validateInstitutionId(institutionId int, instanceUrl string) (int, error) { + +} diff --git a/src/main.go b/src/main.go new file mode 100644 index 0000000..bcc32a6 --- /dev/null +++ b/src/main.go @@ -0,0 +1,34 @@ +package main + +import "fmt" + +// Attempts to connect to WebDAV server, verifying that the authentication data +// works and that the server is one for uploads with museum-digital. +// A museum-digital WebDAV directory can be identified by the availability of the +// directories IMPORT_IMG and IMPORT_XML. +func verifyConnection(config MDWebDavUploaderConfig) bool { + +} + +// Generates the contents of the file import_config.txt necessary +// to let museum-digital know about the required import configuration. +func generateImportConfigFile() string { + +} + + +// Uploads metadata files to the configured instance of +// museum-digital / musdb. +func uploadMetadataFiles() { + +} + +// Uploads media files to the configured instance of +// museum-digital / musdb. +func uploadMediaFiles() { + +} + +func main() { + fmt.Println("hi") +} diff --git a/src/setup.go b/src/setup.go new file mode 100644 index 0000000..0b6c84e --- /dev/null +++ b/src/setup.go @@ -0,0 +1,15 @@ +package main + +// Fetches user information from the relevant musdb API: +// https://demo.museum-digital.org/musdb/swagger/#/user/userReadOwnData +func getUserInformation(instanceUrl string, username string, password string) { + +} + +// Uses musdb's API to generate an access token: +// https://demo.museum-digital.org/musdb/swagger/#/user/userGenerateWebdavAccessToken +// Returns either the token or an error. +func getWebDavAccessToken(instanceUrl string) (string, error) { + +} +