Skip to content

Commit

Permalink
Bundle settings in a text file
Browse files Browse the repository at this point in the history
  • Loading branch information
cass-kazumori committed Dec 19, 2023
1 parent fce9f94 commit b59a42c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { WackyImposition } from './wacky_imposition.js';
import { PAGE_LAYOUTS, PAGE_SIZES, TARGET_BOOK_SIZE, LINE_LEN } from './constants.js';
import { updatePageLayoutInfo} from './utils/renderUtils.js';
import JSZip from 'jszip';
import { loadConfiguration } from './utils/formUtils.js';

export class Book {
/** @param { import("./models/configuration.js").Configuration } configuration */
constructor(configuration) {
Expand Down Expand Up @@ -808,9 +810,17 @@ export class Book {
console.log("After creating signatures, our filelist looks like: ",this.filelist)
}

bundleSettings() {
const currentConfig = loadConfiguration();
const settings = `Imposer settings: ${JSON.stringify(currentConfig, null, 2)}`
+ '\n\n'
+ `Link to the imposer with these settings: ${window.location.href}`
this.zip?.file("settings.txt", settings);
}

saveZip() {
console.log("Saving zip... ")
this.zip?.file("link-to-imposer-with-settings.url", `[InternetShortcut]\nURL=${window.location.href}`)
this.bundleSettings();
return this.zip.generateAsync({ type: "blob" })
.then(blob => {
console.log(" calling saveAs on ", this.filename)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/formUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const setConfigurationToUrl = (configuration) => {
* Loads settings from the URL or local storage.
* @returns { import("../models/configuration").Configuration } The configuration
*/
const loadConfiguration = () => {
export const loadConfiguration = () => {
const urlParams = toUrlParams(window.location.href);
const hasUrlParams = Object.keys(urlParams).length > 0;

Expand Down

0 comments on commit b59a42c

Please sign in to comment.