bookish-press 0.4.36 → 0.4.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  <svelte:options immutable={true} />
2
2
 
3
3
  <script>import { storage } from '../../models/Firebase';
4
- import { getCaret, getBook } from '../page/Contexts';
4
+ import { getCaret, getBook, getBase } from '../page/Contexts';
5
5
  import Figure from './Figure.svelte';
6
6
  import { getContext } from 'svelte';
7
7
  export let node;
@@ -12,6 +12,7 @@ $: url = node.getURL();
12
12
  $: description = node.getDescription();
13
13
  let caret = getCaret();
14
14
  let book = getBook();
15
+ let base = getBase();
15
16
  // Bookish editor should have passed down a way to set the active editor.
16
17
  let claimCaret = getContext('claimeditor');
17
18
  let dragging = false;
@@ -130,7 +131,7 @@ function handleClick() {
130
131
  {:else}
131
132
  <img
132
133
  class={'bookish-figure-image'}
133
- src={url.startsWith('http') ? url : 'images/' + url}
134
+ src={url.startsWith('http') ? url : `${$base}/images/${url}`}
134
135
  srcset={node.hasSmallURL()
135
136
  ? `${node.getSmallURL()} 320w, ${url} 1024w`
136
137
  : undefined}
@@ -40,13 +40,13 @@ function isInvalidChapterLink() {
40
40
  <a href={'#' + url.split(':')[1]}><Text node={content} /></a>
41
41
  {:else}
42
42
  <!-- If it is specified, include the base relative chapter ID and the label -->
43
- <a href={`${$base}${url.split(':')[0]}#${url.split(':')[1]}`}
43
+ <a href={`${$base}/${url.split(':')[0]}#${url.split(':')[1]}`}
44
44
  ><Text node={content} /></a
45
45
  >
46
46
  {/if}
47
47
  {:else}
48
48
  <!-- If this is internal link, make a route link to the chapter. -->
49
- <a href={`${$base}${url}`}><Text node={content} /></a>
49
+ <a href={`${$base}/${url}`}><Text node={content} /></a>
50
50
  {/if}
51
51
 
52
52
  <style>
@@ -91,8 +91,8 @@ onDestroy(() => {
91
91
  <Edition
92
92
  edition={$edition}
93
93
  base={write
94
- ? `/write/${$book.getRefID()}/${$edition.getEditionNumber()}/`
95
- : `/${$book.getSubdomain() ?? $book.getRefID()}/`}
94
+ ? `/write/${$book.getRefID()}/${$edition.getEditionNumber()}`
95
+ : `/${$book.getSubdomain() ?? $book.getRefID()}`}
96
96
  >
97
97
  <slot />
98
98
  </Edition>
@@ -81,7 +81,7 @@ $: {
81
81
  <nav class="letters">
82
82
  {#each 'abcdefghijklmnopqrstuvwxyz'.split('') as symbol, index}
83
83
  {#if symbol in letters && letter !== symbol}
84
- <Link to={$base + 'index/' + symbol}>{symbol}</Link>
84
+ <Link to="{$base}/index/{symbol}">{symbol}</Link>
85
85
  {:else if letter === symbol}
86
86
  <strong
87
87
  ><span style="font-size: 200%">{symbol}</span
@@ -122,7 +122,7 @@ $: {
122
122
  {/if}</ChapterNumber
123
123
  >
124
124
  <ChapterTitle
125
- link={`${$base}${chapterID}?word=${word}`}
125
+ link={`${$base}/${chapterID}?word=${word}`}
126
126
  >{$edition.getChapterName(
127
127
  chapterID
128
128
  )}</ChapterTitle
@@ -1,9 +1,14 @@
1
- <script>export let url;
1
+ <script>import { getBase } from './Contexts';
2
+ export let url;
2
3
  export let alt;
4
+ let base = getBase();
3
5
  </script>
4
6
 
5
7
  <figure class={'media-preview'}>
6
- <img src={url} {alt} />
8
+ <img
9
+ src={url.startsWith('http') ? url : `${$base}/images/small/${url}`}
10
+ {alt}
11
+ />
7
12
  <figcaption class="credit"><slot /></figcaption>
8
13
  </figure>
9
14
 
@@ -140,7 +140,7 @@ let darkLabel = '\u263E';
140
140
  <div class="outline-headers">
141
141
  <!-- Book navigation links -->
142
142
  <div class="outline-header-nav">
143
- {#if previous !== null}<Link to={$base + previous}
143
+ {#if previous !== null}<Link to="{$base}/{previous}">
144
144
  >{previousLabel}</Link
145
145
  >{:else}<span class="outline-header-nav-disabled"
146
146
  >{previousLabel}</span
@@ -148,7 +148,7 @@ let darkLabel = '\u263E';
148
148
  &nbsp;&middot;&nbsp;
149
149
  <Link to="{$base}/">Home</Link>
150
150
  &nbsp;&middot;&nbsp;
151
- {#if next !== null}<Link to={$base + next}>{nextLabel}</Link
151
+ {#if next !== null}<Link to="{$base}/{next}">{nextLabel}</Link
152
152
  >{:else}<span class="outline-header-nav-disabled"
153
153
  >{nextLabel}</span
154
154
  >{/if}
@@ -45,7 +45,7 @@ $: {
45
45
  .toLowerCase()
46
46
  .indexOf(lowerQuery);
47
47
  results.push({
48
- link: `${$base}${chapter.getID()}?word=${match.match.toLowerCase()}&number=${index}`,
48
+ link: `${$base}/${chapter.getID()}?word=${match.match.toLowerCase()}&number=${index}`,
49
49
  left: match.left +
50
50
  match.match.substring(0, start),
51
51
  match: match.match.substring(start, start + query.length),
@@ -119,9 +119,8 @@ function addChapter() {
119
119
  <Description />
120
120
 
121
121
  <Instructions {editable}>
122
- This will appear on the <Link to={$base + 'read'}
123
- >book browsing</Link
124
- > page and in your table of contents. Write an informative description
122
+ This will appear on the <Link to="{$base}/read">book browsing</Link>
123
+ page and in your table of contents. Write an informative description
125
124
  of what your book is about.
126
125
  </Instructions>
127
126
 
@@ -255,7 +254,7 @@ function addChapter() {
255
254
 
256
255
  <PageParagraph>
257
256
  Want to print this book or generate a PDF? See <Link
258
- to={$base + 'print'}>all chapters on a single page</Link
257
+ to="{$base}/print">all chapters on a single page</Link
259
258
  > and then print or export. Long books can take some time to render.
260
259
  </PageParagraph>
261
260
 
@@ -1,15 +1,18 @@
1
1
  <script>import EmbedNode from '../../models/chapter/EmbedNode';
2
2
  import Parser from '../../models/chapter/Parser';
3
- import { getEdition } from './Contexts';
3
+ import { getBase, getEdition } from './Contexts';
4
4
  export let embed;
5
5
  let edition = getEdition();
6
+ let base = getBase();
6
7
  $: embedNode = embed === null ? null : Parser.parseEmbed($edition, embed);
7
8
  </script>
8
9
 
9
10
  {#if embedNode instanceof EmbedNode}
10
11
  <img
11
12
  style="width: 5em"
12
- src={embedNode.getSmallURL()}
13
+ src={embedNode.isLocal()
14
+ ? `${$base}/${embedNode.getSmallURL()}`
15
+ : embedNode.getSmallURL()}
13
16
  alt={embedNode.getDescription()}
14
17
  />
15
18
  {/if}
@@ -53,8 +53,9 @@ function moveDown() {
53
53
  <ChapterNumber>{'Chapter ' + number}</ChapterNumber>
54
54
  {/if}
55
55
  <ChapterTitle
56
- link={forthcoming && !editable ? undefined : `${$base}${chapterID}`}
57
- >{title}</ChapterTitle
56
+ link={forthcoming && !editable
57
+ ? undefined
58
+ : `${$base}/${chapterID}`}>{title}</ChapterTitle
58
59
  >
59
60
  <p><Muted><em><slot name="annotation" /></em></Muted></p>
60
61
  </td>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bookish-press",
3
3
  "private": false,
4
- "version": "0.4.36",
4
+ "version": "0.4.38",
5
5
  "type": "module",
6
6
  "description": "A platform for reading and writing readable, accessible, beautiful online books.",
7
7
  "license": "MIT",