Skip to content

Commit

Permalink
Show selected shows on Home page
Browse files Browse the repository at this point in the history
  • Loading branch information
danstis committed Oct 14, 2017
1 parent 34a7281 commit 1acafe8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [v0.3.0]
### Added
- Show selected shows on home page.
- Version to WebUI pages.

## [v0.2.0]
### Added
Expand All @@ -32,6 +36,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- App would attempt to sync even if a token was not obtained.
- Spaces in TV Show names cause errors.

[unreleased]: https://github.com/danstis/Plex-Sync/compare/v0.2.0...HEAD
[unreleased]: https://github.com/danstis/Plex-Sync/compare/v0.3.0...HEAD
[v0.3.0]: https://github.com/danstis/Plex-Sync/compare/v0.2.0...v0.3.0
[v0.2.0]: https://github.com/danstis/Plex-Sync/compare/v0.1.0...v0.2.0
[v0.1.0]: https://github.com/danstis/Plex-Sync/compare/v0.0.1...v0.1.0
16 changes: 8 additions & 8 deletions plex/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (

// Host defines the data to be stored for server objects
type Host struct {
Name string
Hostname string
Port int
Ssl bool
Token string
Name string
Hostname string
Port int
Ssl bool
Token string
}

var (
Expand Down Expand Up @@ -99,7 +99,7 @@ func SyncWatchedTv(source, destination Host) error {
log.Printf("Syncing watched Tv Shows from %q to %q", source.Name, destination.Name)

// Return all selected shows
ss, err := selectedShows()
ss, err := SelectedShows()
if err != nil {
return err
}
Expand Down Expand Up @@ -151,8 +151,8 @@ func SyncWatchedTv(source, destination Host) error {
return nil
}

// selectedShows returns the selected tv shows from the tvShowsFile
func selectedShows() ([]string, error) {
// SelectedShows returns the selected tv shows from the tvShowsFile
func SelectedShows() ([]string, error) {
file, err := os.Open(tvShowFile)
if err != nil {
return nil, fmt.Errorf("failed to open tvshows file %q", tvShowFile)
Expand Down
2 changes: 1 addition & 1 deletion plex/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func Test_selectedShows(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := selectedShows()
got, err := SelectedShows()
if (err != nil) != tt.wantErr {
t.Errorf("selectedShows() error = %v, wantErr %v", err, tt.wantErr)
return
Expand Down
11 changes: 8 additions & 3 deletions webui/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ import (
"github.com/danstis/Plex-Sync/plex"
)

// VersionInfo defines a struct to store the current version information.
type VersionInfo struct {
// PageData defines a struct to store the current version information.
type PageData struct {
Version string
Shows []string
}

var v = VersionInfo{Version: plex.Version}
var ss, _ = plex.SelectedShows()
var v = PageData{
Version: plex.Version,
Shows: ss,
}

// RootHandler returns the default page.
func rootHandler(w http.ResponseWriter, r *http.Request) {
Expand Down
8 changes: 6 additions & 2 deletions webui/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@
<div class="container">

<div>
<h1>Plex-Sync</h1>
<p class="lead">Some text in here...</p>
<h2>Welcome to Plex-Sync</h2>
{{if .Shows}}
<p class="lead">Selected Shows:</p>
{{range .Shows}}
<p>{{.}}</p>
{{end}} {{end}}
</div>

</div>
Expand Down

0 comments on commit 1acafe8

Please sign in to comment.