diff --git a/.gitignore b/.gitignore index f903669..bd4bca0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/_source/ \ No newline at end of file +/_source/ +/data/ diff --git a/couchpotato/core/_base/updater/main.py b/couchpotato/core/_base/updater/main.py index b88b1e9..174f1ff 100644 --- a/couchpotato/core/_base/updater/main.py +++ b/couchpotato/core/_base/updater/main.py @@ -78,7 +78,7 @@ class Updater(Plugin): def doUpdateView(self): self.check() - if not self.update_version: + if not self.updater.update_version: log.error('Trying to update when no update is available.') success = False else: diff --git a/couchpotato/core/helpers/variable.py b/couchpotato/core/helpers/variable.py index 9a4bdc1..493ac79 100644 --- a/couchpotato/core/helpers/variable.py +++ b/couchpotato/core/helpers/variable.py @@ -5,6 +5,7 @@ import platform import random import re import string +import sys log = CPLog(__name__) @@ -22,6 +23,10 @@ def getDataDir(): if 'darwin' in platform.platform().lower(): return os.path.join(user_dir, 'Library', 'Application Support', 'CouchPotato') + # FreeBSD + if 'freebsd' in sys.platform: + return os.path.join('/usr/local/', 'couchpotato', 'data') + # Linux return os.path.join(user_dir, '.couchpotato') diff --git a/couchpotato/core/plugins/log/static/log.js b/couchpotato/core/plugins/log/static/log.js index 1668ded..7a91d4c 100644 --- a/couchpotato/core/plugins/log/static/log.js +++ b/couchpotato/core/plugins/log/static/log.js @@ -45,7 +45,7 @@ Page.Log = new Class({ new Fx.Scroll(window, {'duration': 0}).toBottom(); var nav = new Element('ul.nav').inject(self.log, 'top'); - for (var i = 0; i < json.total; i++) { + for (var i = 0; i <= json.total; i++) { new Element('li', { 'text': i+1, 'class': nr == i ? 'active': '', @@ -78,6 +78,10 @@ Page.Log = new Class({ addColors: function(text){ var self = this; + var text = new Element('div', { + 'html': text + }).get('text') + text = text.replace(/\u001b\[31m/gi, '') text = text.replace(/\u001b\[36m/gi, '') text = text.replace(/\u001b\[33m/gi, '') diff --git a/couchpotato/static/scripts/block/navigation.js b/couchpotato/static/scripts/block/navigation.js index b6886f8..85f20c4 100644 --- a/couchpotato/static/scripts/block/navigation.js +++ b/couchpotato/static/scripts/block/navigation.js @@ -32,13 +32,21 @@ Block.Navigation = new Class({ }, - addTab: function(tab){ + addTab: function(name, tab){ var self = this - return new Element('li.tab_'+(tab.text.toLowerCase() || 'unknown')).adopt( + return new Element('li.tab_'+(name || 'unknown')).adopt( new Element('a', tab) ).inject(self.nav) + }, + + activate: function(name){ + var self = this; + + self.nav.getElements('.active').removeClass('active'); + self.nav.getElements('.tab_'+name).addClass('active'); + } }); \ No newline at end of file diff --git a/couchpotato/static/scripts/couchpotato.js b/couchpotato/static/scripts/couchpotato.js index b983fb5..9a15bba 100644 --- a/couchpotato/static/scripts/couchpotato.js +++ b/couchpotato/static/scripts/couchpotato.js @@ -82,7 +82,7 @@ var CouchPotato = new Class({ new Element('a', { 'text': 'Check for updates', 'events': { - 'click': self.checkForUpdate.bind(self) + 'click': self.checkForUpdate.bind(self, null) } }), new Element('a', { diff --git a/couchpotato/static/scripts/page.js b/couchpotato/static/scripts/page.js index 589fa3e..1af800e 100644 --- a/couchpotato/static/scripts/page.js +++ b/couchpotato/static/scripts/page.js @@ -20,7 +20,7 @@ var PageBase = new Class({ // Create tab for page if(self.has_tab){ var nav = App.getBlock('navigation'); - self.tab = nav.addTab({ + self.tab = nav.addTab(self.name, { 'href': App.createUrl(self.name), 'title': self.title, 'text': self.name.capitalize() @@ -39,6 +39,7 @@ var PageBase = new Class({ self.el.adopt(elements); } + App.getBlock('navigation').activate(self.name); self.fireEvent('opened'); } catch (e){ diff --git a/couchpotato/static/scripts/page/settings.js b/couchpotato/static/scripts/page/settings.js index 8bf0405..9184855 100644 --- a/couchpotato/static/scripts/page/settings.js +++ b/couchpotato/static/scripts/page/settings.js @@ -34,6 +34,8 @@ Page.Settings = new Class({ else { self.openTab(action); } + + App.getBlock('navigation').activate(self.name); }, openTab: function(action){ diff --git a/couchpotato/static/style/main.css b/couchpotato/static/style/main.css index 884d872..679748b 100644 --- a/couchpotato/static/style/main.css +++ b/couchpotato/static/style/main.css @@ -203,18 +203,25 @@ body > .spinner, .mask{ display: block; margin-top: 5px; } - - .header .navigation li.disabled { - color: #e5e5e5; - } - - .header .navigation li a:link, .header .navigation li a:visited { - color: #fff; + + .header .navigation li a:after { + content: ''; + display: inline-block; + height: 2px; + width: 100%; + position: relative; + top: -20px; + background-color: #46505e; + outline: none; + box-shadow: inset 0 1px 8px rgba(0,0,0,0.05), 0 1px 0px rgba(255,255,255,0.15); + transition: all .4s cubic-bezier(0.9,0,0.1,1); } + + .header .navigation li:hover a:after { background-color: #047792; } + .header .navigation li.active a:after { background-color: #04bce6; } - .header .navigation li a:hover, .header .navigation li a:active { - color: #b1d8dc; - } + .header .navigation li.disabled { color: #e5e5e5; } + .header .navigation li a { color: #fff; } .header .navigation .backtotop { opacity: 0; diff --git a/init/freebsd b/init/freebsd index e3cf408..eeba51d 100644 --- a/init/freebsd +++ b/init/freebsd @@ -31,14 +31,27 @@ load_rc_config ${name} : ${couchpotato_user:="_sabnzbd"} : ${couchpotato_dir:="/usr/local/couchpotato"} : ${couchpotato_chdir:="${couchpotato_dir}"} -: ${couchpotato_pid:="/var/run/couchpotato.pid"} +: ${couchpotato_pid:="${couchpotato_dir}/couchpotato.pid"} +: ${couchpotato_conf:="${couchpotato_dir}/data/settings.conf"} + +WGET="/usr/local/bin/wget" # You need wget for this script to safely shutdown CouchPotato. +if [ -e "${couchpotato_conf}" ]; then + HOST=`grep -A14 "\[core\]" "${couchpotato_conf}"|egrep "^host"|perl -wple 's/^host = (.*)$/$1/'` + PORT=`grep -A14 "\[core\]" "${couchpotato_conf}"|egrep "^port"|perl -wple 's/^port = (.*)$/$1/'` + CPAPI=`grep -A14 "\[core\]" "${couchpotato_conf}"|egrep "^api_key"|perl -wple 's/^api_key = (.*)$/$1/'` +fi -pidfile="${couchpotato_pid}" status_cmd="${name}_status" stop_cmd="${name}_stop" command="/usr/sbin/daemon" -command_args="-f -p ${couchpotato_pid} python ${couchpotato_dir}/CouchPotato.py ${couchpotato_flags} --pid_file=${couchpotato_pid}" +command_args="-f -p ${couchpotato_pid} python ${couchpotato_dir}/CouchPotato.py ${couchpotato_flags}" + +# Check for wget and refuse to start without it. +if [ ! -x "${WGET}" ]; then + warn "couchpotato not started: You need wget to safely shut down CouchPotato." + exit 1 +fi # Ensure user is root when running this script. if [ `id -u` != "0" ]; then @@ -55,17 +68,17 @@ verify_couchpotato_pid() { # Try to stop CouchPotato cleanly by calling shutdown over http. couchpotato_stop() { - + if [ ! -e "${couchpotato_conf}" ]; then + echo "CouchPotato's settings file does not exist. Try starting CouchPotato, as this should create the file." + exit 1 + fi echo "Stopping $name" verify_couchpotato_pid - + ${WGET} -O - -q "http://${HOST}:${PORT}/api/${CPAPI}/app.shutdown/" >/dev/null if [ -n "${pid}" ]; then - kill -SIGTERM ${pid} 2> /dev/null wait_for_pids ${pid} - kill -9 ${pid} 2> /dev/null echo "Stopped" fi - } couchpotato_status() {