Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HUGE PR: new config framework for Headphones #2590

Open
wants to merge 90 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
3af0a5f
Templates for config
maxkoryukov Feb 6, 2016
f0cb45e
fuckin pep8
maxkoryukov Feb 14, 2016
53dc707
`unittescompat` moved to lib folder
maxkoryukov Feb 14, 2016
2ae7c11
Small improvements for all exiting tests
maxkoryukov Feb 14, 2016
031130c
Test Config : additional assertions, on config write. It is enough im…
maxkoryukov Feb 14, 2016
deb7207
THE FIRST SINGNIFICANT commit for hidden opt
maxkoryukov Feb 14, 2016
648390a
Small fixes for CSS of default interface
maxkoryukov Feb 14, 2016
8ef9ffd
Improved JS of ajax sending
maxkoryukov Feb 14, 2016
ec90a60
opt-hidden progress
maxkoryukov Feb 17, 2016
cd82bf8
CONFIG: structured options, another one step
maxkoryukov Mar 1, 2016
200fc6f
Step: improve settings
maxkoryukov Mar 9, 2016
efde5e2
UPG: a lot of improvements for options
maxkoryukov Mar 10, 2016
6e38c31
UPG: move files to refactor config infrastructure
maxkoryukov Mar 10, 2016
9761c47
UPG : config viewmodel improvements
maxkoryukov Mar 10, 2016
c3faa4e
FIX: fixed bug with column ruler on the config page (out of tab-box)
maxkoryukov Mar 10, 2016
4178fee
DOC: link in the config.less
maxkoryukov Mar 10, 2016
225839f
FIX: fixed type-name for hp.config.types.path
maxkoryukov Mar 10, 2016
b27cfa3
UPG: intermediate version of new config. Able to read config using ne…
maxkoryukov Mar 11, 2016
60b3259
UPG: config writing
maxkoryukov Mar 12, 2016
770f738
UPG: javascripts are moved from config-templates to the config page (…
maxkoryukov Mar 12, 2016
c9fec80
TEST: removed unnecessary (tests for the internal stuff) tests for co…
maxkoryukov Mar 12, 2016
c4a6a7c
FIX : fix less
maxkoryukov Mar 12, 2016
97ad116
FIX: style.less
maxkoryukov Mar 12, 2016
cde81ac
FIX: style.less
maxkoryukov Mar 12, 2016
3026f6e
squash me
maxkoryukov Mar 12, 2016
fc0985c
FIX: style for HP
maxkoryukov Mar 12, 2016
fb28178
UPG: misc improvements for options. New block of options - advanced:git
maxkoryukov Mar 12, 2016
835ce70
FIX: removed trailing spaces from ui.js
maxkoryukov Mar 12, 2016
0cb3c09
FIX: fixed bugs in config and definitions
maxkoryukov Mar 13, 2016
858b16c
UPG: added parser of POSTed data for config module
maxkoryukov Mar 14, 2016
b1b83dd
UPG: now config works!
maxkoryukov Mar 14, 2016
6e2d77f
FIX: css for options. Removed old config definitions, and 'float' lay…
maxkoryukov Mar 15, 2016
ce6994e
* UPG : MetaConfig - loader for meta-info about options, such as Read…
maxkoryukov Mar 15, 2016
37e84eb
UPG : new config-template: OptionDropDownSelector. It allows to selec…
maxkoryukov Mar 15, 2016
3d90cff
FIX: style.css regenerate
maxkoryukov Mar 15, 2016
f828c3c
UPG: 100% working OptionDropdownSelector
maxkoryukov Mar 16, 2016
565bac2
UPG : Complete 'Downloads' tab of Config page
maxkoryukov Mar 16, 2016
484c6e9
FIX: style and forced-non-render for internal and deprecated options
maxkoryukov Mar 16, 2016
6c78b70
FIX: pep8 and tests
maxkoryukov Mar 16, 2016
cf3fe34
FIX: pyflakes
maxkoryukov Mar 16, 2016
3f863ce
FIX: pyflakes and tests
maxkoryukov Mar 16, 2016
2974339
FIX: fix all small bugs, now tests are passed
maxkoryukov Mar 17, 2016
a0f38b8
FIX: simplified `searcher.py` uses the INTEGER value of option 'PREFE…
maxkoryukov Mar 17, 2016
9a4ba59
UPG: restructured tab 'Quality and Post Processing'
maxkoryukov Mar 17, 2016
02cc796
FIX: pep8 and pyflakes
maxkoryukov Mar 17, 2016
5286b9a
TEST: improved coverage
maxkoryukov Mar 17, 2016
5b588bb
UPG: the half of Advanced tab
maxkoryukov Mar 17, 2016
bb8e62e
FIX: EXTRA-checkbox beaten. Now it is common option, without superdup…
maxkoryukov Mar 17, 2016
259c62f
UPG: Config tab 'Advanced' almost done. There is just one trouble - s…
maxkoryukov Mar 18, 2016
8be9f4a
UPG: hidden and readonly options (configured using `config.meta.ini`)…
maxkoryukov Mar 18, 2016
f4e14b6
UPG: Partialy localized (ru) !!
maxkoryukov Mar 18, 2016
22c490a
FIX: displaying of the appropriate block of settings on "advanced" fo…
maxkoryukov Mar 18, 2016
ca35772
UPG: common way to handle cssclasses for options and other templates
maxkoryukov Mar 19, 2016
bc9f94c
UPG: NOTIFICATIONS tab
maxkoryukov Mar 21, 2016
cd0eefd
UPG: translations updated
maxkoryukov Mar 21, 2016
6a0d896
UPG: Font awesome
maxkoryukov Mar 22, 2016
fe1e4a8
UPG: Search tab DONE
maxkoryukov Mar 22, 2016
bb65f58
LANG: translations updated
maxkoryukov Mar 22, 2016
b139525
UPD: Font awesome
maxkoryukov Mar 22, 2016
be5fcdd
UPG: soft chroot (fix #11)
maxkoryukov Mar 22, 2016
1c57651
Merge branch 'fix/unittestcompat-method-doc' into feature/hidden-opt-2
maxkoryukov Mar 22, 2016
a23e078
adsf
maxkoryukov Mar 22, 2016
e2aa959
UPG: release version of HIDDEN OPT
maxkoryukov Apr 2, 2016
84640ac
Merge branch 'feature/hidden-opt-2' into feature/hidden-opt-pr
maxkoryukov Apr 2, 2016
626cbf9
Remove unittestcompat from headphones (exists in lib)
maxkoryukov Apr 2, 2016
d7a2123
FIX: fixed errors in extra-torznabs, newznabs. Now worked well with '…
maxkoryukov Apr 2, 2016
919b88a
UPG: unittestcompat improvements
maxkoryukov Apr 2, 2016
c9031d9
FIX: unittestcompat for python 2.6 : exception type inheritance
maxkoryukov Apr 2, 2016
d7150e1
DBG: small fixes in travis ci for drop cache
maxkoryukov Apr 2, 2016
092d4c4
DOC: upgraded docs in /locale
maxkoryukov Apr 9, 2016
6b3b8ae
DOCS: fixed run path in locale-docs
maxkoryukov Apr 9, 2016
11859ce
UPG: more logging for webserve.py
maxkoryukov Apr 11, 2016
4e43afe
Merge branch 'feature/hidden-opt-pr' of https://github.com/maxkoryuko…
maxkoryukov Apr 11, 2016
45f489c
FIX: font-awesome without SVG version
maxkoryukov Apr 12, 2016
fbe509d
Sync branch with upstream (through merge, because rebase will take a …
maxkoryukov Apr 13, 2016
9dbc518
UGP: improved unittestcompat
maxkoryukov Apr 13, 2016
800e9eb
FIX: travis config reverted (was modified , to drop cache)
maxkoryukov Apr 13, 2016
524ec86
UPG: font awesome 4.6.1
maxkoryukov Apr 19, 2016
8b94362
FIX: fix microsoft CSS filter property
maxkoryukov Apr 19, 2016
ee55c3c
New meta-options (#26) and fix for HTTP-headers for proxy
maxkoryukov Apr 20, 2016
771ed21
TEST: slight improvements for tests for softchroot
maxkoryukov Apr 22, 2016
c265743
UPG: config - hide empty blocks (when all embed options was hidden by…
maxkoryukov Apr 22, 2016
5a352dd
Tests in browser with SouceLabs+Selenium
maxkoryukov Apr 23, 2016
cd2110f
FIX: soft-chroot bug with path equals to chroot without slash fixed
maxkoryukov Apr 23, 2016
5c01883
FIX: correct closing SauceLabs browser
maxkoryukov Apr 23, 2016
74740eb
FIX: slight modifications in advanced options
maxkoryukov Apr 23, 2016
c72a1c1
UPG: browser test - new environment: OS X 10, safari 9.0
maxkoryukov Apr 23, 2016
6433b02
Simplified selenium tests (runs locally)
maxkoryukov Apr 24, 2016
50e65f9
remove commented code (fix maxkoryukov/headphones#24)
maxkoryukov May 30, 2016
43c5ed5
remove commented code (fix maxkoryukov/headphones#24)
maxkoryukov May 30, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CONFIG: structured options, another one step
  • Loading branch information
maxkoryukov committed Mar 22, 2016
commit cd82bf8f723edb83a6d21bba8c2d3b6206029f36
92 changes: 84 additions & 8 deletions data/interfaces/default/config-templates.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,90 @@
<%def name="OptionString(key, label='', tip='', caption='', size=None)">
<%def name="OptionString(o)">
<%
txt_size_attr = ' size="%d"' % size if size is not None else '';
size_attr = '' if o.maxlength is None else ' size="%d"' % o.maxlength
tooltip_attr = '' if o.tooltip is None else ' title="%s"' % o.tooltip
uiname = o.appkey + '_config_opt'
%>
<div class="row">
<label title="${tip}">
${label}
</label>
<input type="text" name="${key}" value="${config[key]}" ${txt_size_attr} />
%if caption:
<small>${caption}</small>
%if o.label is not None:
<label ${tooltip_attr} for="${uiname}">
${o.label}
</label>
%endif

<input type="text" id="${uiname}" name="${uiname}" value="${o.value}" ${size_attr} />

%if o.caption is not None:
<small>${o.caption}</small>
%endif
</div>
</%def>


<%def name="OptionPassword(o)">
<%
size_attr = '' if o.maxlength is None else ' size="%d"' % o.maxlength
tooltip_attr = '' if o.tooltip is None else ' title="%s"' % o.tooltip
uiname = o.appkey + '_config_opt'
%>
<div class="row">
%if o.label is not None:
<label ${tooltip_attr} for="${uiname}">
${o.label}
</label>
%endif

<input type="password" id="${uiname}" name="${uiname}" value="${o.value}" ${size_attr} />

%if o.caption is not None:
<small>${o.caption}</small>
%endif
</div>
</%def>


<%def name="OptionNumber(o)">
<%
min_attr = '' if o.minvalue is None else ' min="%d"' % o.minvalue
max_attr = '' if o.maxvalue is None else ' size="%d"' % o.maxvalue
tooltip_attr = '' if o.tooltip is None else ' title="%s"' % o.tooltip
uiname = o.appkey + '_config_opt'
%>
<div class="row">
%if o.label is not None:
<label ${tooltip_attr} for="${uiname}">
${o.label}
</label>
%endif

<input type="number" id="${uiname}" name="${uiname}" value="${o.value}" ${min_attr} ${max_attr} />

%if o.caption is not None:
<small>${o.caption}</small>
%endif
</div>
</%def>

<%def name="OptionBool(o)">
<%
tooltip_attr = '' if o.tooltip is None else ' title="%s"' % o.tooltip
uiname = o.appkey + '_config_opt'
checked_attr = 'checked' if o.value else ''
%>
<div class="row checkbox">
%if o.label is not None:
<label ${tooltip_attr} for="${uiname}">
${o.label}
</label>
%endif

<input type="checkbox" id="${uiname}" name="${uiname}" value="1" ${checked_attr} />

%if o.caption is not None:
<small>${o.caption}</small>
%endif
</div>
</%def>

<%def name="OptionSwitch(o)">
<strong>Turn</strong>
</%def>
12 changes: 7 additions & 5 deletions data/interfaces/default/config.html
Original file line number Diff line number Diff line change
@@ -32,14 +32,16 @@ <h1 class="clearfix"><i class="fa fa-gear"></i> Settings</h1>

% for tab in tabs:
<div id="${tab.id}">
% for block in tab.iblocks():
% for block in tab:
<fieldset>
<legend>${block.caption}</legend>
% for option in block.ioptions():
<div>${${option.tmp}}</div>
% endfor # for option in block.ioptions()
% for option in block:
<div>
${option.render()}
</div>
% endfor # for option in block
</fieldset>
% endfor # for block in tab.iblocks()
% endfor # for block in tab
</div>
% endfor # for tab in tabs
</form>
13 changes: 2 additions & 11 deletions data/interfaces/default/config2.html
Original file line number Diff line number Diff line change
@@ -36,17 +36,8 @@ <h1 class="clearfix"><i class="fa fa-gear"></i> Settings</h1>
<td>
<fieldset>
<legend>Basic</legend>

${OptionString('http_host',
tip='Host to bind web server to',
label='HTTP Host',
caption='Use 0.0.0.0 to allow outside connections',
size=30)}

${OptionString('http_port',
tip='Port to bind web server to. Note that ports below 1024 may require root.',
label='HTTP Port',
size=10)}



<div class="row">
<label title="Username for web server authentication. Leave empty to disable.">
101 changes: 74 additions & 27 deletions headphones/config.py
Original file line number Diff line number Diff line change
@@ -7,9 +7,10 @@
from configview import Tab, Tabs, Block
from configoptions import path, bool_int

from configoptions import OptionString, OptionNumber, OptionSwitch
from configoptions import OptionString, OptionNumber, OptionSwitch, OptionPassword, OptionBool, OptionPath

def _(x):
""" required just for marking translatable strings"""
return x

_TABS = Tabs((
@@ -21,7 +22,7 @@ def _(x):
Tab('advanced', _("Advanced Settings")),
))

def register_block(tabid, *blocks):
def registerBlock(tabid, *blocks):
tab = None
for t in _TABS:
if t.id == tabid:
@@ -32,28 +33,74 @@ def register_block(tabid, *blocks):
for block in blocks:
tab.add([block])

"""
${OptionString('http_host',
tip='Host to bind web server to',
label='HTTP Host',
caption='Use 0.0.0.0 to allow outside connections',
size=30)}

${OptionString('http_port',
tip='Port to bind web server to. Note that ports below 1024 may require root.',
label='HTTP Port',
size=10)}
"""
register_block('webui',

# <div class="row checkbox">
# <input type="checkbox" name="enable_https" id="enable_https" value="1" ${config['enable_https']} />
# <label title="Enable HTTPS for web server for encrypted communication">
# Enable HTTPS
# </label>
# </div>
# <div id="https_options">
# <div class="row">
# <label>HTTPS Cert</label>
# <input type="text" name="https_cert" value="${config['https_cert']}" size="30">
# </div>
# <div class="row">
# <label>HTTPS Key</label>
# <input type="text" name="https_key" value="${config['https_key']}" size="30">
# </div>
# </div>


registerBlock('webui',
Block('basic', caption=_("Basic"), options=[
OptionString('HTTP_HOST', default='', maxlength=30),
OptionNumber('HTTP_PORT', default=8181, minvalue=1, maxvalue=99999),

OptionString('HTTP_HOST', 'General', 'localhost',
label=_('HTTP Host'),
caption=_('Use 0.0.0.0 to allow outside connections'),
tooltip=_('Host to bind web server to'),
maxlength=30
),
OptionNumber('HTTP_PORT', 'General', 8181,
label=_('HTTP Port'),
tooltip=_('Port to bind web server to. Note that ports below 1024 may require root.'),
minvalue=1,
maxvalue=99999),
OptionPath('HTTP_USERNAME', 'General', '',
label=_('HTTP Username'),
tooltip=_('Username for web server authentication. Leave empty to disable.'),
maxlength=30),
OptionPassword('HTTP_PASSWORD', 'General', '',
label=_('HTTP Password'),
tooltip=_('Password for web server authentication. Leave empty to disable.'),
maxlength=30),
OptionBool('LAUNCH_BROWSER', 'General', True,
label=_('Launch Browser on Startup'),
tooltip=_('Launch browser pointed to Headphones, on startup.'),
),
]),


# <fieldset>
# <legend>API</legend>
# <div class="row checkbox">
# <input type="checkbox" id="api_enabled" />
# </div>
# <div id="apioptions" class="row">
# <label></label>
# <input type="text" name="api_key" id="api_key" value="${config['api_key']}" size="20">
# <input type="button" value="Generate" id="generate_api">
# <small>Current API key: <strong>${config['api_key']}</strong></small>
# </div>
# </fieldset>
Block('api', caption=_("API"), options=[
OptionString('API_KEY', default='', maxlength=20),
OptionSwitch('API_ENABLED', default=False),
]),
OptionSwitch('API_ENABLED', 'General', False,
label=_('Enable API'),
tooltip=_('Allow remote applications to interface with Headphones')),
OptionString('API_KEY', 'General', '',
label=_('API key'),
maxlength=20),
]),
)

# =======================================================================================
@@ -67,8 +114,8 @@ def register_block(tabid, *blocks):
# This is used in importer.py to determine how complete an album needs to
# be - to be considered "downloaded". Percentage from 0-100
'ALBUM_COMPLETION_PCT': (int, 'Advanced', 80),
'API_ENABLED': (int, 'General', 0),
'API_KEY': (str, 'General', ''),
'API_ENABLED': (int, 'General', 0),
'API_KEY': (str, 'General', ''),
'AUTOWANT_ALL': (int, 'General', 0),
'AUTOWANT_MANUALLY_ADDED': (int, 'General', 1),
'AUTOWANT_UPCOMING': (int, 'General', 1),
@@ -149,12 +196,12 @@ def register_block(tabid, *blocks):
'HPUSER': (str, 'General', ''),
'HTTPS_CERT': (path, 'General', ''),
'HTTPS_KEY': (path, 'General', ''),
'HTTP_HOST': (str, 'General', 'localhost'),
'HTTP_PASSWORD': (str, 'General', ''),
'HTTP_PORT': (int, 'General', 8181),
'HTTP_HOST': (str, 'General', 'localhost'),
'HTTP_PASSWORD': (str, 'General', ''),
'HTTP_PORT': (int, 'General', 8181),
'HTTP_PROXY': (int, 'General', 0),
'HTTP_ROOT': (str, 'General', '/'),
'HTTP_USERNAME': (str, 'General', ''),
'HTTP_USERNAME': (str, 'General', ''),
'IDTAG': (int, 'Beets', 0),
'IGNORE_CLEAN_RELEASES': (int, 'General', 0),
'IGNORED_WORDS': (str, 'General', ''),
@@ -169,7 +216,7 @@ def register_block(tabid, *blocks):
'KEEP_NFO': (int, 'General', 0),
'KEEP_TORRENT_FILES': (int, 'General', 0),
'LASTFM_USERNAME': (str, 'General', ''),
'LAUNCH_BROWSER': (int, 'General', 1),
'LAUNCH_BROWSER': (int, 'General', 1),
'LIBRARYSCAN': (int, 'General', 1),
'LIBRARYSCAN_INTERVAL': (int, 'General', 300),
'LMS_ENABLED': (int, 'LMS', 0),
Loading
Oops, something went wrong.