Respect base URL

This commit is contained in:
Alex Ling 2020-06-08 15:24:35 +00:00
parent 53c3798691
commit 0f3dd51d6b
2 changed files with 39 additions and 36 deletions

View File

@ -8,8 +8,7 @@ function showModal(encodedPath, pages, percentage, encodedeTitle, encodedEntryTi
if (percentage === 0) { if (percentage === 0) {
$('#continue-btn').attr('hidden', ''); $('#continue-btn').attr('hidden', '');
$('#unread-btn').attr('hidden', ''); $('#unread-btn').attr('hidden', '');
} } else {
else {
$('#continue-btn').text('Continue from ' + percentage + '%'); $('#continue-btn').text('Continue from ' + percentage + '%');
} }
if (percentage === 100) { if (percentage === 100) {
@ -17,7 +16,7 @@ function showModal(encodedPath, pages, percentage, encodedeTitle, encodedEntryTi
} }
$('#modal-title-link').text(title); $('#modal-title-link').text(title);
$('#modal-title-link').attr('href', '/book/' + titleID); $('#modal-title-link').attr('href', `${base_url}book/${titleID}`);
$('#modal-entry-title').find('span').text(entry); $('#modal-entry-title').find('span').text(entry);
$('#modal-entry-title').next().attr('data-id', titleID); $('#modal-entry-title').next().attr('data-id', titleID);
@ -44,14 +43,15 @@ function showModal(encodedPath, pages, percentage, encodedeTitle, encodedEntryTi
const updateProgress = (tid, eid, page) => { const updateProgress = (tid, eid, page) => {
let url = `${base_url}api/progress/${tid}/${page}` let url = `${base_url}api/progress/${tid}/${page}`
const query = $.param({entry: eid}); const query = $.param({
entry: eid
});
if (eid) if (eid)
url += `?${query}`; url += `?${query}`;
$.post(url, (data) => { $.post(url, (data) => {
if (data.success) { if (data.success) {
location.reload(); location.reload();
} } else {
else {
error = data.error; error = data.error;
alert('danger', error); alert('danger', error);
} }
@ -69,7 +69,9 @@ const renameSubmit = (name, eid) => {
return; return;
} }
const query = $.param({ entry: eid }); const query = $.param({
entry: eid
});
let url = `${base_url}api/admin/display_name/${titleId}/${name}`; let url = `${base_url}api/admin/display_name/${titleId}/${name}`;
if (eid) if (eid)
url += `?${query}`; url += `?${query}`;
@ -102,8 +104,7 @@ const edit = (eid) => {
url = item.find('img').attr('data-src'); url = item.find('img').attr('data-src');
displayName = item.find('.uk-card-title').attr('data-title'); displayName = item.find('.uk-card-title').attr('data-title');
$('#title-progress-control').attr('hidden', ''); $('#title-progress-control').attr('hidden', '');
} } else {
else {
$('#title-progress-control').removeAttr('hidden'); $('#title-progress-control').removeAttr('hidden');
} }
@ -130,7 +131,9 @@ const setupUpload = (eid) => {
const upload = $('.upload-field'); const upload = $('.upload-field');
const bar = $('#upload-progress').get(0); const bar = $('#upload-progress').get(0);
const titleId = upload.attr('data-title-id'); const titleId = upload.attr('data-title-id');
const queryObj = {title: titleId}; const queryObj = {
title: titleId
};
if (eid) if (eid)
queryObj['entry'] = eid; queryObj['entry'] = eid;
const query = $.param(queryObj); const query = $.param(queryObj);

View File

@ -11,7 +11,7 @@
<dd>Update <code>config.yml</code> located at: <code><%= Config.current.path %></code></dd> <dd>Update <code>config.yml</code> located at: <code><%= Config.current.path %></code></dd>
<dt style="font-weight: 500;">Can't see your files yet?</dt> <dt style="font-weight: 500;">Can't see your files yet?</dt>
<dd>You must wait <%= Config.current.scan_interval %> minutes for the library scan to complete <dd>You must wait <%= Config.current.scan_interval %> minutes for the library scan to complete
<% if is_admin %>, or manually re-scan from <a href="/admin">Admin</a><% end %>.</dd> <% if is_admin %>, or manually re-scan from <a href="<%= base_url %>admin">Admin</a><% end %>.</dd>
</dl> </dl>
</div> </div>
@ -22,16 +22,16 @@
<h2>Read your first manga</h2> <h2>Read your first manga</h2>
<p>Once you start reading, Mango will remember where you left off <p>Once you start reading, Mango will remember where you left off
and show your entries here.</p> and show your entries here.</p>
<a href="/library" class="uk-button uk-button-default">View library</a> <a href="<%= base_url %>library" class="uk-button uk-button-default">View library</a>
</div> </div>
<%- elsif new_user == false && empty_library == false -%> <%- elsif new_user == false && empty_library == false -%>
<%- if continue_reading.empty? && recently_added.empty? -%> <%- if continue_reading.empty? && recently_added.empty? -%>
<div class="uk-container uk-text-center"> <div class="uk-container uk-text-center">
<img src="/img/banner.png" style="max-width: 400px; padding: 0 20px;"> <img src="<%= base_url %>img/banner.png" style="max-width: 400px; padding: 0 20px;">
<p>A self-hosted manga server and reader</p> <p>A self-hosted manga server and reader</p>
<a href="/library" class="uk-button uk-button-default">View library</a> <a href="<%= base_url %>library" class="uk-button uk-button-default">View library</a>
</div> </div>
<%- end -%> <%- end -%>
@ -78,7 +78,7 @@
</div> </div>
<%- else -%> <%- else -%>
<div class="item"> <div class="item">
<a class="acard" href="/book/<%= ra[:entry].book.id %>"> <a class="acard" href="<%= base_url %>book/<%= ra[:entry].book.id %>">
<div class="uk-card uk-card-default"> <div class="uk-card uk-card-default">
<div class="uk-card-media-top"> <div class="uk-card-media-top">
<img data-src="<%= ra[:entry].cover_url %>" data-width data-height alt="" uk-img> <img data-src="<%= ra[:entry].cover_url %>" data-width data-height alt="" uk-img>
@ -126,7 +126,7 @@
<% content_for "script" do %> <% content_for "script" do %>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery.dotdotdot/4.0.11/dotdotdot.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery.dotdotdot/4.0.11/dotdotdot.js"></script>
<script src="/js/dots.js"></script> <script src="<%= base_url %>js/dots.js"></script>
<script src="/js/alert.js"></script> <script src="<%= base_url %>js/alert.js"></script>
<script src="/js/title.js"></script> <script src="<%= base_url %>js/title.js"></script>
<% end %> <% end %>