mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 10:11:10 +00:00
Adds book reading support with EPUB and PDF reader plugins
This commit is contained in:
1 parent
275fd83ff2
commit
f7ccdf3d1c
271 files changed
+11501
-361
No files matched your search
@@ -7,7 +7,7 @@
|
||||
@using Microsoft.AspNetCore.Mvc.Localization
|
||||
|
||||
@{
|
||||
// generate a unique id for the scripts section of this view, so it can be dynamically loaded/unloaded by the global AJAX navigator handler
|
||||
// Generate a unique id for the scripts section of this view, so it can be dynamically loaded/unloaded by the global AJAX navigator handler.
|
||||
var scriptId = ScriptIdentifierHelper.GenerateScriptId();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
@model UserSettingsDto
|
||||
|
||||
<div style="display: grid; grid-template-rows: auto 1fr;"><!--container with two rows, one fixed, one filling remaining space-->
|
||||
<div style="min-height: 1rem;"></div><!--the first row is a dummy row for "margin", because setting a margin on the next row would offset the parent's position-->
|
||||
<div style="display: grid; grid-template-rows: auto 1fr;"><!--Container with two rows, one fixed, one filling remaining space.-->
|
||||
<div style="min-height: 1rem;"></div><!--The first row is a dummy row for "margin", because setting a margin on the next row would offset the parent's position.-->
|
||||
<div class="enlightenment-panel shadow-effect mx-auto panel w-50 mb-10" style="min-width: 320px;">
|
||||
<div class="shine-effect"></div>
|
||||
<form method="post" id="user-settings-form" class="inline">
|
||||
@@ -28,7 +28,7 @@
|
||||
</h1>
|
||||
</div>
|
||||
<div class="form-container">
|
||||
<!-- Pagination -->
|
||||
<!-- Pagination. -->
|
||||
<div class="form-row">
|
||||
<div class="form-label">
|
||||
<label asp-for="IsPaginationEnabled">@_localizer["EnablePagination"]</label>:
|
||||
@@ -41,7 +41,7 @@
|
||||
</div>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionEnablePagination"]</small>
|
||||
</div>
|
||||
<!-- Items per page -->
|
||||
<!-- Items per page. -->
|
||||
<div class="form-row">
|
||||
<div class="form-label">
|
||||
<label asp-for="ItemsPerPage">@_localizer["ItemsPerPage"]</label>
|
||||
@@ -65,7 +65,7 @@
|
||||
</div>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionShouldIgnoreThePrefixForAlphaPicker"]</small>
|
||||
</div>
|
||||
<!-- Theme caching -->
|
||||
<!-- Theme caching. -->
|
||||
<div class="form-row">
|
||||
<div class="form-label">
|
||||
<label asp-for="IsThemeCachingEnabled">@_localizer["EnableThemeCaching"]</label>:
|
||||
@@ -78,6 +78,32 @@
|
||||
</div>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionEnableThemeCaching"]</small>
|
||||
</div>
|
||||
<!-- Render PDFs as images. -->
|
||||
<div class="form-row">
|
||||
<div class="form-label">
|
||||
<label asp-for="ShouldRenderPdfAsImages">@_localizer["ShouldRenderPdfAsImages"]</label>:
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label class="enlightenment-checkbox-label">
|
||||
<input type="checkbox" asp-for="ShouldRenderPdfAsImages" class="enlightenment-checkbox-hidden" />
|
||||
<span class="enlightenment-checkbox"></span>
|
||||
</label>
|
||||
</div>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionShouldRenderPdfAsImages"]</small>
|
||||
</div>
|
||||
<!-- Preserve book styles. -->
|
||||
<div class="form-row">
|
||||
<div class="form-label">
|
||||
<label asp-for="ShouldPreserveBookStyles">@_localizer["ShouldPreserveBookStyles"]</label>:
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label class="enlightenment-checkbox-label">
|
||||
<input type="checkbox" asp-for="ShouldPreserveBookStyles" class="enlightenment-checkbox-hidden" />
|
||||
<span class="enlightenment-checkbox"></span>
|
||||
</label>
|
||||
</div>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionShouldPreserveBookStyles"]</small>
|
||||
</div>
|
||||
<div class="form-row" style="justify-content: center;">
|
||||
<button type="submit" class="confirm-button h-22px">@_localizer["Save"]</button>
|
||||
</div>
|
||||
@@ -88,7 +114,7 @@
|
||||
@section Scripts {
|
||||
<!-- The "text/plain" type is a design choice, not a mistake: it keeps the browser from executing this view script during HTML parsing, before site.js defines the API helpers it calls (callApiGetAsync, callApiPostAsync, ...). site.js (which loads deferred) executes these scripts once it is loaded, both on the initial page load and during AJAX navigation. -->
|
||||
<script type="text/plain" data-form="@scriptId">
|
||||
// create cleanup registry for this view
|
||||
// Create cleanup registry for this view.
|
||||
const cleanupFunctions = [];
|
||||
let isInitialized = false;
|
||||
|
||||
@@ -97,14 +123,16 @@
|
||||
const inputItemsPerPage = document.getElementById('ItemsPerPage');
|
||||
const checkboxShouldIgnoreThePrefixForAlphaPicker = document.getElementById('ShouldIgnoreThePrefixForAlphaPicker');
|
||||
const checkboxIsThemeCachingEnabled = document.getElementById('IsThemeCachingEnabled');
|
||||
const checkboxShouldRenderPdfAsImages = document.getElementById('ShouldRenderPdfAsImages');
|
||||
const checkboxShouldPreserveBookStyles = document.getElementById('ShouldPreserveBookStyles');
|
||||
let shouldAggregateMetadataWhenMissing = false;
|
||||
|
||||
// toggle the enabled state of the items per page input based on the pagination checkbox
|
||||
// Toggle the enabled state of the items per page input based on the pagination checkbox.
|
||||
function updateItemsPerPageEnabledState() {
|
||||
inputItemsPerPage.disabled = !checkboxIsPaginationEnabled.checked;
|
||||
}
|
||||
|
||||
// load the settings of the current user
|
||||
// Load the settings of the current user.
|
||||
async function loadUserSettingsAsync() {
|
||||
const data = await callApiGetAsync('@_urlService.GetAbsoluteUrl(WebRoutes.Settings.GET_USER_SETTINGS)');
|
||||
if (data) {
|
||||
@@ -112,42 +140,46 @@
|
||||
inputItemsPerPage.value = data.itemsPerPage;
|
||||
checkboxShouldIgnoreThePrefixForAlphaPicker.checked = data.shouldIgnoreThePrefixForAlphaPicker === true;
|
||||
checkboxIsThemeCachingEnabled.checked = data.isThemeCachingEnabled === true;
|
||||
checkboxShouldRenderPdfAsImages.checked = data.shouldRenderPdfAsImages === true;
|
||||
checkboxShouldPreserveBookStyles.checked = data.shouldPreserveBookStyles === true;
|
||||
shouldAggregateMetadataWhenMissing = data.shouldAggregateMetadataWhenMissing === true;
|
||||
updateItemsPerPageEnabledState();
|
||||
}
|
||||
}
|
||||
|
||||
// save the settings of the current user
|
||||
// Save the settings of the current user.
|
||||
async function handleSaveUserSettingsAsync() {
|
||||
const formData = {
|
||||
IsPaginationEnabled: checkboxIsPaginationEnabled.checked,
|
||||
ItemsPerPage: Number(inputItemsPerPage.value),
|
||||
ShouldIgnoreThePrefixForAlphaPicker: checkboxShouldIgnoreThePrefixForAlphaPicker.checked,
|
||||
IsThemeCachingEnabled: checkboxIsThemeCachingEnabled.checked,
|
||||
ShouldAggregateMetadataWhenMissing: shouldAggregateMetadataWhenMissing
|
||||
ShouldAggregateMetadataWhenMissing: shouldAggregateMetadataWhenMissing,
|
||||
ShouldRenderPdfAsImages: checkboxShouldRenderPdfAsImages.checked,
|
||||
ShouldPreserveBookStyles: checkboxShouldPreserveBookStyles.checked
|
||||
};
|
||||
const data = await callApiPostAsync('@_urlService.GetAbsoluteUrl(WebRoutes.Settings.UPDATE_USER_SETTINGS)', formData);
|
||||
if (data && data.isUpdated === true)
|
||||
notificationService.show('@_localizer["SettingsSaved"]', NotificationType.SUCCESS);
|
||||
}
|
||||
|
||||
// on form submit event
|
||||
// On form submit event.
|
||||
const handleSubmit = async function(e) {
|
||||
e.preventDefault();
|
||||
await handleSaveUserSettingsAsync();
|
||||
};
|
||||
|
||||
// on pagination checkbox change, update the enabled state of the items per page input
|
||||
// On pagination checkbox change, update the enabled state of the items per page input.
|
||||
const handlePaginationCheckboxChange = function() {
|
||||
updateItemsPerPageEnabledState();
|
||||
};
|
||||
|
||||
// add listeners
|
||||
// Add listeners.
|
||||
form.addEventListener('submit', handleSubmit);
|
||||
checkboxIsPaginationEnabled.addEventListener('change', handlePaginationCheckboxChange);
|
||||
document.addEventListener('DOMContentLoaded', InitializeAsync);
|
||||
|
||||
// register cleanup for these listeners
|
||||
// Register cleanup for these listeners.
|
||||
cleanupFunctions.push(() => {
|
||||
form.removeEventListener('submit', handleSubmit);
|
||||
checkboxIsPaginationEnabled.removeEventListener('change', handlePaginationCheckboxChange);
|
||||
@@ -161,7 +193,7 @@
|
||||
await loadUserSettingsAsync();
|
||||
}
|
||||
|
||||
// store all cleanups for this view on window object using the scriptId
|
||||
// Store all cleanups for this view on window object using the scriptId.
|
||||
window.viewCleanups = window.viewCleanups || {};
|
||||
window.viewCleanups['@scriptId'] = () => {
|
||||
cleanupFunctions.forEach(cleanup => cleanup());
|
||||
|
||||
Reference in new issue
Block a user