Skip to content

Commit

Permalink
Merge pull request #47 from danstis/add-version-to-webui
Browse files Browse the repository at this point in the history
Add version to webui pages
  • Loading branch information
danstis authored Oct 14, 2017
2 parents eae431a + 1acafe8 commit c2f84cf
Show file tree
Hide file tree
Showing 10 changed files with 363 additions and 283 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
2 changes: 1 addition & 1 deletion plex/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plex

// Version contains the version of the app.
const Version = "0.2.0"
const Version = "0.3.0"
25 changes: 21 additions & 4 deletions webui/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package webui

import (
"fmt"
"html/template"
"log"
"net/http"
"os"
Expand All @@ -12,21 +13,37 @@ import (
"github.com/danstis/Plex-Sync/plex"
)

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

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) {
http.ServeFile(w, r, path.Join("webui", "templates", "index.html"))
tmpl := template.Must(template.ParseFiles(path.Join("webui", "templates", "index.html")))
tmpl.Execute(w, v)
}

func settingsHandler(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, path.Join("webui", "templates", "settings", "settings.html"))
tmpl := template.Must(template.ParseFiles(path.Join("webui", "templates", "settings", "settings.html")))
tmpl.Execute(w, v)
}

func tokenHandler(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, path.Join("webui", "templates", "settings", "promptCredentials.html"))
tmpl := template.Must(template.ParseFiles(path.Join("webui", "templates", "settings", "promptCredentials.html")))
tmpl.Execute(w, v)
}

func logsHandler(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, path.Join("webui", "templates", "logs.html"))
tmpl := template.Must(template.ParseFiles(path.Join("webui", "templates", "logs.html")))
tmpl.Execute(w, v)
}

func generalLogHeadHandler(w http.ResponseWriter, r *http.Request) {
Expand Down
96 changes: 53 additions & 43 deletions webui/templates/_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,69 @@
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>plex-sync</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet">
<link href="/static/css/main.css" rel="stylesheet">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/static/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<!--[if lt IE 9]>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>plex-sync</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet">
<link href="/static/css/main.css" rel="stylesheet">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/static/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false"
aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Plex-Sync</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="/">Home</a></li>
<li><a href="/logs">Logs</a></li>
<li><a href="/settings">Settings</a></li>
<li><a href="https://github.com/danstis/Plex-Sync" target="_Blank">GitHub Project</a></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</nav>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false"
aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Plex-Sync v{{.Version}}</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">
<a href="/">Home</a>
</li>
<li>
<a href="/logs">Logs</a>
</li>
<li>
<a href="/settings">Settings</a>
</li>
<li>
<a href="https://github.com/danstis/Plex-Sync" target="_Blank">GitHub Project</a>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</nav>

<div class="container">
<div class="container">

<div>
<h1>Plex-Sync</h1>
<p class="lead">Some text in here...</p>
</div>
<div>
<h1>Plex-Sync</h1>
<p class="lead">Some text in here...</p>
</div>

</div>
<!-- /.container -->
</div>
<!-- /.container -->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
</body>

</html>
100 changes: 57 additions & 43 deletions webui/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,73 @@
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>plex-sync</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet">
<link href="/static/css/main.css" rel="stylesheet">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/static/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<!--[if lt IE 9]>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>plex-sync</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet">
<link href="/static/css/main.css" rel="stylesheet">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/static/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false"
aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Plex-Sync</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="/">Home</a></li>
<li><a href="/logs">Logs</a></li>
<li><a href="/settings">Settings</a></li>
<li><a href="https://github.com/danstis/Plex-Sync" target="_Blank">GitHub Project</a></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</nav>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false"
aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Plex-Sync v{{.Version}}</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">
<a href="/">Home</a>
</li>
<li>
<a href="/logs">Logs</a>
</li>
<li>
<a href="/settings">Settings</a>
</li>
<li>
<a href="https://github.com/danstis/Plex-Sync" target="_Blank">GitHub Project</a>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</nav>

<div class="container">
<div class="container">

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

</div>
<!-- /.container -->
</div>
<!-- /.container -->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
</body>

</html>
Loading

0 comments on commit c2f84cf

Please sign in to comment.