Skip to content

Commit

Permalink
Rename package for publish
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeShkurko committed Mar 5, 2021
1 parent 2c42d52 commit 47a5069
Show file tree
Hide file tree
Showing 49 changed files with 128 additions and 135 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# dart-epub
[![Build Status](https://travis-ci.org/orthros/dart-epub.svg?branch=master)](https://travis-ci.org/orthros/dart-epub)
# epubx

dart-epub fork

Epub Reader and Writer for Dart inspired by [this fantastic C# Epub Reader](https://github.com/versfx/EpubReader)

Expand All @@ -9,7 +10,7 @@ This does not rely on the ```dart:io``` package in any way, so it is avilable fo
Add the package to the ```dependencies``` section of your pubspec.yaml
```
dependencies:
epub: ^2.0.0
epubx: ^3.0.0-dev.1
```

## Example
Expand Down
2 changes: 1 addition & 1 deletion example/dart_ex/example.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:io' as io;

import 'package:path/path.dart' as path;
import 'package:epub/epub.dart';
import 'package:epubx/epub.dart';

main(List<String> args) async {
//Get the epub into memory somehow
Expand Down
2 changes: 1 addition & 1 deletion example/flutter_ex/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:epub/epub.dart' as epub;
import 'package:epubx/epub.dart' as epub;
import 'package:image/image.dart' as image;

void main() => runApp(EpubWidget());
Expand Down
2 changes: 1 addition & 1 deletion example/web_ex/web/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:html';
import 'package:http/http.dart' as http;
import 'package:epub/epub.dart' as epub;
import 'package:epubx/epub.dart' as epub;

void main() async {
querySelector('#output').text = 'Your Dart app is running.';
Expand Down
2 changes: 1 addition & 1 deletion lib/epub.dart → lib/epubx.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library epub;
library epubx;

export 'src/utils/enum_from_string.dart';

Expand Down
9 changes: 6 additions & 3 deletions lib/src/epub_writer.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import 'package:archive/archive.dart';
import 'dart:convert' as convert;
import 'package:epub/epub.dart';
import 'package:epub/src/utils/zip_path_utils.dart';
import 'package:epub/src/writers/epub_package_writer.dart';
import 'package:epubx/src/utils/zip_path_utils.dart';
import 'package:epubx/src/writers/epub_package_writer.dart';

import 'entities/epub_book.dart';
import 'entities/epub_byte_content_file.dart';
import 'entities/epub_text_content_file.dart';

class EpubWriter {
static const _container_file =
Expand Down
47 changes: 17 additions & 30 deletions lib/src/readers/navigation_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:async';
import 'package:archive/archive.dart';
import 'dart:convert' as convert;
import 'package:collection/collection.dart' show IterableExtension;
import 'package:epub/src/schema/opf/epub_version.dart';
import 'package:epubx/src/schema/opf/epub_version.dart';
import 'package:xml/xml.dart' as xml;

import '../schema/navigation/epub_metadata.dart';
Expand Down Expand Up @@ -37,8 +37,8 @@ class NavigationReader {
return null;
}

var tocManifestItem = package.Manifest!.Items!
.firstWhereOrNull((EpubManifestItem item) =>
var tocManifestItem = package.Manifest!.Items!.firstWhereOrNull(
(EpubManifestItem item) =>
item.Id!.toLowerCase() == tocId.toLowerCase());
if (tocManifestItem == null) {
throw Exception(
Expand All @@ -47,9 +47,8 @@ class NavigationReader {

var tocFileEntryPath =
ZipPathUtils.combine(contentDirectoryPath, tocManifestItem.Href);
var tocFileEntry = epubArchive.files.firstWhereOrNull(
(ArchiveFile file) =>
file.name.toLowerCase() == tocFileEntryPath!.toLowerCase());
var tocFileEntry = epubArchive.files.firstWhereOrNull((ArchiveFile file) =>
file.name.toLowerCase() == tocFileEntryPath!.toLowerCase());
if (tocFileEntry == null) {
throw Exception(
'EPUB parsing error: TOC file ${tocFileEntryPath} not found in archive.');
Expand Down Expand Up @@ -85,15 +84,13 @@ class NavigationReader {
'EPUB parsing error: TOC file does not contain docTitle element.');
}

var navigationDocTitle =
readNavigationDocTitle(docTitleNode);
var navigationDocTitle = readNavigationDocTitle(docTitleNode);
result.DocTitle = navigationDocTitle;
result.DocAuthors = <EpubNavigationDocAuthor>[];
ncxNode
.findElements('docAuthor', namespace: ncxNamespace)
.forEach((xml.XmlElement docAuthorNode) {
var navigationDocAuthor =
readNavigationDocAuthor(docAuthorNode);
var navigationDocAuthor = readNavigationDocAuthor(docAuthorNode);
result.DocAuthors!.add(navigationDocAuthor);
});

Expand All @@ -119,8 +116,7 @@ class NavigationReader {
ncxNode
.findElements('navList', namespace: ncxNamespace)
.forEach((xml.XmlElement navigationListNode) {
var navigationList =
readNavigationList(navigationListNode);
var navigationList = readNavigationList(navigationListNode);
result.NavLists!.add(navigationList);
});

Expand Down Expand Up @@ -254,13 +250,11 @@ class NavigationReader {
.forEach((xml.XmlElement navigationListChildNode) {
switch (navigationListChildNode.name.local.toLowerCase()) {
case 'navlabel':
var navigationLabel =
readNavigationLabel(navigationListChildNode);
var navigationLabel = readNavigationLabel(navigationListChildNode);
result.NavigationLabels!.add(navigationLabel);
break;
case 'navtarget':
var navigationTarget =
readNavigationTarget(navigationListChildNode);
var navigationTarget = readNavigationTarget(navigationListChildNode);
result.NavigationTargets!.add(navigationTarget);
break;
}
Expand All @@ -279,8 +273,7 @@ class NavigationReader {
.whereType<xml.XmlElement>()
.forEach((xml.XmlElement navigationPointNode) {
if (navigationPointNode.name.local.toLowerCase() == 'navpoint') {
var navigationPoint =
readNavigationPoint(navigationPointNode);
var navigationPoint = readNavigationPoint(navigationPointNode);
result.Points!.add(navigationPoint);
}
});
Expand All @@ -295,8 +288,7 @@ class NavigationReader {
.whereType<xml.XmlElement>()
.forEach((xml.XmlElement pageTargetNode) {
if (pageTargetNode.name.local == 'pageTarget') {
var pageTarget =
readNavigationPageTarget(pageTargetNode);
var pageTarget = readNavigationPageTarget(pageTargetNode);
result.Targets!.add(pageTarget);
}
});
Expand Down Expand Up @@ -347,8 +339,7 @@ class NavigationReader {
result.NavigationLabels!.add(navigationLabel);
break;
case 'content':
var content =
readNavigationContent(navigationPageTargetChildNode);
var content = readNavigationContent(navigationPageTargetChildNode);
result.Content = content;
break;
}
Expand Down Expand Up @@ -390,13 +381,11 @@ class NavigationReader {
.forEach((xml.XmlElement navigationPointChildNode) {
switch (navigationPointChildNode.name.local.toLowerCase()) {
case 'navlabel':
var navigationLabel =
readNavigationLabel(navigationPointChildNode);
var navigationLabel = readNavigationLabel(navigationPointChildNode);
result.NavigationLabels!.add(navigationLabel);
break;
case 'content':
var content =
readNavigationContent(navigationPointChildNode);
var content = readNavigationContent(navigationPointChildNode);
result.Content = content;
break;
case 'navpoint':
Expand Down Expand Up @@ -450,13 +439,11 @@ class NavigationReader {
.forEach((xml.XmlElement navigationTargetChildNode) {
switch (navigationTargetChildNode.name.local.toLowerCase()) {
case 'navlabel':
var navigationLabel =
readNavigationLabel(navigationTargetChildNode);
var navigationLabel = readNavigationLabel(navigationTargetChildNode);
result.NavigationLabels!.add(navigationLabel);
break;
case 'content':
var content =
readNavigationContent(navigationTargetChildNode);
var content = readNavigationContent(navigationTargetChildNode);
result.Content = content;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/writers/epub_guide_writer.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:epub/src/schema/opf/epub_guide.dart';
import 'package:epubx/src/schema/opf/epub_guide.dart';
import 'package:xml/src/xml/builder.dart' show XmlBuilder;

class EpubGuideWriter {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/writers/epub_manifest_writer.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:epub/src/schema/opf/epub_manifest.dart';
import 'package:epubx/src/schema/opf/epub_manifest.dart';
import 'package:xml/src/xml/builder.dart' show XmlBuilder;

class EpubManifestWriter {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/writers/epub_metadata_writer.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:epub/src/schema/opf/epub_metadata.dart';
import 'package:epub/src/schema/opf/epub_version.dart';
import 'package:epubx/src/schema/opf/epub_metadata.dart';
import 'package:epubx/src/schema/opf/epub_version.dart';
import 'package:xml/src/xml/builder.dart' show XmlBuilder;

class EpubMetadataWriter {
Expand Down
10 changes: 5 additions & 5 deletions lib/src/writers/epub_package_writer.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:epub/src/schema/opf/epub_package.dart';
import 'package:epub/src/schema/opf/epub_version.dart';
import 'package:epub/src/writers/epub_guide_writer.dart';
import 'package:epub/src/writers/epub_manifest_writer.dart';
import 'package:epub/src/writers/epub_spine_writer.dart';
import 'package:epubx/src/schema/opf/epub_package.dart';
import 'package:epubx/src/schema/opf/epub_version.dart';
import 'package:epubx/src/writers/epub_guide_writer.dart';
import 'package:epubx/src/writers/epub_manifest_writer.dart';
import 'package:epubx/src/writers/epub_spine_writer.dart';
import 'package:xml/src/xml/builder.dart' show XmlBuilder;
import 'epub_metadata_writer.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/src/writers/epub_spine_writer.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:epub/src/schema/opf/epub_spine.dart';
import 'package:epubx/src/schema/opf/epub_spine.dart';
import 'package:xml/src/xml/builder.dart' show XmlBuilder;

class EpubSpineWriter {
Expand Down
10 changes: 6 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
name: epub
version: 3.0.0
author: Colin Nelson <[email protected]>
name: epubx
version: 3.0.0-dev.1
description: Epub Parser for Dart. Suitable for use on the Server, the Web, or in Flutter
homepage: https://github.com/orthros/dart-epub
homepage: https://github.com/rbcprolabs/epubx.dart

environment:
sdk: '>=2.12.0 <3.0.0'

dependencies:
archive: ^3.1.2
quiver: ^3.0.0
xml: ^5.0.2
image: ^3.0.1
collection: ^1.15.0-nullsafety.4

dev_dependencies:
test: "^1.0.0"
path: "^1.5.1"
Expand Down
4 changes: 2 additions & 2 deletions test/entities/epub_book_test.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
library epubreadertest;

import 'package:epub/epub.dart';
import 'package:epub/src/entities/epub_schema.dart';
import 'package:epubx/epub.dart';
import 'package:epubx/src/entities/epub_schema.dart';
import 'package:test/test.dart';

main() async {
Expand Down
2 changes: 1 addition & 1 deletion test/entities/epub_byte_content_file_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library epubreadertest;

import 'package:epub/epub.dart';
import 'package:epubx/epub.dart';
import 'package:test/test.dart';

main() async {
Expand Down
2 changes: 1 addition & 1 deletion test/entities/epub_chapter_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library epubreadertest;

import 'package:epub/epub.dart';
import 'package:epubx/epub.dart';
import 'package:test/test.dart';

main() async {
Expand Down
2 changes: 1 addition & 1 deletion test/entities/epub_content_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library epubreadertest;

import 'package:epub/epub.dart';
import 'package:epubx/epub.dart';
import 'package:test/test.dart';

main() async {
Expand Down
12 changes: 6 additions & 6 deletions test/entities/epub_schema_test.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
library epubreadertest;

import 'package:epub/epub.dart';
import 'package:epub/src/entities/epub_schema.dart';
import 'package:epub/src/schema/navigation/epub_navigation_doc_author.dart';
import 'package:epub/src/schema/navigation/epub_navigation_doc_title.dart';
import 'package:epub/src/schema/opf/epub_guide.dart';
import 'package:epub/src/schema/opf/epub_version.dart';
import 'package:epubx/epub.dart';
import 'package:epubx/src/entities/epub_schema.dart';
import 'package:epubx/src/schema/navigation/epub_navigation_doc_author.dart';
import 'package:epubx/src/schema/navigation/epub_navigation_doc_title.dart';
import 'package:epubx/src/schema/opf/epub_guide.dart';
import 'package:epubx/src/schema/opf/epub_version.dart';
import 'package:test/test.dart';

main() async {
Expand Down
2 changes: 1 addition & 1 deletion test/entities/epub_text_content_file_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library epubreadertest;

import 'package:epub/epub.dart';
import 'package:epubx/epub.dart';
import 'package:test/test.dart';

main() async {
Expand Down
2 changes: 1 addition & 1 deletion test/enum_string_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library epubtest;

import 'package:test/test.dart';

import 'package:epub/epub.dart';
import 'package:epubx/epub.dart';

main() {
test("Enum One", () {
Expand Down
2 changes: 1 addition & 1 deletion test/epub_image_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'dart:io' as io;
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

import 'package:epub/epub.dart';
import 'package:epubx/epub.dart';

main() async {
String fileName = "alicesAdventuresUnderGround.epub";
Expand Down
2 changes: 1 addition & 1 deletion test/epub_reader_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'dart:io' as io;
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

import 'package:epub/epub.dart';
import 'package:epubx/epub.dart';

main() async {
String fileName = "hittelOnGoldMines.epub";
Expand Down
2 changes: 1 addition & 1 deletion test/epub_writer_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library epubreadertest;

import 'dart:io' as io;

import 'package:epub/epub.dart';
import 'package:epubx/epub.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

Expand Down
Loading

0 comments on commit 47a5069

Please sign in to comment.