Skip to content

Commit

Permalink
Merge tag '0.9.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusCDE committed May 2, 2021
2 parents 5e8c3df + 6b09c2b commit 8cdb5b4
Show file tree
Hide file tree
Showing 24 changed files with 1,034 additions and 503 deletions.
164 changes: 82 additions & 82 deletions Cargo.lock

Large diffs are not rendered by default.

171 changes: 171 additions & 0 deletions contrib/Settings-sample.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# selected-library = 0
# Possible values: "English", "Russian".
keyboard-layout = "English"
frontlight = true
wifi = false
# Handle the Sleep Cover event.
sleep-cover = true
# Automatically enters shared mode when connected to a computer.
auto-share = false
# Defines how the back and forward buttons are mapped to the
# *page forward* and *page backward* actions.
# Possible values: "natural", "inverted".
button-scheme = "natural"
# The number of minutes of inactivity after which a device
# will automatically go to sleep. *Zero* means *never*.
auto-suspend = 30
# The delay, in days, after which a suspended device
# will power off. *Zero* means *never*.
auto-power-off = 3
# Formats used for the clock and the clock's pop-up menu.
# The available specifiers are described at:
# https://docs.rs/chrono/latest/chrono/format/strftime/index.html
time-format = "%H:%M"
date-format = "%A, %B %-d, %Y"

# You can create libraries by adding further [[libraries]] entries.
[[libraries]]
name = "On Board"
path = "/mnt/onboard"
# Possible values: "database", "filesystem".
mode = "database"
sort-method = "opened"
first-column = "title-and-author"
second-column = "progress"
thumbnail-previews = true

# This example fetcher retrieves articles through the *Wallabag* protocol.
# See `doc/ARTICLE_FETCHER.md` on how to configure it.
[[libraries.hooks]]
path = "Articles"
program = "bin/article_fetcher/article_fetcher"
sort-method = "added"
first-column = "title-and-author"
second-column = "progress"

# Remove this entry if you don't have an external card slot
# on your device.
[[libraries]]
name = "Removable"
path = "/mnt/sd"
mode = "database"
sort-method = "opened"
first-column = "title-and-author"
second-column = "progress"
thumbnail-previews = true

# Defines the images displayed when entering an intermission.
# Possible values: "logo:", "cover:", "/path/to/image/file".
# If a relative file path is given, it will be relative to
# the installation directory.
[intermissions]
suspend = "logo:"
power-off = "logo:"
share = "logo:"

[home]
# Show the address bar that display the path of the current directory.
address-bar = false
# Show the navigation bar that displays the directory hierarchy.
navigation-bar = true
# The maximum number of levels shown above the current directory.
max-levels = 3
# The size limit, in bytes, of the trash. Once the limit is reached,
# documents will be automatically removed until the invariant is restored.
max-trash-size = 33_554_432

[reader]
# How to react when a book is finished.
# Possible values: "notify", "close".
finished = "close"
# The action triggered when tapping the south-east corner.
# Possible values: "go-to-page", "next-page".
south-east-corner = "go-to-page"
# The width ratio, relative to `min(W, H) / 2`, of the strip and corner touch regions.
# Launch the *Touch Events* application to display the current touch regions.
strip-width = 0.6
corner-width = 0.4
# The path for the user's font directory.
font-path = "/mnt/onboard/fonts"
# The default serif font.
font-family = "Libertinus Serif"
# The default font size, in points.
font-size = 11.0
# The default text alignment.
# Possible values: "left", "right", "center", "justify".
text-align = "left"
# The default margin width, in millimeters.
margin-width = 8
# The default line height, in ems.
line-height = 1.2
# The file extensions of the files that will automatically be dithered
# when opened for the first time.
dithered-kinds = ["cbz", "jpg", "png", "jpeg"]

[reader.paragraph-breaker]
# The penalty for hyphenated lines. The maximum value is 10_000.
hyphen-penalty = 50
# The stretch/shrink tolerance of inter-word spaces.
stretch-tolerance = 1.26

# Refresh the screen every `regular` page turns when the colors aren't inverted,
# and every `inverted` page turns when they are. *Zero* means *never*.
[reader.refresh-rate]
regular = 8
inverted = 2

[import]
# Start the import process when the device is unplugged from a computer.
unshare-trigger = true
# Start the import process when *Plato* starts.
startup-trigger = true
# Extract the metadata of EPUB documents.
extract-epub-metadata = true
# The file extensions of the file that will be considered during the
# import process.
allowed-kinds = ["djvu", "xps", "fb2", "pdf", "oxps", "cbz", "epub"]

[dictionary]
# The default font size and margin width, for the Dictionary application.
# The units are the same as in the `[reader]` section.
font-size = 11.0
margin-width = 4

[sketch]
# The path to a directory where the sketches will be saved.
# Relative paths are relative to the current library's path.
save-path = "Sketches"
# Create a notification when a sketch is successfully saved.
notify-success = true

[sketch.pen]
# The diameter of the pen tip, in pixels.
size = 2
# Vary the diameter according to the pen's velocity.
dynamic = true
# The current pen color.
# Possible values: 0 … 255.
color = 0
# The pen speeds, in pixels per seconds, that clamps the pen's speed.
# min-speed = 36
# max-speed = 1800

[calculator]
# The default font size and margin width, for the Calculator application.
# The units are the same as in the `[reader]` section.
font-size = 8.0
margin-width = 2
# The number of remembered inputs.
history-size = 4_096

[battery]
# Warn about the battery level being low, when the level
# goes below `warn` percents.
warn = 10.0
# Shut the device down when the battery level goes below
# `power-off` percents.
power-off = 3.0

[frontlight-levels]
intensity = 0.0
warmth = 0.0
8 changes: 8 additions & 0 deletions contrib/config-sample.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Don't set the framebuffer's depth.
# unset PLATO_SET_FRAMEBUFFER_DEPTH

# Don't convert StarDict dictionaries.
# unset PLATO_CONVERT_DICTIONARIES

# Disable hyphenation.
# [ -d hyphenation-patterns ] && rm -rf hyphenation-patterns
26 changes: 26 additions & 0 deletions contrib/convert-dictionary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#! /bin/sh
# Converts a StarDict dictionary to the dictd format.
# The first argument must be the path to the IFO file.

trap 'exit 1' ERR

base=${1%.*}
bindir=bin/utils
short_name=$(grep '^bookname=' "$1" | cut -d '=' -f 2)
url=$(grep '^website=' "$1" | cut -d '=' -f 2)

echo "Converting ${short_name} (${1})."

[ -e "${base}.dict.dz" ] && "$bindir"/dictzip -d "${base}.dict.dz"

args="${base}.dict"

[ -e "${base}.syn" ] && args="$args ${base}.syn"

# shellcheck disable=SC2086
"$bindir"/sdunpack $args < "${base}.idx" > "${base}.txt"
"$bindir"/dictfmt --quiet --utf8 --index-keep-orig --headword-separator '|' -s "$short_name" -u "$url" -t "$base" < "${base}.txt"
"$bindir"/dictzip "${base}.dict"

rm "$1" "${base}.idx" "${base}.txt"
[ -e "${base}.syn" ] && rm "${base}.syn"
6 changes: 3 additions & 3 deletions contrib/firmware.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff -ru a/etc/init.d/rcS b/etc/init.d/rcS
--- a/etc/init.d/rcS 2020-11-15 11:47:09.000000000 +0100
+++ b/etc/init.d/rcS 2020-11-15 11:47:01.000000000 +0100
--- a/etc/init.d/rcS 2021-03-12 11:12:44.000000000 +0100
+++ b/etc/init.d/rcS 2021-03-12 11:12:59.000000000 +0100
@@ -78,7 +78,12 @@
FS_CORRUPT=0
dosfsck -a -w /dev/mmcblk0p3 || dosfsck -a -w /dev/mmcblk0p3 || dosfsck -a -w /dev/mmcblk0p3 || dosfsck -a -w /dev/mmcblk0p3 || FS_CORRUPT=1
Expand All @@ -15,7 +15,7 @@ diff -ru a/etc/init.d/rcS b/etc/init.d/rcS
if [ $? != 0 ] || [ $FS_CORRUPT == 1 ] || [ $FORCE_FACTORY_RESET == 1 ]; then
case $PRODUCT in
kraken|phoenix)
@@ -196,7 +201,12 @@
@@ -198,7 +203,12 @@
/bin/dbus-daemon --system &
export DBUS_SESSION_BUS_ADDRESS=`/bin/dbus-daemon --session --print-address --fork`

Expand Down
1 change: 1 addition & 0 deletions dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ find dist/keyboard-layouts -name '*-user.json' -delete
find dist/hyphenation-patterns -name '*.bounds' -delete
cp target/armv7-unknown-linux-gnueabihf/release/plato dist/
cp contrib/*.sh dist
cp contrib/Settings-sample.toml dist
cp LICENSE-AGPLv3 dist

patchelf --remove-rpath dist/libs/*
Expand Down
10 changes: 9 additions & 1 deletion doc/GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ Pick one of the [one-click install packages](https://www.mobileread.com/forums/s

The settings are saved in and read from `Settings.toml`. You can edit this file when *Plato* isn't running or is in shared mode. You can enter the shared mode by connecting your device to a computer.

The default ePUB stylesheet, `css/epub.css`, can be overridden via `css/epub-user.css`.
You can also edit `Settings-sample.toml` and rename it to `Settings.toml` before you first run *Plato*.

`plato.sh` has a few settings that you can override by with `config.sh` (use `config-sample.sh` as a starting point).

The following style sheets : `css/{epub,html,dictionary}.css` can be overridden via `css/{epub,html,dictionary}-user.css`.

The hyphenation bounds for a particular language can be overridden by creating a file name `LANGUAGE_CODE.bounds` in the `hyphenation-patterns` directory. The content of this file must the minimum number of letters before the hyphenation point relative to the beginning and end of the word, separated by a space. You can disable hyphenation all together by uncommenting the corresponding line in `config.sh`.

Dictionaries in the *StarDict* and *dictd* formats can be placed in the `dictionaries` directory. *Plato* doesn't support *StarDict* natively and will therefore convert all the *StarDict* dictionaries it might find in the `dictionaries` directory during startup. You can disable this behavior by uncommenting the corresponding line in `config.sh`.

## Upgrade

Expand Down
17 changes: 6 additions & 11 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ use crate::input::{DeviceEvent, PowerSource, ButtonCode, ButtonStatus, VAL_RELEA
use crate::input::{raw_events, device_events, usb_events, display_rotate_event, button_scheme_event};
use crate::gesture::{GestureEvent, gesture_events};
use crate::helpers::{load_json, load_toml, save_toml, IsHidden};
use crate::settings::{ButtonScheme, Settings, SETTINGS_PATH, RotationLock, InputSource};
use crate::settings::{ButtonScheme, Settings, SETTINGS_PATH, RotationLock, InputSource, IntermKind};
use crate::frontlight::{Frontlight, StandardFrontlight, NaturalFrontlight, PremixedFrontlight, FakeFrontlight};
use crate::lightsensor::{LightSensor, KoboLightSensor};
use crate::battery::{Battery, RemarkableBattery};
use crate::geom::{Rectangle, DiagDir, Region};
use crate::view::home::Home;
use crate::view::reader::Reader;
use crate::view::dialog::Dialog;
use crate::view::intermission::{Intermission, IntermKind};
use crate::view::intermission::Intermission;
use crate::view::notification::Notification;
use crate::device::{CURRENT_DEVICE, Orientation, FrontlightKind};
use crate::library::Library;
Expand Down Expand Up @@ -473,6 +473,7 @@ pub fn run() -> Result<(), Error> {
} else if tasks.iter().any(|task| task.id == TaskId::Suspend) {
resume(TaskId::Suspend, &mut tasks, view.as_mut(), &tx, &mut rq, &mut context);
} else {
view.handle_event(&Event::Suspend, &tx, &mut bus, &mut rq, &mut context);
let interm = Intermission::new(context.fb.rect(), IntermKind::Suspend, &context);
rq.add(RenderData::new(interm.id(), *interm.rect(), UpdateMode::Full));
schedule_task(TaskId::PrepareSuspend, Event::PrepareSuspend,
Expand All @@ -492,6 +493,7 @@ pub fn run() -> Result<(), Error> {
continue;
}

view.handle_event(&Event::Suspend, &tx, &mut bus, &mut rq, &mut context);
let interm = Intermission::new(context.fb.rect(), IntermKind::Suspend, &context);
rq.add(RenderData::new(interm.id(), *interm.rect(), UpdateMode::Full));
schedule_task(TaskId::PrepareSuspend, Event::PrepareSuspend,
Expand Down Expand Up @@ -781,6 +783,7 @@ pub fn run() -> Result<(), Error> {
.ok();
context.online = false;
}

let interm = Intermission::new(context.fb.rect(), IntermKind::Share, &context);
rq.add(RenderData::new(interm.id(), *interm.rect(), UpdateMode::Full));
view.children_mut().push(Box::new(interm) as Box<dyn View>);
Expand Down Expand Up @@ -1065,15 +1068,6 @@ pub fn run() -> Result<(), Error> {
ignored_bc_tx.send(ignored_buttons.clone()).unwrap();
rq.add(RenderData::new(view.id(), context.fb.rect(), UpdateMode::Gui));
},
Event::Select(EntryId::ToggleIntermissionImage(ref kind, ref path)) => {
let full_path = context.library.home.join(path);
let key = kind.key();
if context.settings.intermission_images.get(key) == Some(&full_path) {
context.settings.intermission_images.remove(key);
} else {
context.settings.intermission_images.insert(key.to_string(), full_path);
}
},
Event::Select(EntryId::Rotate(n)) if n != context.display.rotation && view.might_rotate() => {
updating.retain(|tok, _| context.fb.wait(*tok).is_err());
if let Ok(dims) = context.fb.set_rotation(n) {
Expand Down Expand Up @@ -1163,6 +1157,7 @@ pub fn run() -> Result<(), Error> {
}
let seconds = 60 * context.settings.auto_suspend as u64;
if inactive_since.elapsed() > Duration::from_secs(seconds) {
view.handle_event(&Event::Suspend, &tx, &mut bus, &mut rq, &mut context);
let interm = Intermission::new(context.fb.rect(), IntermKind::Suspend, &context);
rq.add(RenderData::new(interm.id(), *interm.rect(), UpdateMode::Full));
schedule_task(TaskId::PrepareSuspend, Event::PrepareSuspend,
Expand Down
6 changes: 6 additions & 0 deletions src/document/djvu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ impl Document for DjvuDocument {

fn set_line_height(&mut self, _line_height: f32) {
}

fn set_hyphen_penalty(&mut self, _hyphen_penalty: i32) {
}

fn set_stretch_tolerance(&mut self, _stretch_tolerance: f32) {
}
}

impl DjvuDocument {
Expand Down
10 changes: 10 additions & 0 deletions src/document/epub/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,16 @@ impl Document for EpubDocument {
self.cache.clear();
}

fn set_hyphen_penalty(&mut self, hyphen_penalty: i32) {
self.engine.set_hyphen_penalty(hyphen_penalty);
self.cache.clear();
}

fn set_stretch_tolerance(&mut self, stretch_tolerance: f32) {
self.engine.set_stretch_tolerance(stretch_tolerance);
self.cache.clear();
}

fn title(&self) -> Option<String> {
self.metadata("dc:title")
}
Expand Down
Loading

0 comments on commit 8cdb5b4

Please sign in to comment.