Skip to content

Commit

Permalink
Feature: Move config to TOML file. Closes #120
Browse files Browse the repository at this point in the history
  • Loading branch information
danstis committed Dec 9, 2018
1 parent 5a45928 commit 9eba465
Show file tree
Hide file tree
Showing 15 changed files with 191 additions and 290 deletions.
100 changes: 52 additions & 48 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,97 +6,101 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

<!-- ## [Unreleased]
* Fixed|New|Changed - ([#1](https://github.com/danstis/rmstale/issues/1)) Description
* Fixed|New|Changed - ([#1](https://github.com/danstis/Plex-Sync/issues/1)) Description
-->

## [Unreleased]

- Changed - ([#120](https://github.com/danstis/Plex-Sync/issues/120)) Move configuration to TOML config file.

## [v0.7.2]

* Fixed - Version number on build.
- Fixed - Version number on build.

## [v0.7.1]

* Fixed - ([#106](https://github.com/danstis/rmstale/issues/106)) Resolve issue with cache files.
- Fixed - ([#106](https://github.com/danstis/Plex-Sync/issues/106)) Resolve issue with cache files.

## [v0.7.0]

* New - ([#110](https://github.com/danstis/rmstale/issues/110)) Add exe details and Icon for windows executable.
- New - ([#110](https://github.com/danstis/Plex-Sync/issues/110)) Add exe details and Icon for windows executable.

## [v0.6.0]

* Fixed - ([#105](https://github.com/danstis/rmstale/issues/105)) Caching of thumbnail images.
* Fixed - ([#104](https://github.com/danstis/rmstale/issues/104)) HTTPS setting not populating.
* New - Create API for web interface calls.
* Changed - ([#70](https://github.com/danstis/rmstale/issues/70)) Move settings into Database.
* Changed - Refactor logging to new logger package.
* Changed - ([#57](https://github.com/danstis/rmstale/issues/57)) Update web interface settings page to enable population of all settings.
* Changed - Index images retreved from API.
* Changed - ([#95](https://github.com/danstis/rmstale/issues/95)) Update error messages to make more sense.
* Changed - ([#109](https://github.com/danstis/rmstale/issues/109)) Remove config file from Readme file.
- Fixed - ([#105](https://github.com/danstis/Plex-Sync/issues/105)) Caching of thumbnail images.
- Fixed - ([#104](https://github.com/danstis/Plex-Sync/issues/104)) HTTPS setting not populating.
- New - Create API for web interface calls.
- Changed - ([#70](https://github.com/danstis/Plex-Sync/issues/70)) Move settings into Database.
- Changed - Refactor logging to new logger package.
- Changed - ([#57](https://github.com/danstis/Plex-Sync/issues/57)) Update web interface settings page to enable population of all settings.
- Changed - Index images retreved from API.
- Changed - ([#95](https://github.com/danstis/Plex-Sync/issues/95)) Update error messages to make more sense.
- Changed - ([#109](https://github.com/danstis/Plex-Sync/issues/109)) Remove config file from Readme file.

## [v0.5.2]

* Fixed - ([#89](https://github.com/danstis/rmstale/issues/89)) Token file not generated if cache folder does not exist.
* Changed - Changelog formatting.
- Fixed - ([#89](https://github.com/danstis/Plex-Sync/issues/89)) Token file not generated if cache folder does not exist.
- Changed - Changelog formatting.

## [v0.5.1]

* Fixed - ([#87](https://github.com/danstis/Plex-Sync/issues/87)) Update to return message if watched item has already been scrobbled on remote server.
* Changed - Move config into own package.
- Fixed - ([#87](https://github.com/danstis/Plex-Sync/issues/87)) Update to return message if watched item has already been scrobbled on remote server.
- Changed - Move config into own package.

## [v0.5.0]

* Changed - ([#63](https://github.com/danstis/Plex-Sync/issues/63)) Add version number to console on startup.
* Changed - ([#58](https://github.com/danstis/Plex-Sync/issues/58)) Changed text list of selected shows to thumbnail images from destination server.
* Changed - ([#61](https://github.com/danstis/Plex-Sync/issues/61)) Modify build to control versioning.
* Changed - ([#74](https://github.com/danstis/Plex-Sync/issues/74)) Moved tvshows.txt file to config folder.
* Changed - ([#76](https://github.com/danstis/Plex-Sync/issues/76)) Update display of shows on homepage to be responsive.
* Fixed - Cleanup code errors.
- Changed - ([#63](https://github.com/danstis/Plex-Sync/issues/63)) Add version number to console on startup.
- Changed - ([#58](https://github.com/danstis/Plex-Sync/issues/58)) Changed text list of selected shows to thumbnail images from destination server.
- Changed - ([#61](https://github.com/danstis/Plex-Sync/issues/61)) Modify build to control versioning.
- Changed - ([#74](https://github.com/danstis/Plex-Sync/issues/74)) Moved tvshows.txt file to config folder.
- Changed - ([#76](https://github.com/danstis/Plex-Sync/issues/76)) Update display of shows on homepage to be responsive.
- Fixed - Cleanup code errors.

## [v0.4.1]

* Fixed - ([#59](https://github.com/danstis/Plex-Sync/issues/59)) Handle returned errors for the GetToken method.
- Fixed - ([#59](https://github.com/danstis/Plex-Sync/issues/59)) Handle returned errors for the GetToken method.

## [v0.4.0]

* Changed - ([#50](https://github.com/danstis/Plex-Sync/issues/50)) Refresh shows when reloading the WebUI homepage.
* Changed - ([#55](https://github.com/danstis/Plex-Sync/issues/55)) Ignore pre-release tags on header of web interface.
* Changed - ([#54](https://github.com/danstis/Plex-Sync/issues/54)) Move full version number into the settings page.
- Changed - ([#50](https://github.com/danstis/Plex-Sync/issues/50)) Refresh shows when reloading the WebUI homepage.
- Changed - ([#55](https://github.com/danstis/Plex-Sync/issues/55)) Ignore pre-release tags on header of web interface.
- Changed - ([#54](https://github.com/danstis/Plex-Sync/issues/54)) Move full version number into the settings page.

## [v0.3.4]

* New - Script to bump version using GitVersion.
* New - Go generate script to update version.
* Changed - Moved builds from TravisCI to Appveyor.
- New - Script to bump version using GitVersion.
- New - Go generate script to update version.
- Changed - Moved builds from TravisCI to Appveyor.

## [v0.3.1]

* Fixed - Sort selected shows on Home page.
- Fixed - Sort selected shows on Home page.

## [v0.3.0]

* New - Show selected shows on home page.
* New - Version to WebUI pages.
- New - Show selected shows on home page.
- New - Version to WebUI pages.

## [v0.2.0]

* New - Ability to remove a cached token from the web interface.
* New - Logging to file.
* New - Logging to web interface.
* New - Web interface for management of the application.
* Changed - After token generation direct user to the settings page.
* Changed - Moved generation of token file into web interface.
* Changed - Update logging to go to file and StdOut.
* Changed - Update release to remove all .go files from subdirectories.
- New - Ability to remove a cached token from the web interface.
- New - Logging to file.
- New - Logging to web interface.
- New - Web interface for management of the application.
- Changed - After token generation direct user to the settings page.
- Changed - Moved generation of token file into web interface.
- Changed - Update logging to go to file and StdOut.
- Changed - Update release to remove all .go files from subdirectories.

## [v0.1.0]

* New - Add Readme.
* New - Usage instructions to the Readme file.
* New - Cache token in local token file.
* New - Enable syncing of Show watched status from a local server to a remote server.
* New - Support for MyPlex Account.
* Fixed - App would attempt to sync even if a token was not obtained.
* Fixed - Spaces in TV Show names cause errors.
- New - Add Readme.
- New - Usage instructions to the Readme file.
- New - Cache token in local token file.
- New - Enable syncing of Show watched status from a local server to a remote server.
- New - Support for MyPlex Account.
- Fixed - App would attempt to sync even if a token was not obtained.
- Fixed - Spaces in TV Show names cause errors.

[unreleased]: https://github.com/danstis/Plex-Sync/compare/v0.7.2...HEAD
[v0.7.2]: https://github.com/danstis/Plex-Sync/compare/v0.7.1...v0.7.2
Expand Down
8 changes: 4 additions & 4 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
assembly-versioning-scheme: None
mode: Mainline
major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
patch-version-bump-message: '\+semver:\s?(fix|patch)'
no-bump-message: '\+semver:\s?(none|skip)'
major-version-bump-message: '(\+semver:\s?(breaking|major)|Major:\s?)'
minor-version-bump-message: '(\+semver:\s?(feature|minor)|Feature:\s?|Minor:\s?)'
patch-version-bump-message: '(\+semver:\s?(fix|patch)|Patch:\s?)'
no-bump-message: '(\+semver:\s?(none|skip)|NOCI:\s?)'
branches: {}
ignore:
sha: []
Expand Down
86 changes: 0 additions & 86 deletions Gopkg.lock

This file was deleted.

43 changes: 0 additions & 43 deletions Gopkg.toml

This file was deleted.

71 changes: 71 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package config

import (
"bufio"
"os"
"path"

"github.com/BurntSushi/toml"
"github.com/danstis/Plex-Sync/plex"
)

//ConfigFile defines the path to the configuration file
var (
configFile = path.Join("config", "config.toml")
)

// Settings defines the program configureation
type Settings struct {
WebServerPort int
CacheLifetime int
SyncInterval int
Logging logging `toml:"logging"`
LocalServer plex.Host `toml:"localserver"`
RemoteServer plex.Host `toml:"remoteserver"`
}

type logging struct {
Logfile string
Webserverlogfile string
MaxLogSize int
MaxLogCount int
MaxLogAge int
}

// GetConfig returns the application configuration from the config TOML file.
func GetConfig() (Settings, error) {
var s Settings
_, err := toml.DecodeFile(configFile, &s)
if os.IsNotExist(err) {
s := Settings{
WebServerPort: 8080,
Logging: logging{
MaxLogSize: 5,
MaxLogCount: 1,
MaxLogAge: 30,
},
LocalServer: plex.Host{},
RemoteServer: plex.Host{},
CacheLifetime: 30,
SyncInterval: 3600,
}
err := UpdateConfig(s)
return s, err
}
if err != nil {
return Settings{}, err
}
return s, nil
}

// UpdateConfig sets the configuration settings in the config TOML file.
func UpdateConfig(s Settings) error {
f, err := os.OpenFile(configFile, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666)
if err != nil {
return err
}
defer f.Close()
w := bufio.NewWriter(f)
defer w.Flush()
return toml.NewEncoder(w).Encode(s)
}
8 changes: 0 additions & 8 deletions database/database.go

This file was deleted.

15 changes: 15 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module github.com/danstis/Plex-Sync

require (
github.com/BurntSushi/toml v0.3.1
github.com/gopherjs/gopherjs v0.0.0-20180227192048-df18d38287ab // indirect
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f // indirect
github.com/gorilla/handlers v1.3.0
github.com/gorilla/mux v1.6.1
github.com/jtolds/gls v4.2.1+incompatible // indirect
github.com/smartystreets/assertions v0.0.0-20170925172151-0b37b35ec743 // indirect
github.com/smartystreets/goconvey v0.0.0-20170602164621-9e8dc3f972df
github.com/smartystreets/gunit v0.0.0-20180314194857-6f0d6275bdcd // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0-20170531160350-a96e63847dc3
gopkg.in/yaml.v2 v2.2.2 // indirect
)
Loading

0 comments on commit 9eba465

Please sign in to comment.