Add setting to specify newsletter ID name for static URLs

This commit is contained in:
JonnyWong16 2018-05-08 10:54:07 -07:00
parent 8e3fe7bfa2
commit 7778d84728
7 changed files with 61 additions and 31 deletions

View file

@ -166,6 +166,15 @@
% endfor
</div>
<div class="col-md-12" style="margin-top: 10px; padding-top: 10px; border-top: 1px solid #444;">
<div class="form-group">
<label for="id_name">Unique ID Name</label>
<div class="row">
<div class="col-md-12">
<input type="text" class="form-control" id="id_name" name="id_name" value="${newsletter['id_name']}" size="30">
</div>
</div>
<p class="help-block">Enter a unique ID name to create a static URL to the last sent scheduled newsletter at <span class="inline-pre">/newsletter/id/&lt;id_name&gt;</span>. Only letters (a-z), numbers (0-9), underscores (_) and hyphens (-) are allowed. Leave blank to disable.</p>
</div>
<div class="form-group">
<label for="newsletter_config_filename">Filename</label>
<div class="row">
@ -483,6 +492,17 @@
return true;
}
}
function validateIDName() {
var id_name = $('#id_name').val();
if (/^[a-zA-Z0-9_-]*$/.test(id_name)) {
return true;
} else {
showMsg('<i class="fa fa-times"></i> Failed to save newsletter. Invalid unique ID name.', false, true, 5000, true);
return false;
}
}
var $incl_libraries = $('#newsletter_config_incl_libraries').selectize({
plugins: ['remove_button'],
maxItems: null,
@ -668,7 +688,7 @@
if ($('#custom_cron').val() === '0'){
$("#cron_value").val(cron_widget.cron('value'));
}
if (validateFilename()){
if (validateFilename() && validateIDName()){
doAjaxCall('set_newsletter_config', $(this), 'tabs', true, true, saveCallback);
}
}

View file

@ -969,13 +969,6 @@
Note: The <span class="inline-pre">${http_root}newsletter</span> endpoint on your domain must be publicly accessible from the internet.
</p>
<p class="help-block settings-warning base-url-warning">Warning: Public Tautulli domain not set under <a data-tab-destination="tabs-web_interface" data-target="#http_base_url">Web Interface</a>.</p>
<div class="checkbox">
<label>
<input type="checkbox" id="newsletter_static_url" name="newsletter_static_url" value="1" ${config['newsletter_static_url']}> Enable Static Newsletter URL
</label>
<p class="help-block">Enable static newsletter URLs to the last sent scheduled newsletter at <span class="inline-pre">${http_root}newsletter/id/&lt;newsletter_id&gt;</span>.</p>
</div>
</div>
<div class="form-group advanced-setting">