├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .gitignore ├── LICENSE.md ├── README.md ├── package-lock.json ├── package.json ├── packages ├── epub-press-chrome │ ├── .babelrc │ ├── CHANGELOG.md │ ├── DEBUGGING.md │ ├── DEPLOYMENT.md │ ├── README.md │ ├── app │ │ ├── _locales │ │ │ └── en │ │ │ │ └── messages.json │ │ ├── build │ │ │ ├── background.js │ │ │ └── popup.js │ │ ├── images │ │ │ ├── download-icon-128.png │ │ │ ├── download-icon-16.png │ │ │ ├── download-icon-20.png │ │ │ ├── download-icon-32.png │ │ │ ├── download-icon-white.svg │ │ │ └── gear.svg │ │ ├── manifest.json │ │ ├── popup.html │ │ ├── styles │ │ │ ├── fonts.css │ │ │ └── main.css │ │ └── vendor │ │ │ └── fonts │ │ │ ├── lato-v11-latin-regular.eot │ │ │ ├── lato-v11-latin-regular.svg │ │ │ ├── lato-v11-latin-regular.ttf │ │ │ ├── lato-v11-latin-regular.woff │ │ │ ├── lato-v11-latin-regular.woff2 │ │ │ ├── quicksand-v5-latin-700.eot │ │ │ ├── quicksand-v5-latin-700.svg │ │ │ ├── quicksand-v5-latin-700.ttf │ │ │ ├── quicksand-v5-latin-700.woff │ │ │ ├── quicksand-v5-latin-700.woff2 │ │ │ ├── quicksand-v5-latin-regular.eot │ │ │ ├── quicksand-v5-latin-regular.svg │ │ │ ├── quicksand-v5-latin-regular.ttf │ │ │ ├── quicksand-v5-latin-regular.woff │ │ │ └── quicksand-v5-latin-regular.woff2 │ ├── images │ │ ├── background-network-details.png │ │ ├── background-network-requests.png │ │ ├── console-inspector-tab.png │ │ ├── developer-mode.png │ │ ├── epub-press-extension.png │ │ └── popup-inspect.png │ ├── package-lock.json │ ├── package.json │ ├── releases │ │ ├── epub-press-0.0.1.crx │ │ ├── epub-press-0.1.0.crx │ │ ├── epub-press-0.1.1.crx │ │ ├── epub-press-0.1.2.crx │ │ ├── epub-press-0.10.0.crx │ │ ├── epub-press-0.10.1.crx │ │ ├── epub-press-0.11.0.crx │ │ ├── epub-press-0.12.0.crx │ │ ├── epub-press-0.12.1.crx │ │ ├── epub-press-0.5.0.crx │ │ ├── epub-press-0.6.0.crx │ │ ├── epub-press-0.6.1.crx │ │ ├── epub-press-0.6.2.crx │ │ ├── epub-press-0.7.0.crx │ │ ├── epub-press-0.7.1.crx │ │ ├── epub-press-0.8.0.crx │ │ └── epub-press-0.9.0.crx │ ├── scripts │ │ ├── background.js │ │ ├── browser.js │ │ ├── popup.js │ │ └── ui.js │ ├── tests │ │ ├── browser-test.js │ │ ├── index.html │ │ ├── index.js │ │ ├── mocks.js │ │ └── ui-test.js │ └── webpack.config.js ├── epub-press-js │ ├── .babelrc │ ├── .npmignore │ ├── CHANGELOG.md │ ├── DEPLOYMENT.md │ ├── README.md │ ├── build │ │ └── index.js │ ├── epub-press.js │ ├── package-lock.json │ ├── package.json │ ├── tests │ │ ├── browserTest.html │ │ ├── epub-press-test.js │ │ ├── helpers.js │ │ ├── index.html │ │ ├── index.js │ │ ├── instance-test.js │ │ └── nodeTest.js │ └── webpack.config.js └── epub-press-widgets │ ├── README.md │ ├── package.json │ ├── tests │ ├── index.html │ └── index.js │ ├── webpack.config.js │ └── widgets.js └── screenshots ├── custom-news.png └── wikitravel-guide.png /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | 10 | # Change these settings to your own preference 11 | indent_style = space 12 | indent_size = 4 13 | 14 | [*.json] 15 | indent_size = 4 16 | 17 | # We recommend you to keep these unchanged 18 | end_of_line = lf 19 | charset = utf-8 20 | trim_trailing_whitespace = true 21 | insert_final_newline = true 22 | 23 | [*.md] 24 | trim_trailing_whitespace = false 25 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | app/build/** 2 | node_modules/ 3 | **/build/*.js 4 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "es6": true, 4 | "mocha": true, 5 | "browser": true 6 | }, 7 | "globals": { 8 | "chrome": true, 9 | "$": true, 10 | "assert": true 11 | }, 12 | "ecmaFeatures": { 13 | "arrowFunctions": true 14 | }, 15 | "rules": { 16 | "no-unused-vars": 2, 17 | "no-useless-escape": 0, 18 | "indent": [2,4], 19 | "func-names": 0, 20 | "import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*test.js"]}] 21 | }, 22 | "extends": [ 23 | "eslint:recommended", 24 | "airbnb" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | ignored 3 | *.log 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |

3 | 4 | # epub-press-clients 5 | > Easy to use clients for building ebooks with [EpubPress](https://epub.press). 6 | 7 | Backend code can be found in [haroldtreen/epub-press](https://github.com/haroldtreen/epub-press). 8 | 9 | Follow us on [Twitter](https://twitter.com/Epub_Press). 10 | 11 | ## Overview 12 | EpubPress is a service for stitching articles/blogs/webpages into a customized ebook. 13 | 14 | #### 🌟 Benefits 🌟 15 | EpubPress makes reading the web more enjoyable! 16 | 17 | - Downloads your articles for offline reading. 18 | - Books are compatible with all your iPhone, Android, Kindle, Nook, etc. 19 | - Removes website boilerplate and ads. Just. Clean. Content. 20 | - Lets you group information together (eg. "News from this week", "Top 10 travel articles"). 21 | - Easy to sharing with friends. 22 | 23 | ## Packages 📦 24 | 25 | ### epub-press-chrome 26 | 27 | [![Chrome Web Store](https://img.shields.io/chrome-web-store/v/pnhdnpnnffpijjbnhnipkehhibchdeok.svg?maxAge=2592000)](https://chrome.google.com/webstore/detail/epubpress-read-the-web-of/pnhdnpnnffpijjbnhnipkehhibchdeok) 28 | [![Chrome Web Store](https://img.shields.io/chrome-web-store/d/pnhdnpnnffpijjbnhnipkehhibchdeok.svg?maxAge=2592000)](https://chrome.google.com/webstore/detail/epubpress-read-the-web-of/pnhdnpnnffpijjbnhnipkehhibchdeok) 29 | 30 | Source code for the EpubPress chrome extension. The extension allows you to build ebooks by selecting articles from your currently open tabs. 31 | 32 | **It is available on the [Chrome Store](https://chrome.google.com/webstore/detail/epubpress/pnhdnpnnffpijjbnhnipkehhibchdeok)** 33 | 34 | See the Readme [here](./packages/epub-press-chrome/README.md) 35 | 36 | ### epub-press-js 37 | 38 | [![npm](https://img.shields.io/npm/v/epub-press-js.svg?maxAge=2592000)](https://www.npmjs.com/package/epub-press-js) 39 | [![npm](https://img.shields.io/npm/dt/epub-press-js.svg?maxAge=2592000)](https://www.npmjs.com/package/epub-press-js) 40 | 41 | A javascript library for creating books with EpubPress. 42 | 43 | **It is available on [npm](https://www.npmjs.com/package/epub-press-js)** 44 | 45 | See the Readme [here](./packages/epub-press-js/README.md) 46 | 47 | ### epub-press-widgets 48 | 49 | A set of ready to use widgets for integration by publishers. Give your users the ability to download your content in an ebook. 50 | 51 | **Development/release is on the Roadmap.*** 52 | 53 | See the Readme [here](./packages/epub-press-widgets/README.md) 54 | 55 | 56 | ## Roadmap 🛣 57 | - Widgets. 58 | - Ability to share your generated creations with others. 59 | - Custom cover page. 60 | - Extra metadata (eg. author). 61 | - Detection for pages with a list of links (eg. OneTab, Feedly, RSS Feeds) and show those links. 62 | 63 | Have any awesome ideas? Suggestions? Feature requests? Would love to hear them! 64 | feedback@epub.press 65 | 66 | ## Bug Reporting 🐛 67 | Create an [issue](https://github.com/haroldtreen/epub-press-clients/issues) in Github. 68 | 69 | **OR** 70 | 71 | Send a help request to [support@epub.press](mailto:support@epub.press). 72 | Please include as much information as possible (eg. version, os, reproduction steps, screenshots) 73 | 74 | ## Acknowledgements 👏 75 | 76 | - Icon created by Picol.org (http://www.picol.org/) 77 | - Content extraction using `node-readability` (https://www.npmjs.com/package/node-readability) 78 | - epub construction using `nodepub` (https://www.npmjs.com/package/nodepub) 79 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "epub-press-chrome", 3 | "private": true, 4 | "engines": { 5 | "node": ">=0.8.0" 6 | }, 7 | "devDependencies": { 8 | "eslint": "^5.12.1", 9 | "eslint-config-airbnb": "^17.1.0", 10 | "eslint-plugin-import": "^2.14.0", 11 | "eslint-plugin-jsx-a11y": "^6.1.2", 12 | "eslint-plugin-react": "^7.12.4" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "targets": { 7 | "firefox": "60", 8 | "chrome": "60" 9 | } 10 | } 11 | ] 12 | ], 13 | "plugins": [ 14 | "@babel/plugin-transform-runtime" 15 | ] 16 | } -------------------------------------------------------------------------------- /packages/epub-press-chrome/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ### 0.12.1 4 | 5 | - Unminified to simplify extension store review process. 6 | 7 | ### 0.12.0 8 | 9 | - Removes unused permissions. 10 | 11 | ### 0.11.0 12 | 13 | - Fix for invalid filenames causing the extension to break. 14 | - Timeout for all downloads of 30 seconds. 15 | 16 | ### 0.10.2 17 | 18 | - Update file download npm module to fix failed file downloads. 19 | 20 | ### 0.10.0 21 | 22 | - Adds a progress bar. 23 | 24 | ### 0.9.0 25 | 26 | - Switches to using `epub-press-js` 27 | - Javascript is now bundled using webpack. 28 | - Files are downloaded with the given title. 29 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/DEBUGGING.md: -------------------------------------------------------------------------------- 1 | # Debugging 2 | 3 | If you run into a bug while using EpubPress on Chrome, follow these steps to collect useful debug information. 4 | 5 | ## Checking for errors 6 | 7 | EpubPress has two components, the popup and the background process. 8 | 9 | **Popup Errors** 10 | 11 | 1. Open EpubPress and right-click on the popup. 12 | 1. Select `inspect`. This opens a Chrome Inspector Window. 13 | ![popup-inspect](./images/popup-inspect.png) 14 | 1. Look at the `Console` tab for errors being raised or logged. 15 | ![console-inspector-tab](./images/console-inspector-tab.png) 16 | 17 | **Background Errors** 18 | 19 | 1. Open [chrome://extensions](chrome://extensions) and enable `Developer Mode`. 20 | ![developer-mode](./images/developer-mode.png) 21 | 1. Find `EpubPress` and click on `Background Page`. This opens an inspector for the background process. 22 | ![epub-press-extension](./images/epub-press-extension.png) 23 | 1. Look at the `Console` tab for errors being raised or logged. 24 | 1. Look at the `Network` tab to check that requests are being made to the server. 25 | ![background-network-requests](./images/background-network-requests.png) 26 | 1. If a request is returning a non `2XX` status code, click on it to get more information. 27 | ![background-network-details](./images/background-network-details.png) 28 | 1. Run the following snippet in the `Console` to view what has been stored by the extension: 29 | ```js 30 | chrome.storage.local.get(console.log) 31 | ``` 32 | 1. Run the following snippet to reset the extension state: 33 | ```js 34 | chrome.storage.local.set({ downloadState: false }) 35 | ``` 36 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/DEPLOYMENT.md: -------------------------------------------------------------------------------- 1 | # Deployment 2 | 3 | `epub-press-chrome` is a browser extension for Chrome/Firefox. 4 | 5 | To deploy a new version: 6 | 7 | - Make sure dependencies are up to date. 8 | - `npm install` 9 | - `npm run build-prod` (updates the files in `/build`) 10 | - Update the version in the `manifest.json` (following [semver](https://semver.org/)). 11 | - Make sure the manifest `homepage_url` points to the correct host. 12 | - Zip all the files in `/app` into an `app.zip`. 13 | - Upload the `app.zip` to the [Chrome store](https://chrome.google.com/webstore/developer/dashboard). 14 | - Upload the `app.zip` to the [Firefox store](https://addons.mozilla.org/en-US/developers/addons). 15 | - Update the CHANGELOG. 16 | - Create a new release on Github with an `epub-press-x.x.x.crx` file. 17 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/README.md: -------------------------------------------------------------------------------- 1 | # epub-press-chrome 2 | 3 | [![npm](https://img.shields.io/npm/v/epub-press-js.svg?maxAge=2592000)](https://www.npmjs.com/package/epub-press-js) 4 | [![npm](https://img.shields.io/npm/dt/epub-press-js.svg?maxAge=2592000)](https://www.npmjs.com/package/epub-press-js) 5 | 6 | > A browser extension for creating ebooks from your tabs! 7 | 8 | Available on the [Chrome Store](https://chrome.google.com/webstore/detail/epubpress-create-ebooks-f/pnhdnpnnffpijjbnhnipkehhibchdeok) 9 | 10 | ## Development 11 | 12 | ### Build 13 | 14 | ```bash 15 | # Development 16 | 17 | npm start 18 | # or 19 | npm run build 20 | 21 | # Production 22 | npm run build-prod 23 | ``` 24 | 25 | ### Test 26 | 27 | ``` 28 | npm test 29 | ``` 30 | 31 | ## Usage with local server 32 | 33 | 1. Download the files: 34 | `git clone https://github.com/haroldtreen/epub-press-clients`. 35 | 1. Open the extension `manifest.json`: 36 | `open epub-press-clients/packages/epub-press-chrome/app/manifest.json`. 37 | 1. Change the `homepage_url` to point to your local server: 38 | ~~`"homepage_url": "https://epub.press"`~~ --> `"homepage_url": "http://localhost:3000"` 39 | 1. Go to your extension manager: 40 | `chrome://extensions` 41 | 1. Enable `Developer Mode`: 42 | :white_check_mark: Developer Mode 43 | 1. Click `Load Unpacked Extension`. 44 | 1. Navigate to the `epub-press-clients` folder and select `epub-press-clients/packages/epub-press-chrome/app/`. 45 | 46 | Done! 47 | 48 | Another instance of EpubPress will appear. When using this version of the extension, it will use your local server for building ebooks. 49 | 50 | To learn about setting up a local server, see the [haroldtreen/epub-press](https://github.com/haroldtreen/epub-press) repo. 51 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/_locales/en/messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "appName": { 3 | "message": "EpubPress - Read the web offline", 4 | "description": "Publish custom eBooks with your favorite web content!" 5 | }, 6 | "appShortName": { 7 | "message": "EpubPress", 8 | "description": "Name of app." 9 | }, 10 | "appDescription": { 11 | "message": "Create custom ebooks from your favorite blogs and websites.", 12 | "description": "Publish custom eBooks with your favorite web content!" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/images/download-icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/images/download-icon-128.png -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/images/download-icon-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/images/download-icon-16.png -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/images/download-icon-20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/images/download-icon-20.png -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/images/download-icon-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/images/download-icon-32.png -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/images/download-icon-white.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/images/gear.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 18 | 19 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "__MSG_appName__", 3 | "short_name": "__MSG_appShortName__", 4 | "version": "0.12.1", 5 | "author": "Harold Treen", 6 | "homepage_url": "https://epub.press/", 7 | "manifest_version": 2, 8 | "description": "__MSG_appDescription__", 9 | "icons": { 10 | "16": "images/download-icon-16.png", 11 | "128": "images/download-icon-128.png" 12 | }, 13 | "default_locale": "en", 14 | "background": { 15 | "scripts": [ 16 | "build/background.js" 17 | ] 18 | }, 19 | "permissions": [ 20 | "tabs", 21 | "downloads", 22 | "storage", 23 | "http://*/", 24 | "https://*/" 25 | ], 26 | "browser_action": { 27 | "default_icon": { 28 | "20": "images/download-icon-20.png", 29 | "32": "images/download-icon-32.png" 30 | }, 31 | "default_title": "EpubPress", 32 | "default_popup": "popup.html" 33 | } 34 | } -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |
13 | 14 |

EpubPress

15 |
16 |
17 | 18 |
19 |
20 |
21 |

Title:

22 | 23 | 24 |

Description:

25 | 26 | 27 |

Select pages for your book:

28 |
29 |
30 | 31 |
32 | 33 | 34 |
35 | 36 |
37 | 38 |
39 |
40 |
41 |
42 | 43 |
44 |
45 |
46 | 47 |

EpubPress

48 |
49 |
50 |
51 |

Settings:

52 | 53 |

Filetype

54 | 58 | 59 |

Delivery Email

60 | 61 | 62 |
63 | 64 | 65 |
66 |
67 |
68 | 69 |
70 |

Sending pages...

71 | 72 | 73 |

Pressing Your Epub

74 |
75 | 76 |
77 |

78 |

Success

79 |
80 | 81 |
82 |

83 |

Failed

84 |

85 |
86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/styles/fonts.css: -------------------------------------------------------------------------------- 1 | /* lato-regular - latin */ 2 | @font-face { 3 | font-family: 'Lato'; 4 | font-style: normal; 5 | font-weight: 400; 6 | src: url('../vendor/fonts/lato-v11-latin-regular.eot'); /* IE9 Compat Modes */ 7 | src: local('Lato Regular'), local('Lato-Regular'), 8 | url('../vendor/fonts/lato-v11-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ 9 | url('../vendor/fonts/lato-v11-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */ 10 | url('../vendor/fonts/lato-v11-latin-regular.woff') format('woff'), /* Modern Browsers */ 11 | url('../vendor/fonts/lato-v11-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */ 12 | url('../vendor/fonts/lato-v11-latin-regular.svg#Lato') format('svg'); /* Legacy iOS */ 13 | } 14 | 15 | /* quicksand-regular - latin */ 16 | @font-face { 17 | font-family: 'Quicksand'; 18 | font-style: normal; 19 | font-weight: 400; 20 | src: url('../vendor/fonts/quicksand-v5-latin-regular.eot'); /* IE9 Compat Modes */ 21 | src: local('Quicksand Regular'), local('Quicksand-Regular'), 22 | url('../vendor/fonts/quicksand-v5-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ 23 | url('../vendor/fonts/quicksand-v5-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */ 24 | url('../vendor/fonts/quicksand-v5-latin-regular.woff') format('woff'), /* Modern Browsers */ 25 | url('../vendor/fonts/quicksand-v5-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */ 26 | url('../vendor/fonts/quicksand-v5-latin-regular.svg#Quicksand') format('svg'); /* Legacy iOS */ 27 | } 28 | /* quicksand-700 - latin */ 29 | @font-face { 30 | font-family: 'Quicksand'; 31 | font-style: normal; 32 | font-weight: 700; 33 | src: url('../vendor/fonts/quicksand-v5-latin-700.eot'); /* IE9 Compat Modes */ 34 | src: local('Quicksand Bold'), local('Quicksand-Bold'), 35 | url('../vendor/fonts/quicksand-v5-latin-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ 36 | url('../vendor/fonts/quicksand-v5-latin-700.woff2') format('woff2'), /* Super Modern Browsers */ 37 | url('../vendor/fonts/quicksand-v5-latin-700.woff') format('woff'), /* Modern Browsers */ 38 | url('../vendor/fonts/quicksand-v5-latin-700.ttf') format('truetype'), /* Safari, Android, iOS */ 39 | url('../vendor/fonts/quicksand-v5-latin-700.svg#Quicksand') format('svg'); /* Legacy iOS */ 40 | } 41 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/styles/main.css: -------------------------------------------------------------------------------- 1 | /* 2 | General 3 | */ 4 | 5 | body { 6 | font-family: 'Lato', sans-serif; 7 | font-weight: 400; 8 | padding: 0px; 9 | margin: 0px; 10 | width: 500px; 11 | } 12 | 13 | h1, h2, h3, h4 { 14 | font-family: 'Quicksand', sans-serif; 15 | margin-bottom: 10px; 16 | } 17 | 18 | h1 { 19 | margin-top: 10px; 20 | } 21 | 22 | h2 { 23 | font-size: 30px; 24 | } 25 | 26 | h3 { 27 | font-family: 'Quicksand', sans-serif; 28 | font-size: 18px; 29 | margin: 10px 0px; 30 | } 31 | 32 | h4 { 33 | font-size: 16px; 34 | margin-top: 0px; 35 | } 36 | 37 | .container { 38 | margin: 10px; 39 | } 40 | 41 | #title-bar { 42 | display: flex; 43 | justify-content: space-between; 44 | align-items: center; 45 | font-family: 'Quicksand', sans-serif; 46 | font-weight: bolder; 47 | color: #f6f6f6; 48 | background-color: #2a2a2a; 49 | padding: 10px 10px; 50 | } 51 | 52 | #title-bar--title > h1 { 53 | margin: 0px 0px 0px 5px; 54 | font-size: 25px; 55 | } 56 | 57 | #title-bar > #title-bar--title { 58 | align-items: center; 59 | display: flex; 60 | } 61 | 62 | /* 63 | Inputs 64 | */ 65 | 66 | select, input[type="text"] { 67 | height: 30px; 68 | width: 100%; 69 | background-color: #fafafa; 70 | border-radius: 5px; 71 | border: 1px solid #ccc; 72 | box-sizing: border-box; 73 | font-size: 14px; 74 | margin-bottom: 10px; 75 | padding: 5px; 76 | } 77 | 78 | /* 79 | Buttons 80 | */ 81 | 82 | .btn-box { 83 | height: 30px; 84 | border: 5px solid #2a2a2a; 85 | border-radius: 5px; 86 | display: flex; 87 | background-color: #2a2a2a; 88 | flex-direction: row; 89 | margin: 5px 0px; 90 | } 91 | 92 | .btn-box > button { 93 | font-family: 'Quicksand', sans-serif; 94 | width: 100%; 95 | height: 100%; 96 | border: 0px; 97 | border-radius: 5px; 98 | background-color: #2a2a2a; 99 | color: white; 100 | font-weight: bold; 101 | font-size: 14px; 102 | flex-grow: 1; 103 | } 104 | 105 | .btn-box > button:hover { 106 | background-color: #fafafa; 107 | color: #2a2a2a; 108 | } 109 | 110 | button.btn-left { 111 | border-top-right-radius: 0px; 112 | border-bottom-right-radius: 0px; 113 | border-right: 1px solid white; 114 | } 115 | 116 | button.btn-right { 117 | border-top-left-radius: 0px; 118 | border-bottom-left-radius: 0px; 119 | border-left: 1px solid white; 120 | } 121 | 122 | /* 123 | Lists 124 | */ 125 | 126 | #tab-list { 127 | margin-bottom: 20px; 128 | } 129 | 130 | .checkbox > label { 131 | display: flex; 132 | flex-direction: row; 133 | font-size: 15px; 134 | margin: 5px 0px; 135 | } 136 | 137 | input.article-checkbox { 138 | margin-right: 10px; 139 | } 140 | 141 | /* 142 | Spinner 143 | */ 144 | 145 | #downloadSpinner > h2 { 146 | color: rgba(50, 50, 50, 0.4); 147 | } 148 | 149 | #downloadSpinner > h4 { 150 | color: rgba(50, 50, 50, 0.4); 151 | } 152 | 153 | progress { 154 | margin-bottom: 30px; 155 | -webkit-appearance: none; 156 | -moz-appearance: none; 157 | appearance: none; 158 | height: 25px; 159 | width: 250px; 160 | border-radius: 5px; 161 | background-color: #eee; 162 | } 163 | 164 | progress::-webkit-progress-value { 165 | border-radius: 5px; 166 | background-color: #333; 167 | } 168 | 169 | progress::-webkit-progress-bar { 170 | border-radius: 5px; 171 | background-color: #eee; 172 | } 173 | 174 | progress::-moz-progress-bar { 175 | border-radius: 5px; 176 | background-color: #333; 177 | } 178 | 179 | /* 180 | Status Messages 181 | */ 182 | 183 | 184 | .status-msg { 185 | display: flex; 186 | flex-direction: column; 187 | align-items: center; 188 | justify-content: center; 189 | text-align: center; 190 | height: 175px; 191 | } 192 | 193 | .status-msg > h2 { 194 | margin: 0px; 195 | } 196 | 197 | .status-icon { 198 | font-size: 90px; 199 | } 200 | 201 | #alert-message { 202 | color: red; 203 | font-size: 16px; 204 | font-weight: bold; 205 | } 206 | 207 | #downloadSuccess { 208 | color: green; 209 | } 210 | 211 | #downloadFailed { 212 | color: red; 213 | margin-bottom: 20px; 214 | } 215 | 216 | /* 217 | Settings 218 | */ 219 | 220 | #settingsForm > button { 221 | margin-top: 10px; 222 | } 223 | 224 | div#settings-btn { 225 | font-size: 15px; 226 | text-align: center; 227 | style: bold; 228 | } 229 | 230 | div#settings-btn > img { 231 | width: 100%; 232 | height: 100%; 233 | } 234 | 235 | div#settings-btn { 236 | height: 30px; 237 | width: 30px; 238 | } 239 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/vendor/fonts/lato-v11-latin-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/vendor/fonts/lato-v11-latin-regular.eot -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/vendor/fonts/lato-v11-latin-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/vendor/fonts/lato-v11-latin-regular.ttf -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/vendor/fonts/lato-v11-latin-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/vendor/fonts/lato-v11-latin-regular.woff -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/vendor/fonts/lato-v11-latin-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/vendor/fonts/lato-v11-latin-regular.woff2 -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-700.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-700.eot -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-700.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-700.ttf -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-700.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-700.woff -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-700.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-700.woff2 -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-regular.eot -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-regular.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 13 | 14 | 16 | 19 | 22 | 25 | 28 | 29 | 31 | 33 | 35 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 45 | 47 | 49 | 51 | 53 | 54 | 56 | 58 | 59 | 60 | 61 | 62 | 63 | 65 | 68 | 69 | 71 | 73 | 74 | 76 | 77 | 79 | 80 | 81 | 82 | 84 | 85 | 87 | 88 | 89 | 90 | 92 | 94 | 96 | 97 | 98 | 99 | 101 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 113 | 115 | 116 | 118 | 120 | 122 | 124 | 126 | 127 | 129 | 131 | 132 | 134 | 136 | 137 | 139 | 141 | 143 | 145 | 147 | 148 | 149 | 151 | 153 | 155 | 156 | 158 | 159 | 161 | 163 | 164 | 167 | 169 | 171 | 172 | 174 | 176 | 178 | 181 | 183 | 184 | 185 | 186 | 187 | 188 | 190 | 192 | 194 | 196 | 198 | 200 | 202 | 204 | 206 | 208 | 210 | 212 | 214 | 216 | 218 | 220 | 222 | 224 | 226 | 228 | 230 | 232 | 234 | 236 | 238 | 240 | 242 | 244 | 246 | 248 | 250 | 252 | 254 | 256 | 258 | 260 | 262 | 264 | 267 | 269 | 272 | 275 | 277 | 279 | 281 | 283 | 285 | 286 | 287 | 289 | 291 | 293 | 296 | 298 | 300 | 302 | 304 | 306 | 308 | 310 | 312 | 314 | 316 | 318 | 321 | 323 | 326 | 327 | 328 | 329 | 330 | 331 | 333 | 335 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-regular.ttf -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-regular.woff -------------------------------------------------------------------------------- /packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/app/vendor/fonts/quicksand-v5-latin-regular.woff2 -------------------------------------------------------------------------------- /packages/epub-press-chrome/images/background-network-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/images/background-network-details.png -------------------------------------------------------------------------------- /packages/epub-press-chrome/images/background-network-requests.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/images/background-network-requests.png -------------------------------------------------------------------------------- /packages/epub-press-chrome/images/console-inspector-tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/images/console-inspector-tab.png -------------------------------------------------------------------------------- /packages/epub-press-chrome/images/developer-mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/images/developer-mode.png -------------------------------------------------------------------------------- /packages/epub-press-chrome/images/epub-press-extension.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/images/epub-press-extension.png -------------------------------------------------------------------------------- /packages/epub-press-chrome/images/popup-inspect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/images/popup-inspect.png -------------------------------------------------------------------------------- /packages/epub-press-chrome/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Chrome extension for epub-press", 3 | "main": "index.js", 4 | "private": true, 5 | "scripts": { 6 | "test": "cross-env ENV=test && open http://localhost:5001/tests && webpack-dev-server", 7 | "build": "cross-env ENV=development && webpack", 8 | "webpackVer": "webpack --version", 9 | "build-prod": "cross-env NODE_ENV=production && webpack", 10 | "start": "cross-env ENV=development && webpack --watch --color --progress" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/haroldtreen/epub-press-clients.git" 15 | }, 16 | "author": "EpubPress", 17 | "license": "GPL-3.0+", 18 | "bugs": { 19 | "url": "https://github.com/haroldtreen/epub-press-clients/issues" 20 | }, 21 | "homepage": "https://github.com/haroldtreen/epub-press-clients#readme", 22 | "dependencies": { 23 | "bluebird": "^3.7.2", 24 | "epub-press-js": "^0.5.0", 25 | "jquery": "^3.5.1", 26 | "sanitize-filename": "^1.6.1" 27 | }, 28 | "devDependencies": { 29 | "@babel/core": "^7.10.2", 30 | "@babel/plugin-transform-runtime": "^7.10.1", 31 | "@babel/preset-env": "^7.10.2", 32 | "@babel/runtime": "^7.10.2", 33 | "babel-loader": "^8.1.0", 34 | "chai": "^4.2.0", 35 | "cross-env": "^7.0.3", 36 | "fetch-mock": "^5.1.1", 37 | "mocha": "^6.2.3", 38 | "mocha-loader": "^2.0.1", 39 | "sinon": "^7.5.0", 40 | "webpack": "^4.43.0", 41 | "webpack-cli": "^3.3.11", 42 | "webpack-dev-server": "^3.11.0" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.0.1.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.0.1.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.1.0.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.1.0.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.1.1.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.1.1.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.1.2.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.1.2.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.10.0.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.10.0.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.10.1.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.10.1.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.11.0.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.11.0.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.12.0.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.12.0.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.12.1.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.12.1.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.5.0.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.5.0.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.6.0.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.6.0.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.6.1.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.6.1.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.6.2.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.6.2.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.7.0.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.7.0.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.7.1.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.7.1.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.8.0.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.8.0.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/releases/epub-press-0.9.0.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/packages/epub-press-chrome/releases/epub-press-0.9.0.crx -------------------------------------------------------------------------------- /packages/epub-press-chrome/scripts/background.js: -------------------------------------------------------------------------------- 1 | import EpubPress from 'epub-press-js'; 2 | import Browser from './browser'; 3 | 4 | const manifest = Browser.getManifest(); 5 | const DOWNLOAD_TIMEOUT = 300000; // 30 second timeout for downloads 6 | 7 | EpubPress.BASE_API = `${manifest.homepage_url}api/v1`; 8 | 9 | function timeoutDownload() { 10 | Browser.setLocalStorage({ downloadState: false, publishStatus: '{}' }); 11 | Browser.sendMessage({ 12 | action: 'download', 13 | status: 'failed', 14 | error: 'Download timed out', 15 | }); 16 | } 17 | 18 | Browser.onForegroundMessage((request) => { 19 | if (request.action === 'download') { 20 | Browser.setLocalStorage({ downloadState: true, publishStatus: '{}' }); 21 | const timeout = setTimeout(timeoutDownload, DOWNLOAD_TIMEOUT); 22 | 23 | Browser.getLocalStorage(['email', 'filetype']).then((state) => { 24 | const book = new EpubPress(Object.assign({}, request.book)); 25 | book.on('statusUpdate', (status) => { 26 | Browser.setLocalStorage({ publishStatus: JSON.stringify(status) }); 27 | Browser.sendMessage({ 28 | action: 'publish', 29 | progress: status.progress, 30 | message: status.message, 31 | }); 32 | }); 33 | book.publish() 34 | .then(() => { 35 | const email = state.email && state.email.trim(); 36 | const { filetype } = state; 37 | return email 38 | ? book.email(email, filetype) 39 | : Browser.download({ 40 | filename: `${book.getTitle()}.${filetype || book.getFiletype()}`, 41 | url: book.getDownloadUrl(filetype), 42 | }); 43 | }) 44 | .then(() => { 45 | clearTimeout(timeout); 46 | Browser.setLocalStorage({ downloadState: false, publishStatus: '{}' }); 47 | Browser.sendMessage({ action: 'download', status: 'complete' }); 48 | }) 49 | .catch((e) => { 50 | clearTimeout(timeout); 51 | Browser.setLocalStorage({ downloadState: false, publishStatus: '{}' }); 52 | Browser.sendMessage({ action: 'download', status: 'failed', error: e.message }); 53 | }); 54 | }); 55 | } 56 | }); 57 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/scripts/browser.js: -------------------------------------------------------------------------------- 1 | import Promise from 'bluebird'; 2 | import sanitize from 'sanitize-filename'; 3 | 4 | class Browser { 5 | static isValidUrl(url) { 6 | let matchesValid = true; 7 | let matchesInvalid = false; 8 | 9 | const invalidRegex = [/\.pdf$/i, /\.jpg$/i, /\.png$/, /\.gif$/]; 10 | const validRegex = [/^http/]; 11 | 12 | invalidRegex.forEach((regex) => { 13 | matchesInvalid = matchesInvalid || regex.test(url); 14 | }); 15 | validRegex.forEach((regex) => { 16 | matchesValid = matchesValid && regex.test(url); 17 | }); 18 | 19 | return matchesValid && !matchesInvalid; 20 | } 21 | 22 | static filterUrls(urls) { 23 | return (urls || []).filter(Browser.isValidUrl); 24 | } 25 | 26 | static isBackgroundMsg(sender) { 27 | return sender.url.indexOf('popup') < 0; 28 | } 29 | 30 | static isPopupMsg(sender) { 31 | return sender.url.indexOf('popup') > -1; 32 | } 33 | 34 | static getCurrentWindowTabs() { 35 | let promise; 36 | if (chrome) { 37 | promise = new Promise((resolve, reject) => { 38 | chrome.windows.getCurrent({ populate: true }, (currentWindow) => { 39 | if (currentWindow.tabs) { 40 | const websiteTabs = currentWindow.tabs.filter(tab => Browser.isValidUrl(tab.url)); 41 | resolve(websiteTabs); 42 | } else { 43 | reject(new Error('No tabs!')); 44 | } 45 | }); 46 | }); 47 | } else { 48 | promise = new Promise((resolve) => { 49 | resolve(null); 50 | }); 51 | } 52 | return promise; 53 | } 54 | 55 | static getTabsHtml(tabs) { 56 | const code = 'document.documentElement.outerHTML'; 57 | const htmlPromises = tabs.map( 58 | tab => new Promise((resolve) => { 59 | chrome.tabs.executeScript(tab.id, { code }, (html) => { 60 | const updatedTab = tab; 61 | if (html && html[0] && html[0].match(/html/i)) { 62 | updatedTab.html = html[0]; 63 | } else { 64 | updatedTab.html = null; 65 | } 66 | resolve(updatedTab); 67 | }); 68 | }), 69 | ); 70 | 71 | return Promise.all(htmlPromises); 72 | } 73 | 74 | static getLocalStorage(fields) { 75 | let promise; 76 | if (chrome) { 77 | promise = new Promise((resolve) => { 78 | chrome.storage.local.get(fields, (state) => { 79 | resolve(state); 80 | }); 81 | }); 82 | } 83 | return promise; 84 | } 85 | 86 | static setLocalStorage(keyValues) { 87 | chrome.storage.local.set(keyValues); 88 | } 89 | 90 | static sendMessage(...args) { 91 | chrome.runtime.sendMessage(...args); 92 | } 93 | 94 | static onBackgroundMessage(cb) { 95 | chrome.runtime.onMessage.addListener((request, sender) => { 96 | if (Browser.isBackgroundMsg(sender)) { 97 | cb(request, sender); 98 | } 99 | }); 100 | } 101 | 102 | static onForegroundMessage(cb) { 103 | chrome.runtime.onMessage.addListener((request, sender) => { 104 | if (Browser.isPopupMsg(sender)) { 105 | cb(request, sender); 106 | } 107 | }); 108 | } 109 | 110 | static download(params) { 111 | let promise; 112 | const sanitizedParams = { ...params, filename: sanitize(params.filename) }; 113 | if (chrome) { 114 | promise = new Promise((resolve, reject) => { 115 | chrome.downloads.download(sanitizedParams, (downloadId) => { 116 | const downloadListener = (downloadInfo) => { 117 | if (downloadInfo && downloadInfo.id === downloadId) { 118 | if (downloadInfo.error) { 119 | chrome.downloads.onChanged.removeListener(downloadListener); 120 | reject(downloadInfo.error); 121 | } else if ( 122 | downloadInfo.endTime 123 | || downloadInfo.state.current === 'complete' 124 | ) { 125 | chrome.downloads.onChanged.removeListener(downloadListener); 126 | resolve(); 127 | } 128 | } else { 129 | reject(chrome.runtime.lastError); 130 | } 131 | }; 132 | chrome.downloads.onChanged.addListener(downloadListener); 133 | }); 134 | }); 135 | } 136 | return promise; 137 | } 138 | 139 | static baseUrl() { 140 | return chrome.runtime.getManifest().homepage_url; 141 | } 142 | 143 | static getManifest() { 144 | return chrome.runtime.getManifest(); 145 | } 146 | 147 | static getErrorMsg(location, xhr) { 148 | let msg = location ? `${location}: ` : ''; 149 | 150 | msg 151 | += xhr.responseText 152 | || Browser.ERROR_CODES[xhr.statusText] 153 | || Browser.ERROR_CODES[xhr.status] 154 | || Browser.ERROR_CODES[xhr.current] 155 | || 'Unknown'; 156 | 157 | return msg; 158 | } 159 | } 160 | 161 | Browser.ERROR_CODES = { 162 | // Book Create Errors 163 | 0: 'Server is down. Please try again later.', 164 | 400: 'There was a problem with the request. Is EpubPress up to date?', 165 | 404: 'Resource not found.', 166 | 500: 'Unexpected server error.', 167 | 503: 'Server took too long to respond.', 168 | timeout: 'Request took too long to complete.', 169 | error: undefined, 170 | // Download Errors 171 | SERVER_FAILED: 'Server error while downloading.', 172 | SERVER_BAD_CONTENT: 'Book could not be found', 173 | }; 174 | 175 | export default Browser; 176 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/scripts/popup.js: -------------------------------------------------------------------------------- 1 | import EpubPress from 'epub-press-js'; 2 | import $ from 'jquery'; 3 | 4 | import Browser from './browser'; 5 | import UI from './ui'; 6 | 7 | const manifest = Browser.getManifest(); 8 | 9 | /* 10 | Download Form 11 | */ 12 | 13 | $('#select-all').click(() => { 14 | $('input.article-checkbox').each((index, checkbox) => { 15 | $(checkbox).prop('checked', true); 16 | }); 17 | }); 18 | 19 | $('#select-none').click(() => { 20 | $('input.article-checkbox').each((index, checkbox) => { 21 | $(checkbox).prop('checked', false); 22 | }); 23 | }); 24 | 25 | $('#download').click(() => { 26 | const selectedItems = []; 27 | $('input.article-checkbox').each((index, checkbox) => { 28 | if ($(checkbox).prop('checked')) { 29 | selectedItems.push({ 30 | url: $(checkbox).prop('value'), 31 | id: Number($(checkbox).prop('name')), 32 | }); 33 | } 34 | }); 35 | 36 | 37 | if (selectedItems.length <= 0) { 38 | $('#alert-message').text('No articles selected!'); 39 | } else { 40 | Browser.getTabsHtml(selectedItems).then((sections) => { 41 | UI.showSection('#downloadSpinner'); 42 | Browser.sendMessage({ 43 | action: 'download', 44 | book: { 45 | title: $('#book-title').val() || $('#book-title').attr('placeholder'), 46 | description: $('#book-description').val() || undefined, 47 | sections, 48 | }, 49 | }); 50 | }).catch((error) => { 51 | UI.setErrorMessage(`Could not find tab content: ${error}`); 52 | }); 53 | } 54 | }); 55 | 56 | 57 | /* 58 | Settings Management 59 | */ 60 | 61 | function setExistingSettings(cb) { 62 | Browser.getLocalStorage(['email', 'filetype']).then((state) => { 63 | $('#settings-email-text').val(state.email); 64 | $('#settings-filetype-select').val(state.filetype); 65 | cb(); 66 | }).catch((error) => { 67 | UI.setErrorMessage(`Could not load settings: ${error}`); 68 | }); 69 | } 70 | 71 | $('#settings-btn').click(() => { 72 | setExistingSettings(() => { 73 | UI.showSection('#settingsForm'); 74 | }); 75 | }); 76 | 77 | $('#settings-save-btn').click(() => { 78 | Browser.setLocalStorage({ 79 | email: $('#settings-email-text').val(), 80 | filetype: $('#settings-filetype-select').val(), 81 | }); 82 | UI.showSection('#downloadForm'); 83 | }); 84 | 85 | $('#settings-cancel-btn').click(() => { 86 | UI.showSection('#downloadForm'); 87 | }); 88 | 89 | /* 90 | Messaging 91 | */ 92 | 93 | Browser.onBackgroundMessage((request) => { 94 | if (request.action === 'download') { 95 | if (request.status === 'complete') { 96 | UI.updateStatus(100, 'Done!').then(() => { 97 | UI.showSection('#downloadSuccess'); 98 | }); 99 | } else { 100 | UI.showSection('#downloadFailed'); 101 | if (request.error) { 102 | UI.setErrorMessage(request.error); 103 | } 104 | } 105 | } else if (request.action === 'publish') { 106 | UI.updateStatus(request.progress, request.message); 107 | } 108 | }); 109 | 110 | /* 111 | Startup 112 | */ 113 | 114 | window.onload = () => { 115 | UI.initializeUi(); 116 | Browser.getLocalStorage('downloadState').then((state) => { 117 | if (state.downloadState) { 118 | Browser.getLocalStorage('publishStatus').then((publishState) => { 119 | const status = JSON.parse(publishState.publishStatus); 120 | UI.updateStatus(status.progress, status.message); 121 | UI.showSection('#downloadSpinner'); 122 | }); 123 | } else { 124 | EpubPress.checkForUpdates('epub-press-chrome', manifest.version).then((message) => { 125 | if (message) { 126 | UI.setAlertMessage(message); 127 | } 128 | }); 129 | UI.showSection('#downloadForm'); 130 | UI.initializeTabList(); 131 | } 132 | return null; 133 | }); 134 | }; 135 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/scripts/ui.js: -------------------------------------------------------------------------------- 1 | import Browser from './browser'; 2 | 3 | class UI { 4 | static initializeUi() { 5 | let date = Date(); 6 | date = date.slice(0, date.match(/\d{4}/).index + 4); 7 | document.getElementById('book-title').placeholder = `EpubPress - ${date}`; 8 | } 9 | 10 | static setErrorMessage(msg) { 11 | $('#failure-message').text(msg); 12 | } 13 | 14 | static showSection(section) { 15 | UI.SECTIONS_SELECTORS.forEach((selector) => { 16 | if (selector === section) { 17 | $(selector).show(); 18 | } else { 19 | $(selector).hide(); 20 | } 21 | }); 22 | } 23 | 24 | static setAlertMessage(message) { 25 | $('#alert-message').text(message); 26 | } 27 | 28 | static updateStatus(progress, message) { 29 | $('h4#progress-msg').text(message); 30 | if (progress) { 31 | return this.animateValueChange($('progress'), progress); 32 | } 33 | return Promise.resolve(); 34 | } 35 | 36 | static animateValueChange($el, finalValue) { 37 | return new Promise((resolve) => { 38 | const animateFrom = (currentValue) => { 39 | requestAnimationFrame(() => { 40 | if (currentValue === finalValue) { 41 | setTimeout(resolve, 100); 42 | return; 43 | } 44 | const diff = currentValue < finalValue ? 1 : -1; 45 | const newValue = diff + currentValue; 46 | $el.val(newValue); 47 | animateFrom(newValue); 48 | }); 49 | }; 50 | animateFrom($el.val()); 51 | }); 52 | } 53 | 54 | static getCheckbox(props) { 55 | const html = `
56 | 60 |
`; 61 | return html; 62 | } 63 | 64 | static initializeTabList() { 65 | Browser.getCurrentWindowTabs().then((tabs) => { 66 | tabs.forEach((tab) => { 67 | $('#tab-list').append(UI.getCheckbox({ 68 | title: tab.title, 69 | url: tab.url, 70 | id: tab.id, 71 | })); 72 | }); 73 | }).catch((error) => { 74 | UI.setErrorMessage(`Searching tabs failed: ${error}`); 75 | }); 76 | } 77 | } 78 | 79 | UI.SECTIONS_SELECTORS = [ 80 | '#downloadForm', 81 | '#settingsForm', 82 | '#downloadSpinner', 83 | '#downloadSuccess', 84 | '#downloadFailed', 85 | ]; 86 | 87 | export default UI; 88 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/tests/browser-test.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import { MockChrome } from './mocks'; 3 | import Browser from '../scripts/browser'; 4 | 5 | describe('Browser', () => { 6 | it('is a function', () => { 7 | assert.isFunction(Browser); 8 | }); 9 | 10 | it('handles failed downloads', () => { 11 | chrome = new MockChrome(); 12 | const downloadPromise = Browser.download({ 13 | filename: 'file.txt', 14 | url: 'http://www.example.com/', 15 | }); 16 | 17 | const downloadsCb = chrome.downloads.download.firstCall.args[1]; 18 | downloadsCb(1); 19 | const downloadListener = chrome.downloads.onChanged.addListener.firstCall.args[0]; 20 | 21 | downloadListener(undefined); 22 | 23 | return downloadPromise.then( 24 | () => Promise.reject( 25 | new Error('Expected download to fail when callback run with undefined'), 26 | ), 27 | (err) => { 28 | assert.instanceOf(err, Error); 29 | }, 30 | ); 31 | }); 32 | 33 | it('sanitizes filenames', () => { 34 | chrome = new MockChrome(); 35 | 36 | Browser.download({ 37 | filename: 'invalid | filename', 38 | url: 'http://www.example.com', 39 | }); 40 | 41 | const downloadInfo = chrome.downloads.download.firstCall.args[0]; 42 | console.log(downloadInfo); 43 | assert.notMatch(downloadInfo.filename, /\|/); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mocha 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/tests/index.js: -------------------------------------------------------------------------------- 1 | const context = require.context('.', true, /.+-test\.(js|jsx)$/); 2 | context.keys().forEach(context); 3 | module.exports = context; 4 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/tests/mocks.js: -------------------------------------------------------------------------------- 1 | import sinon from 'sinon'; 2 | 3 | export class MockChrome { 4 | constructor() { 5 | this.sandbox = sinon.createSandbox(); 6 | } 7 | 8 | restore() { 9 | this.sandbox.restore(); 10 | } 11 | 12 | get downloads() { 13 | return this; 14 | } 15 | 16 | get onChanged() { 17 | return this; 18 | } 19 | 20 | get runtime() { 21 | return this; 22 | } 23 | 24 | get lastError() { 25 | this.error = new Error('Chrome error'); 26 | return this.error; 27 | } 28 | 29 | get download() { 30 | this.downloadStub = this.downloadStub || this.sandbox.stub(); 31 | return this.downloadStub; 32 | } 33 | 34 | get addListener() { 35 | this.addListenerStub = this.addListenerStub || this.sandbox.stub(); 36 | return this.addListenerStub; 37 | } 38 | } 39 | 40 | export default { MockChrome }; 41 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/tests/ui-test.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import fetchMock from 'fetch-mock'; 3 | import EpubPress from 'epub-press-js'; 4 | import UI from '../scripts/ui'; 5 | 6 | describe('UI', () => { 7 | it('is a function', () => { 8 | assert.isFunction(UI); 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /packages/epub-press-chrome/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const webpack = require('webpack'); 3 | 4 | const MODULE_RULES = [ 5 | { 6 | test: /\.(js|jsx)$/, 7 | exclude: /node_modules/, 8 | loader: 'babel-loader', 9 | }, 10 | ]; 11 | 12 | let WebpackConfig; 13 | if (process.env.ENV !== 'test') { 14 | WebpackConfig = { 15 | mode: 'production', 16 | entry: { 17 | popup: ['./scripts/popup.js'], 18 | background: ['./scripts/background.js'], 19 | }, 20 | output: { 21 | filename: '[name].js', 22 | path: path.join(__dirname, 'app', 'build'), 23 | }, 24 | optimization: { 25 | minimize: false, 26 | }, 27 | module: { 28 | rules: MODULE_RULES, 29 | }, 30 | plugins: [ 31 | new webpack.DefinePlugin({ 32 | 'process.env.ENV': JSON.stringify(process.env.NODE_ENV || 'development'), 33 | }), 34 | new webpack.ProvidePlugin({ 35 | $: 'jquery', 36 | jQuery: 'jquery', 37 | }), 38 | ], 39 | resolve: { 40 | extensions: ['.js'], 41 | }, 42 | devServer: { 43 | hostname: 'localhost', 44 | port: '5000', 45 | inline: true, 46 | }, 47 | node: { 48 | fs: 'empty', 49 | }, 50 | }; 51 | } else { 52 | WebpackConfig = { 53 | mode: 'development', 54 | entry: ['fetch-mock', 'mocha-loader!./tests/index.js'], 55 | output: { 56 | filename: 'test.build.js', 57 | path: path.join(__dirname, 'tests'), 58 | }, 59 | module: { 60 | rules: MODULE_RULES, 61 | }, 62 | plugins: [ 63 | new webpack.DefinePlugin({ 64 | 'process.env.ENV': JSON.stringify(process.env.NODE_ENV || 'test'), 65 | }), 66 | ], 67 | resolve: { 68 | extensions: ['.js'], 69 | }, 70 | devServer: { 71 | port: '5001', 72 | inline: true, 73 | }, 74 | node: { 75 | fs: 'empty', 76 | }, 77 | }; 78 | } 79 | 80 | module.exports = WebpackConfig; 81 | -------------------------------------------------------------------------------- /packages/epub-press-js/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env"], 3 | "plugins": ["@babel/plugin-transform-runtime"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/epub-press-js/.npmignore: -------------------------------------------------------------------------------- 1 | tests/ 2 | -------------------------------------------------------------------------------- /packages/epub-press-js/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ### 0.5.3 4 | 5 | * Update dependencies to fix downloads failing in browser. 6 | 7 | ### 0.5.1 8 | 9 | * Fix `email` function 10 | 11 | ### 0.5.0 12 | 13 | * New methods for handling progress events: `ebook.on`, `ebook.removeListener` 14 | * Ability to get progress updates through `ebook.on('statusUpdate', () => {})` 15 | * Switch to `v1` api. Book publishes are now asynchronous. 16 | 17 | ### 0.4.0 18 | 19 | * API update for `checkForUpdates`. 20 | * Better error handling. 21 | 22 | ### 0.3.1 23 | 24 | * Fix for filetype not being used. 25 | * Fix download. 26 | * Files built properly. 27 | 28 | ### 0.3.0 29 | 30 | * `book.download()` can accept a filetype. 31 | * New `book.emailDelivery()` method for email delivery. 32 | * Change `book.checkForUpdate()` to `book.checkForUpdates()` 33 | -------------------------------------------------------------------------------- /packages/epub-press-js/DEPLOYMENT.md: -------------------------------------------------------------------------------- 1 | # Deployment 2 | 3 | `epub-press-js` is a npm package. 4 | 5 | To deploy a new version: 6 | 7 | * Make sure dependencies are up to date. 8 | * `npm install` 9 | * Update `package.json` with a new version number (following [semver](https://semver.org/)). 10 | * Update `CHANGELOG.md` with a list of changes in the new version. 11 | * `npm publish` (this also runs the `build-prod` script which will bundle everything before deploy). 12 | -------------------------------------------------------------------------------- /packages/epub-press-js/README.md: -------------------------------------------------------------------------------- 1 | # epub-press-js 2 | 3 | [![npm](https://img.shields.io/npm/v/epub-press-js.svg?maxAge=2592000)](https://www.npmjs.com/package/epub-press-js) 4 | [![npm](https://img.shields.io/npm/dt/epub-press-js.svg?maxAge=2592000)](https://www.npmjs.com/package/epub-press-js) 5 | 6 | > A javascript client for building books with [EpubPress](https://epub.press). 7 | 8 | ### Install 9 | 10 | ``` 11 | npm install --save epub-press-js 12 | ``` 13 | 14 | ### Test 15 | 16 | **Unit Tests** 17 | ``` 18 | npm test 19 | ``` 20 | 21 | **Browser Test** 22 | ``` 23 | open tests/browserTest.html 24 | ``` 25 | 26 | **NodeJS Test** 27 | ``` 28 | node tests/nodeTest.js 29 | ``` 30 | 31 | ### Build 32 | 33 | ```bash 34 | # Single build 35 | npm run-script build 36 | 37 | # Build + watch 38 | npm start 39 | ``` 40 | 41 | ### Usage 42 | 43 | ##### Browser 44 | ```html 45 | 46 | 47 | ``` 48 | 49 | ##### NodeJS 50 | ```js 51 | const EpubPress = require('epub-press-js'); 52 | ``` 53 | 54 | ##### Creating a Book 55 | 56 | ```js 57 | const ebook = new EpubPress({ 58 | title: 'Best of HackerNews', 59 | description: 'Favorite articles from HackerNews in May, 2016', 60 | sections: [ 61 | { 62 | url: 'http://medium.com/@techBlogger/why-javascript-is-dead-long-live-php', 63 | html: '

Lulz.

', 64 | } 65 | ] 66 | }); 67 | 68 | // OR 69 | 70 | const ebook = new EpubPress({ 71 | title: 'Best of HackerNews', 72 | description: 'Favorite articles from HackerNews in May, 2016', 73 | urls: [ 74 | 'http://medium.com/@techBlogger/why-js-is-dead-long-live-php' 75 | ] 76 | }); 77 | ``` 78 | 79 | ##### Publishing 80 | ```js 81 | ebook.publish().then(() => 82 | ebook.download(); // Default epub 83 | // or ebook.email('epubpress@gmail.com') 84 | ).then(() => { 85 | console.log('Success!'); 86 | }).catch((error) => { 87 | console.log(`Error: ${error}`); 88 | }); 89 | ``` 90 | 91 | ##### Checking Status 92 | ```js 93 | ebook.checkStatus().then((status) => { 94 | 95 | }).catch((error) => {}); 96 | ``` 97 | 98 | ##### Event Listening 99 | ```js 100 | const onStatusUpdate = (status) => { console.log(status.message); }; 101 | 102 | // Adding callback 103 | ebook.on('statusUpdate', onStatusUpdate); 104 | 105 | // Removing callback 106 | ebook.removeListener('statusUpdate', onStatusUpdate) 107 | ``` 108 | 109 | ##### Check for updates 110 | 111 | ```js 112 | // epub-press-js updates 113 | EpubPress.checkForUpdates().then((message) => { 114 | console.log(message); // Undefined if no update required 115 | }); 116 | 117 | // epub-press-chrome updates 118 | EpubPress.checkForUpdates('epub-press-chrome', '0.9.0').then((message) => { 119 | console.log(message); 120 | }); 121 | ``` 122 | 123 | ### API 124 | 125 | ##### **`new EpubPress(metadata) => ebook`** 126 | - `metadata.sections`: Object with the url and html for a chapter. 127 | - `metadata.urls`: Array of urls. 128 | - `metadata.title`: Title for the book. 129 | - `metadata.description`: Description for the book. 130 | - `metadata.filetype`: File format to use for downloads. 131 | 132 | ##### **`ebook.publish() => Promise`** 133 | 134 | ##### **`ebook.download(filetype) => Promise`** 135 | - `filetype`: `'mobi'` or `'epub'` (Default `'epub'`) 136 | 137 | ##### **`ebook.email(email, filetype) => Promise`** 138 | - `filetype`: `'mobi'` or `'epub'` (Default `'epub'`) 139 | - `email`: Email address to deliver ebook to. 140 | 141 | ##### **`ebook.checkStatus() => Promise => status`** 142 | - `status.progress`: Percentage complete. (0 -> 100) 143 | - `status.message`: Status message. 144 | 145 | ##### **`ebook.on('statusUpdate', (status) => {}) => callback`** 146 | - `status.progress`: Percentage complete. (0 -> 100) 147 | - `status.message`: Description of current step. 148 | 149 | ##### **`ebook.removeListener(eventName, callback)`** 150 | - `eventName`: Name of the event `callback` exists on. 151 | - `callback`: Listener to be removed. 152 | 153 | ##### **`EpubPress.checkForUpdates(clientName, clientVersion) => Promise => Update Message | undefined`** 154 | - `clientName`: EpubPress client library to check. (Default: `epub-press-js`) 155 | - `clientVersion`: Version of client. (Default: `EpubPress.VERSION`) 156 | 157 | ### Issues 158 | 159 | - Safari downloads the file as `Unknown`. You then must manually add the file extension (eg. `.epub` or `.mobi`) 160 | 161 | Feel free to report any other issues: 162 | 163 | - In the Github repo: https://github.com/haroldtreen/epub-press-clients 164 | - By email: support@epub.press 165 | 166 | ### Related 167 | 168 | - Website: https://epub.press 169 | - Chrome Extension: https://chrome.google.com/webstore/detail/epubpress-create-ebooks-f/pnhdnpnnffpijjbnhnipkehhibchdeok 170 | -------------------------------------------------------------------------------- /packages/epub-press-js/epub-press.js: -------------------------------------------------------------------------------- 1 | import Promise from 'bluebird'; 2 | import { saveAs } from 'file-saver'; 3 | 4 | import packageInfo from './package.json'; 5 | 6 | function isBrowser() { 7 | return typeof window !== 'undefined'; 8 | } 9 | 10 | function log(...args) { 11 | if (EpubPress.DEBUG) { 12 | console.log(...args); 13 | } 14 | } 15 | 16 | function isDownloadable(book) { 17 | if (!book.getId()) { 18 | throw new Error('Book has no id. Have you published?'); 19 | } 20 | } 21 | 22 | function saveFile(filename, data) { 23 | if (isBrowser()) { 24 | let file; 25 | if (typeof File === 'function') { 26 | file = new File([data], filename); 27 | } else { 28 | file = new Blob([data], { type: 'application/octet-stream' }); 29 | } 30 | saveAs(file, filename); 31 | } else { 32 | const fs = require('fs'); 33 | fs.writeFileSync(filename, data); 34 | } 35 | } 36 | 37 | function getPublishParams(bookData) { 38 | const body = { 39 | title: bookData.title, 40 | description: bookData.description, 41 | }; 42 | 43 | if (bookData.sections) { 44 | body.sections = bookData.sections; 45 | } else { 46 | body.urls = bookData.urls.slice(); 47 | } 48 | 49 | return { 50 | method: 'POST', 51 | headers: { Accept: 'application/json', 'Content-Type': 'application/json' }, 52 | body: JSON.stringify(body), 53 | }; 54 | } 55 | 56 | function trackPublishStatus(book) { 57 | return new Promise((resolve, reject) => { 58 | const trackingCallback = (checkStatusCounter) => { 59 | book.checkStatus().then((status) => { 60 | book.emit('statusUpdate', status); 61 | if (Number(status.progress) >= 100) { 62 | resolve(book); 63 | } else if (checkStatusCounter >= EpubPress.CHECK_STATUS_LIMIT) { 64 | reject(new Error(EpubPress.ERROR_CODES[503])); 65 | } else { 66 | setTimeout(trackingCallback, EpubPress.POLL_RATE, checkStatusCounter + 1); 67 | } 68 | }).catch(reject); 69 | }; 70 | trackingCallback(1); 71 | }); 72 | } 73 | 74 | function checkResponseStatus(response) { 75 | const defaultErrorMsg = EpubPress.ERROR_CODES[response.status]; 76 | if (response.status >= 200 && response.status < 300) { 77 | return response; 78 | } else if (response.body) { 79 | return response.json().then((body) => { 80 | const hasErrorMsg = body.errors && body.errors.length > 0; 81 | const errorMsg = hasErrorMsg ? body.errors[0].detail : defaultErrorMsg; 82 | return Promise.reject(new Error(errorMsg)); 83 | }); 84 | } 85 | const error = new Error(defaultErrorMsg); 86 | return Promise.reject(error); 87 | } 88 | 89 | function normalizeError(err) { 90 | const knownError = EpubPress.ERROR_CODES[err.message] || EpubPress.ERROR_CODES[err.name]; 91 | if (knownError) { 92 | return new Error(knownError); 93 | } 94 | return err; 95 | } 96 | 97 | function compareVersion(currentVersion, apiVersion) { 98 | const apiVersionNumber = Number(apiVersion.minCompatible.replace('.', '')); 99 | const currentVersionNumber = Number(currentVersion.replace('.', '')); 100 | 101 | if (apiVersionNumber > currentVersionNumber) { 102 | return apiVersion.message; 103 | } 104 | return null; 105 | } 106 | 107 | function buildQuery(params) { 108 | const query = ['email', 'filetype'].map((paramName) => 109 | params[paramName] ? `${paramName}=${encodeURIComponent(params[paramName])}` : '' 110 | ).filter(paramStr => paramStr).join('&'); 111 | return query ? `?${query}` : ''; 112 | } 113 | 114 | class EpubPress { 115 | static checkForUpdates(client = 'epub-press-js', version = EpubPress.getVersion()) { 116 | return new Promise((resolve, reject) => { 117 | fetch(EpubPress.getVersionUrl()) 118 | .then(checkResponseStatus) 119 | .then(response => response.json()) 120 | .then((versionData) => { 121 | const clientVersionData = versionData.clients[client]; 122 | if (clientVersionData) { 123 | resolve(compareVersion(version, clientVersionData)); 124 | } else { 125 | reject(new Error(`Version data for ${client} not found.`)); 126 | } 127 | }) 128 | .catch((e) => { 129 | const error = normalizeError(e); 130 | log('Version check failed', error); 131 | reject(error); 132 | }); 133 | }); 134 | } 135 | 136 | static getPublishUrl() { 137 | return this.prototype.getPublishUrl(); 138 | } 139 | 140 | static getVersionUrl() { 141 | return `${EpubPress.BASE_API}/version`; 142 | } 143 | 144 | static getVersion() { 145 | return EpubPress.VERSION; 146 | } 147 | 148 | constructor(bookData) { 149 | const date = Date().slice(0, Date().match(/\d{4}/).index + 4); 150 | const defaults = { 151 | title: `EpubPress - ${date}`, 152 | description: undefined, 153 | sections: undefined, 154 | urls: undefined, 155 | filetype: 'epub', 156 | }; 157 | 158 | this.bookData = Object.assign({}, defaults, bookData); 159 | this.events = {}; 160 | } 161 | 162 | on(eventName, callback) { 163 | if (!this.events[eventName]) { 164 | this.events[eventName] = []; 165 | } 166 | 167 | this.events[eventName].push(callback); 168 | return callback; 169 | } 170 | 171 | emit(eventName, ...args) { 172 | if (this.events[eventName]) { 173 | this.events[eventName].forEach((cb) => { 174 | cb(...args); 175 | }); 176 | } 177 | } 178 | 179 | removeListener(eventName, callback) { 180 | if (!this.events[eventName]) { 181 | return; 182 | } 183 | 184 | const index = this.events[eventName].indexOf(callback); 185 | if (index >= 0) { 186 | this.events[eventName].splice(index, 1); 187 | } 188 | } 189 | 190 | getUrls() { 191 | let bookUrls = []; 192 | const { urls, sections } = this.bookData; 193 | 194 | if (urls) { 195 | bookUrls = urls.slice(); 196 | } else if (sections) { 197 | bookUrls = sections.map((section) => section.url); 198 | } 199 | return bookUrls; 200 | } 201 | 202 | getFiletype(providedFiletype) { 203 | const filetype = providedFiletype || this.bookData.filetype; 204 | if (!filetype) { 205 | return 'epub'; 206 | } 207 | 208 | return ['mobi', 'epub'].find((type) => filetype.toLowerCase() === type) || 'epub'; 209 | } 210 | 211 | getEmail() { 212 | return this.bookData.email; 213 | } 214 | 215 | getTitle() { 216 | return this.bookData.title; 217 | } 218 | 219 | getDescription() { 220 | return this.bookData.description; 221 | } 222 | 223 | getId() { 224 | return this.bookData.id; 225 | } 226 | 227 | getStatusUrl() { 228 | return `${EpubPress.getPublishUrl()}/${this.getId()}/status`; 229 | } 230 | 231 | getPublishUrl() { 232 | return `${EpubPress.BASE_API}/books`; 233 | } 234 | 235 | getDownloadUrl(filetype = this.getFiletype()) { 236 | const query = buildQuery({ filetype }); 237 | return `${this.getPublishUrl()}/${this.getId()}/download${query}`; 238 | } 239 | 240 | getEmailUrl(email = this.getEmail(), filetype = this.getFiletype()) { 241 | const query = buildQuery({ email, filetype }); 242 | return `${this.getPublishUrl()}/${this.getId()}/email${query}`; 243 | } 244 | 245 | checkStatus() { 246 | return new Promise((resolve, reject) => { 247 | fetch(this.getStatusUrl()) 248 | .then(checkResponseStatus) 249 | .then(response => response.json()) 250 | .then((body) => { 251 | resolve(body); 252 | }) 253 | .catch((e) => { 254 | const error = normalizeError(e); 255 | reject(error); 256 | }); 257 | }); 258 | } 259 | 260 | publish() { 261 | if (this.isPublishing) { 262 | return Promise.reject(new Error('Publishing in progress')); 263 | } else if (this.getId()) { 264 | return Promise.resolve(this.getId()); 265 | } 266 | this.isPublishing = true; 267 | return new Promise((resolve, reject) => { 268 | fetch(this.getPublishUrl(), getPublishParams(this.bookData)) 269 | .then(checkResponseStatus) 270 | .then(response => response.json()) 271 | .then(({ id }) => { 272 | this.bookData.id = id; 273 | return trackPublishStatus(this).then(() => { 274 | resolve(id); 275 | }); 276 | }) 277 | .catch((e) => { 278 | this.isPublishing = false; 279 | const error = normalizeError(e); 280 | log('EbupPress: Publish failed', error); 281 | reject(error); 282 | }); 283 | }); 284 | } 285 | 286 | download(filetype) { 287 | return new Promise((resolve, reject) => { 288 | isDownloadable(this); 289 | 290 | fetch(this.getDownloadUrl(filetype)) 291 | .then(checkResponseStatus) 292 | .then((response) => { 293 | return response.blob ? response.blob() : response.buffer(); 294 | }) 295 | .then((bookFile) => { 296 | if (process.env.NODE_ENV !== 'test') { 297 | const filename = `${this.getTitle()}.${filetype || this.getFiletype()}`; 298 | saveFile(filename, bookFile); 299 | } 300 | resolve(); 301 | }) 302 | .catch((e) => { 303 | const error = normalizeError(e); 304 | log('EpubPress: Download failed', error); 305 | reject(error); 306 | }); 307 | }); 308 | } 309 | 310 | email(email, filetype) { 311 | return new Promise((resolve, reject) => { 312 | if (!email) { 313 | return reject(new Error('EpubPress: No email provided.')); 314 | } 315 | 316 | isDownloadable(this); 317 | 318 | return fetch(this.getEmailUrl(email, filetype)) 319 | .then(checkResponseStatus) 320 | .then(() => { 321 | log('EpubPress: Book delivered.'); 322 | resolve(); 323 | }) 324 | .catch((e) => { 325 | const error = normalizeError(e); 326 | log('EpubPress: Email delivery failed.'); 327 | reject(error); 328 | }); 329 | }); 330 | } 331 | } 332 | 333 | EpubPress.BASE_URL = packageInfo.baseUrl; 334 | EpubPress.BASE_API = `${EpubPress.BASE_URL}/api/v1`; 335 | 336 | EpubPress.VERSION = packageInfo.version; 337 | EpubPress.POLL_RATE = 3000; 338 | EpubPress.CHECK_STATUS_LIMIT = 40; 339 | 340 | EpubPress.ERROR_CODES = { 341 | // Book Create Errors 342 | 0: 'Server is down. Please try again later.', 343 | 'Failed to fetch': 'Server is down. Please try again later.', 344 | 'FetchError': 'Server is down. Please try again later.', 345 | 400: 'There was a problem with the request. Is EpubPress up to date?', 346 | 404: 'Resource not found.', 347 | 422: 'Request contained invalid data.', 348 | 500: 'Unexpected server error.', 349 | 503: 'Server took too long to respond.', 350 | timeout: 'Request took too long to complete.', 351 | error: undefined, 352 | // Download Errors 353 | SERVER_FAILED: 'Server error while downloading.', 354 | SERVER_BAD_CONTENT: 'Book could not be found', 355 | }; 356 | 357 | export default EpubPress; 358 | -------------------------------------------------------------------------------- /packages/epub-press-js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "epub-press-js", 3 | "version": "0.5.3", 4 | "description": "Javascript client for building books with EpubPress.", 5 | "homepage": "https://github.com/haroldtreen/epub-press-clients#readme", 6 | "baseUrl": "https://epub.press", 7 | "main": "build/index.js", 8 | "directories": { 9 | "tests": "test" 10 | }, 11 | "scripts": { 12 | "test": "export NODE_ENV=test && open http://localhost:5001/tests && webpack-dev-server", 13 | "start": "export NODE_ENV=development && webpack --watch --progress --color", 14 | "build": "export NODE_ENV=development && webpack", 15 | "build-prod": "export NODE_ENV=production && webpack --optimize-minimize --optimize-dedupe", 16 | "preversion": "npm run-script build-prod", 17 | "prepublish": "npm run build-prod" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/haroldtreen/epub-press-clients.git" 22 | }, 23 | "keywords": [ 24 | "epub", 25 | "publishing", 26 | "productivity", 27 | "client", 28 | "epubpress", 29 | "ebooks", 30 | "content", 31 | "extraction" 32 | ], 33 | "author": "EpubPress", 34 | "license": "GPL-3.0+", 35 | "bugs": { 36 | "url": "https://github.com/haroldtreen/epub-press-clients/issues" 37 | }, 38 | "devDependencies": { 39 | "@babel/core": "^7.7.4", 40 | "@babel/plugin-transform-runtime": "^7.7.4", 41 | "@babel/preset-env": "^7.7.4", 42 | "@babel/runtime": "^7.7.4", 43 | "babel-loader": "^8.0.6", 44 | "chai": "^3.5.0", 45 | "fetch-mock": "^5.13.1", 46 | "mocha": "^5.2.0", 47 | "mocha-loader": "^2.0.1", 48 | "sinon": "^7.5.0", 49 | "webpack": "^4.41.2", 50 | "webpack-cli": "^3.3.10", 51 | "webpack-dev-server": "^3.9.0" 52 | }, 53 | "dependencies": { 54 | "bluebird": "^3.4.6", 55 | "file-saver": "^1.3.3", 56 | "isomorphic-fetch": "^2.2.1" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /packages/epub-press-js/tests/browserTest.html: -------------------------------------------------------------------------------- 1 | 2 | 25 | -------------------------------------------------------------------------------- /packages/epub-press-js/tests/epub-press-test.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import fetchMock from 'fetch-mock'; 3 | 4 | import EpubPress from '../epub-press'; 5 | import packageInfo from '../package.json'; 6 | import Helpers from './helpers'; 7 | 8 | const { isError } = Helpers; 9 | 10 | describe('EpubPress', () => { 11 | describe('.BASE_URLS', () => { 12 | it('has a BASE_URL', () => { 13 | assert.equal(EpubPress.BASE_URL, packageInfo.baseUrl); 14 | }); 15 | 16 | it('has a BASE_API', () => { 17 | assert.include(EpubPress.BASE_API, EpubPress.BASE_URL); 18 | assert.include(EpubPress.BASE_API, 'api'); 19 | }); 20 | }); 21 | 22 | describe('versions', () => { 23 | const VERSION_RESPONSE = { 24 | version: '0.3.0', 25 | minCompatible: '0.8.0', 26 | message: 'An update for EpubPress is available.', 27 | clients: { 28 | 'epub-press-chrome': { 29 | minCompatible: '0.8.0', 30 | message: 'Please update epub-press-chrome', 31 | }, 32 | 'epub-press-js': { 33 | minCompatible: '0.8.0', 34 | message: 'An update for EpubPress is available.', 35 | }, 36 | }, 37 | }; 38 | 39 | describe('.checkForUpdates', () => { 40 | beforeEach(() => { 41 | fetchMock.get(EpubPress.getVersionUrl(), VERSION_RESPONSE); 42 | }); 43 | 44 | it('can detect when an update is needed', () => { 45 | EpubPress.VERSION = '0.7.0'; 46 | 47 | return EpubPress.checkForUpdates().then((result) => { 48 | assert.isTrue(fetchMock.called(EpubPress.getVersionUrl())); 49 | assert.equal(result, VERSION_RESPONSE.message); 50 | }); 51 | }); 52 | 53 | it('can detect when an update is not needed', () => { 54 | EpubPress.VERSION = '0.8.1'; 55 | 56 | return EpubPress.checkForUpdates().then((result) => { 57 | assert.isTrue(fetchMock.called(EpubPress.getVersionUrl())); 58 | assert.isFalse(!!result); 59 | }); 60 | }); 61 | 62 | it('can tell version updates for client libraries', () => 63 | EpubPress.checkForUpdates('epub-press-chrome', '0.7.0') 64 | .then((result) => { 65 | assert.isTrue(fetchMock.called(EpubPress.getVersionUrl())); 66 | assert.include(result, 'epub-press-chrome'); 67 | }) 68 | ); 69 | 70 | it('can check for client library version updates', () => 71 | EpubPress.checkForUpdates('epub-press-chrome', '0.9.0') 72 | .then((result) => { 73 | assert.isTrue(fetchMock.called(EpubPress.getVersionUrl())); 74 | assert.isFalse(!!result); 75 | }) 76 | ); 77 | 78 | it('rejects invalid clients', () => 79 | EpubPress.checkForUpdates('epub-press-iphone').then(() => 80 | Promise.reject('#checkForUpdates should reject invalid clients.') 81 | ) 82 | .catch(isError) 83 | .then((e) => { 84 | assert.include(e.message, 'epub-press-iphone'); 85 | }) 86 | ); 87 | }); 88 | }); 89 | }); 90 | -------------------------------------------------------------------------------- /packages/epub-press-js/tests/helpers.js: -------------------------------------------------------------------------------- 1 | import Promise from 'bluebird'; 2 | 3 | const Helpers = {}; 4 | 5 | Helpers.isError = (e) => { 6 | if (typeof e === 'string') { 7 | return Promise.reject(new Error(e)); 8 | } 9 | return Promise.resolve(e); 10 | }; 11 | 12 | export default Helpers; 13 | -------------------------------------------------------------------------------- /packages/epub-press-js/tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mocha 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /packages/epub-press-js/tests/index.js: -------------------------------------------------------------------------------- 1 | const context = require.context('.', true, /.+-test\.(js|jsx)$/); 2 | context.keys().forEach(context); 3 | module.exports = context; 4 | -------------------------------------------------------------------------------- /packages/epub-press-js/tests/instance-test.js: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai'; 2 | import fetchMock from 'fetch-mock'; 3 | import sinon from 'sinon'; 4 | import EpubPress from '../epub-press'; 5 | import Helpers from './helpers'; 6 | 7 | const { isError } = Helpers; 8 | 9 | const MOCK_SECTIONS = [{ 10 | url: 'https://epub.press', 11 | html: '', 12 | }, { 13 | url: 'https://google.com', 14 | html: '', 15 | }]; 16 | 17 | const MOCK_BOOK_DATA = { 18 | title: 'Title', 19 | description: 'Description', 20 | sections: MOCK_SECTIONS, 21 | }; 22 | 23 | const MOCK_STATUSES = [ 24 | { message: 'Publishing...', progress: 5 }, 25 | { message: 'Fetching HTML...', progress: 10 }, 26 | { message: 'Extracting Content...', progress: 30 }, 27 | { message: 'Fetching Images...', progress: 70 }, 28 | { message: 'Formatting HTML...', progress: 80 }, 29 | { message: 'Writting Ebook...', progress: 90 }, 30 | { message: 'Done!', progress: 100 }, 31 | ]; 32 | 33 | const MOCK_ERROR = { status: '422', detail: 'Error Message' }; 34 | const MOCK_ERROR_RESPONSE = { errors: [MOCK_ERROR] }; 35 | 36 | const EMAIL = 'epubpress@gmail.com'; 37 | const FILETYPE = 'mobi'; 38 | 39 | const DOWNLOAD_REGEX = new RegExp((`${EpubPress.getPublishUrl()}/[\\w|-]+/download`).replace(/\//g, '\/')); 40 | const EMAIL_REGEX = new RegExp((`${EpubPress.getPublishUrl()}/[\\w|-]+/email`).replace(/\//g, '\/')); 41 | 42 | const getMockBook = (props) => { 43 | const defaults = MOCK_BOOK_DATA; 44 | return Object.assign({}, defaults, props); 45 | }; 46 | 47 | const buildBook = () => { 48 | const props = getMockBook(); 49 | return new EpubPress(props); 50 | }; 51 | 52 | describe('ebook', () => { 53 | describe('constructor', () => { 54 | it('accepts sections', () => { 55 | const props = getMockBook(); 56 | const book = new EpubPress(props); 57 | const urls = book.getUrls(); 58 | 59 | MOCK_SECTIONS.forEach((section) => { 60 | assert.include(urls, section.url); 61 | }); 62 | }); 63 | 64 | it('accepts urls', () => { 65 | const props = getMockBook({ 66 | sections: undefined, 67 | urls: MOCK_SECTIONS.map(s => s.url), 68 | }); 69 | const book = new EpubPress(props); 70 | const urls = book.getUrls(); 71 | 72 | MOCK_SECTIONS.forEach((section) => { 73 | assert.include(urls, section.url); 74 | }); 75 | }); 76 | 77 | it('accepts a title', () => { 78 | const props = getMockBook({ title: 'A title' }); 79 | const book = new EpubPress(props); 80 | 81 | assert.equal(book.getTitle(), props.title); 82 | }); 83 | 84 | it('accepts a description', () => { 85 | const props = getMockBook({ description: 'Hello world' }); 86 | const book = new EpubPress(props); 87 | 88 | assert.equal(book.getDescription(), props.description); 89 | }); 90 | 91 | it('accepts an email and filetype', () => { 92 | const settings = { email: 'epubpress@gmail.com', filetype: 'mobi' }; 93 | const book = new EpubPress(getMockBook(settings)); 94 | 95 | const downloadUrl = book.getDownloadUrl(); 96 | assert.notInclude(downloadUrl, encodeURIComponent(settings.email)); 97 | assert.include(downloadUrl, encodeURIComponent(settings.filetype)); 98 | 99 | const emailUrl = book.getEmailUrl(); 100 | assert.include(emailUrl, encodeURIComponent(settings.email)); 101 | assert.include(emailUrl, encodeURIComponent(settings.filetype)); 102 | }); 103 | 104 | it('accepts a filetype', () => { 105 | const mobiBook = new EpubPress(getMockBook({ filetype: 'mobi' })); 106 | const epubBook = new EpubPress(getMockBook({ filetype: 'epub' })); 107 | const noneBook = new EpubPress(getMockBook({ filetype: '.mobi' })); 108 | 109 | assert.equal(mobiBook.getFiletype(), 'mobi'); 110 | assert.equal(epubBook.getFiletype(), 'epub'); 111 | assert.equal(noneBook.getFiletype(), 'epub'); 112 | }); 113 | }); 114 | 115 | describe('event listening', () => { 116 | describe('#on', () => { 117 | it('allows subscribing to events', () => { 118 | const book = buildBook(); 119 | const cb = () => {}; 120 | 121 | const returnVal = book.on('event', cb); 122 | 123 | assert.equal(returnVal, cb); 124 | assert.lengthOf(book.events.event, 1); 125 | }); 126 | }); 127 | 128 | describe('#removeListener', () => { 129 | it('removes listeners', () => { 130 | const book = buildBook(); 131 | const cb = () => {}; 132 | 133 | book.on('event', cb); 134 | book.removeListener('event', cb); 135 | 136 | assert.lengthOf(book.events.event, 0); 137 | }); 138 | 139 | it('ignores non used listeners', () => { 140 | const book = buildBook(); 141 | const beforeEvents = Object.values(book.events); 142 | book.removeListener('event', () => {}); 143 | const afterEvents = Object.values(book.events); 144 | 145 | assert.deepEqual(beforeEvents, afterEvents); 146 | }); 147 | }); 148 | 149 | describe('#emit', () => { 150 | it('emits events', (done) => { 151 | let calls = 0; 152 | const expectedNumCalls = 5; 153 | 154 | const book = buildBook(); 155 | const emitArgOne = 'string'; 156 | const emitArgTwo = { an: 'object' }; 157 | const cb = (argOne, argTwo) => { 158 | calls += 1; 159 | assert.equal(argOne, emitArgOne); 160 | assert.equal(argTwo, emitArgTwo); 161 | if (calls === expectedNumCalls) { 162 | done(); 163 | } 164 | }; 165 | 166 | for (let i = 0; i < expectedNumCalls; i += 1) { 167 | book.on('event', cb); 168 | } 169 | 170 | book.emit('event', emitArgOne, emitArgTwo); 171 | }); 172 | 173 | it('ignores unknown events', () => { 174 | const book = buildBook(); 175 | book.emit('event', 'string', { ob: 'ject' }); 176 | }); 177 | }); 178 | }); 179 | 180 | describe('urls', () => { 181 | const book = new EpubPress(getMockBook()); 182 | 183 | describe('#getDownloadUrl', () => { 184 | it('returns a download url', () => { 185 | book.bookData.id = 1; 186 | 187 | const downloadUrl = book.getDownloadUrl(); 188 | assert.include(downloadUrl, `${book.getPublishUrl()}/1/download`); 189 | }); 190 | 191 | it('no longer accepts an email', () => { 192 | const downloadUrl = book.getDownloadUrl({ email: EMAIL }); 193 | assert.notInclude(downloadUrl, EMAIL.split('@')[1]); 194 | }); 195 | 196 | it('accepts a filetype', () => { 197 | const downloadUrl = book.getDownloadUrl(FILETYPE); 198 | assert.include(downloadUrl, FILETYPE); 199 | }); 200 | }); 201 | 202 | describe('#getEmailUrl', () => { 203 | it('accepts an email', () => { 204 | const emailUrl = book.getEmailUrl(EMAIL); 205 | assert.include(emailUrl, encodeURIComponent(EMAIL)); 206 | }); 207 | 208 | it('accepts a filetype', () => { 209 | const emailUrl = book.getEmailUrl(EMAIL, FILETYPE); 210 | assert.include(emailUrl, FILETYPE); 211 | }); 212 | }); 213 | 214 | describe('#getPublishUrl', () => { 215 | it('returns the publish url', () => { 216 | const publishUrl = book.getPublishUrl(); 217 | assert.include(publishUrl, EpubPress.BASE_API); 218 | assert.include(publishUrl, 'books'); 219 | }); 220 | }); 221 | 222 | describe('#getStatusUrl', () => { 223 | it('returns a status url for the book', () => { 224 | const url = book.getStatusUrl(); 225 | assert.include(url, book.getId()); 226 | assert.include(url, 'status'); 227 | }); 228 | }); 229 | }); 230 | 231 | describe('books', () => { 232 | let sandbox; 233 | const MOCK_RESPONSE = { 234 | headers: { 235 | 'Access-Control-Allow-Origin': '*', 236 | 'Access-Control-Allow-Methods': 'GET, POST, PATCH, PUT, DELETE, OPTIONS', 237 | 'Access-Control-Allow-Headers': 'Origin, Content-Type, X-Auth-Token', 238 | }, 239 | body: { id: 1 }, 240 | }; 241 | const PUBLISH_URL = EpubPress.getPublishUrl(); 242 | 243 | beforeEach(() => { 244 | fetchMock.restore(); 245 | sandbox = sinon.sandbox.create(); 246 | }); 247 | 248 | afterEach(() => { 249 | sandbox.restore(); 250 | }); 251 | 252 | describe('#publish', () => { 253 | it('posts section data to EpubPress', () => { 254 | const props = getMockBook(); 255 | const book = new EpubPress(props); 256 | 257 | fetchMock.post(book.getPublishUrl(), MOCK_RESPONSE); 258 | 259 | const statusStub = sandbox 260 | .stub(book, 'checkStatus') 261 | .resolves({ message: 'Done!', progress: 100 }); 262 | 263 | return book.publish().then(() => { 264 | assert.isTrue(fetchMock.called(PUBLISH_URL)); 265 | assert.equal(fetchMock.lastUrl(PUBLISH_URL), PUBLISH_URL); 266 | assert.equal(statusStub.callCount, 1); 267 | 268 | const requestBody = JSON.parse(fetchMock.lastOptions(PUBLISH_URL).body); 269 | assert.deepEqual(requestBody, props); 270 | assert.equal(book.getId(), 1); 271 | }); 272 | }); 273 | 274 | it('handles publish errors', () => { 275 | const props = getMockBook(); 276 | const book = new EpubPress(props); 277 | 278 | fetchMock.post(PUBLISH_URL, 500); 279 | return book.publish().then(() => 280 | Promise.reject('Reject should have been called.') 281 | ) 282 | .catch(isError) 283 | .then((e) => { 284 | assert.isTrue(fetchMock.called(PUBLISH_URL)); 285 | assert.include(e.message, 'Unexpected server'); 286 | }); 287 | }); 288 | 289 | it('displays publish error responses', () => { 290 | const props = getMockBook(); 291 | const book = new EpubPress(props); 292 | 293 | fetchMock.post(PUBLISH_URL, { 294 | status: 500, 295 | body: MOCK_ERROR_RESPONSE, 296 | }); 297 | return book 298 | .publish() 299 | .then(() => Promise.reject('Publish should have rejected.')) 300 | .catch(isError) 301 | .then((e) => { 302 | assert.equal(e.message, MOCK_ERROR.detail); 303 | }); 304 | }); 305 | 306 | it('only attempts publish once', (done) => { 307 | const book = buildBook(); 308 | 309 | fetchMock.post(PUBLISH_URL, MOCK_RESPONSE); 310 | 311 | const statusStub = sandbox 312 | .stub(book, 'checkStatus') 313 | .resolves({ message: 'Done!', progress: 100 }); 314 | 315 | book.publish().then(() => { 316 | assert.lengthOf(fetchMock.calls(PUBLISH_URL), 1); 317 | assert.equal(statusStub.callCount, 1); 318 | done(); 319 | }).catch(done); 320 | book.publish().catch(() => {}); 321 | book.publish().catch(() => {}); 322 | }); 323 | 324 | it('will fail if checkStatus is called too often', () => { 325 | const book = buildBook(); 326 | fetchMock.post(PUBLISH_URL, MOCK_RESPONSE); 327 | 328 | sandbox.stub(book, 'checkStatus') 329 | .resolves({ message: 'Almost done!', progress: 90 }); 330 | sandbox.stub(EpubPress, 'POLL_RATE').value(0); 331 | sandbox.stub(EpubPress, 'CHECK_STATUS_LIMIT').value(4); 332 | 333 | return book 334 | .publish() 335 | .then(() => Promise.reject('Publish should not have resolved.')) 336 | .catch(isError) 337 | .then((error) => { 338 | assert.equal(book.checkStatus.callCount, EpubPress.CHECK_STATUS_LIMIT); 339 | assert.include(Object.values(EpubPress.ERROR_CODES), error.message); 340 | }); 341 | }); 342 | 343 | it('emits statusUpdate events', () => { 344 | const book = buildBook(); 345 | const spy = sandbox.spy(); 346 | book.on('statusUpdate', spy); 347 | 348 | fetchMock.post(PUBLISH_URL, MOCK_RESPONSE); 349 | 350 | sandbox.stub(EpubPress, 'POLL_RATE').value(0); 351 | const statusStub = sandbox.stub(book, 'checkStatus'); 352 | MOCK_STATUSES.forEach((status, index) => { 353 | statusStub.onCall(index).returns(Promise.resolve(status)); 354 | }); 355 | 356 | return book.publish().then(() => { 357 | assert.equal(spy.callCount, MOCK_STATUSES.length); 358 | assert.equal(spy.getCall(0).args[0], MOCK_STATUSES[0]); 359 | }); 360 | }); 361 | }); 362 | 363 | describe('#download', () => { 364 | let DOWNLOAD_URL; 365 | let book; 366 | let props; 367 | 368 | beforeEach(() => { 369 | props = getMockBook({ id: 1 }); 370 | book = new EpubPress(props); 371 | DOWNLOAD_URL = book.getDownloadUrl(); 372 | }); 373 | 374 | it('downloads books from EpubPress', () => { 375 | fetchMock.get(DOWNLOAD_URL, 200); 376 | 377 | return book.download().then(() => { 378 | assert.isTrue(fetchMock.called(DOWNLOAD_URL)); 379 | assert.equal(fetchMock.lastUrl(DOWNLOAD_URL), DOWNLOAD_URL); 380 | }); 381 | }); 382 | 383 | it('requests with the provided filetype', () => { 384 | fetchMock.get(DOWNLOAD_REGEX, 200); 385 | 386 | return book.download(FILETYPE).then(() => { 387 | assert.include(fetchMock.lastUrl(DOWNLOAD_REGEX), FILETYPE); 388 | }); 389 | }); 390 | 391 | it('handles download errors', () => { 392 | fetchMock.get(DOWNLOAD_URL, 404); 393 | return book.download().then(() => 394 | Promise.reject('Reject should have been called.') 395 | ) 396 | .catch(isError) 397 | .then((error) => { 398 | assert.isTrue(fetchMock.called(DOWNLOAD_URL)); 399 | assert.include(error.message, 'not found'); 400 | }); 401 | }); 402 | 403 | it('ignores download when no id is saved', () => { 404 | props = getMockBook({ id: undefined }); 405 | book = new EpubPress(props); 406 | DOWNLOAD_URL = book.getDownloadUrl(); 407 | 408 | fetchMock.get(DOWNLOAD_URL, 200); 409 | 410 | return book.download().then(() => 411 | Promise.reject('Download should only be called for books with ids') 412 | ) 413 | .catch(isError) 414 | .then((error) => { 415 | assert.isFalse(fetchMock.called(DOWNLOAD_URL)); 416 | assert.include(error.message.toLowerCase(), 'no id'); 417 | }); 418 | }); 419 | }); 420 | 421 | describe('#email', () => { 422 | let book; 423 | let props; 424 | beforeEach(() => { 425 | props = getMockBook({ id: 1 }); 426 | book = new EpubPress(props); 427 | }); 428 | 429 | it('requests with the provided email & filetype', () => { 430 | props = getMockBook({ id: 1 }); 431 | book = new EpubPress(props); 432 | 433 | fetchMock.get(EMAIL_REGEX, 200); 434 | 435 | return book.email(EMAIL, FILETYPE).then(() => { 436 | assert.isTrue(fetchMock.called(EMAIL_REGEX)); 437 | assert.include(fetchMock.lastUrl(EMAIL_REGEX), EMAIL.split('@')[1]); 438 | assert.include(fetchMock.lastUrl(EMAIL_REGEX), FILETYPE); 439 | }); 440 | }); 441 | 442 | it('rejects when the book has no id', () => { 443 | props = getMockBook({ id: undefined }); 444 | book = new EpubPress(props); 445 | 446 | return book.email(EMAIL, FILETYPE).then(() => 447 | Promise.reject('Success sending book with no id.') 448 | ).catch((err) => { 449 | assert.include(err.message.toLowerCase(), 'no id'); 450 | }); 451 | }); 452 | 453 | it('rejects when no email is provided', () => { 454 | fetchMock.get(EMAIL_REGEX, 200); 455 | 456 | return book.email().then(() => 457 | Promise.reject('Success despite no email provided.') 458 | ) 459 | .catch(isError) 460 | .then((err) => { 461 | assert.isFalse(fetchMock.called(EMAIL_REGEX)); 462 | assert.include(err.message.toLowerCase(), 'no email'); 463 | }); 464 | }); 465 | 466 | it('rejects when the server responds with an error', () => { 467 | fetchMock.get(EMAIL_REGEX, 500); 468 | 469 | return book.email(EMAIL, FILETYPE).then(() => 470 | Promise.reject('Success received when response was 500.') 471 | ) 472 | .catch(isError) 473 | .then((e) => { 474 | assert.include(e.message, 'Unexpected'); 475 | }); 476 | }); 477 | 478 | it('rejects when the book is not found', () => { 479 | fetchMock.get(EMAIL_REGEX, 404); 480 | 481 | return book.email(EMAIL, FILETYPE).then(() => 482 | Promise.reject('Success received when response was 404.') 483 | ) 484 | .catch(isError) 485 | .then((e) => { 486 | assert.include(e.message.toLowerCase(), 'not found'); 487 | }); 488 | }); 489 | }); 490 | 491 | describe('#checkStatus', () => { 492 | let book; 493 | const STATUS_RESPONSE = { message: 'Building', progress: 50 }; 494 | 495 | before(() => { 496 | const props = getMockBook({ id: 1 }); 497 | book = new EpubPress(props); 498 | }); 499 | 500 | beforeEach(() => { 501 | fetchMock.reset(); 502 | }); 503 | 504 | it('calls the endpoint', () => { 505 | const url = book.getStatusUrl(); 506 | fetchMock.get(url, STATUS_RESPONSE); 507 | 508 | return book.checkStatus().then(() => { 509 | assert.isTrue(fetchMock.called(url)); 510 | }); 511 | }); 512 | 513 | it('parses the json', () => { 514 | fetchMock.get(book.getStatusUrl(), STATUS_RESPONSE); 515 | return book.checkStatus().then((status) => { 516 | assert.deepEqual(STATUS_RESPONSE, status); 517 | }); 518 | }); 519 | 520 | it('rejects when 404 codes are returned', () => { 521 | book = new EpubPress(getMockBook({ id: 10 })); 522 | fetchMock.get(book.getStatusUrl(), 404); 523 | 524 | return book.checkStatus().then(() => 525 | Promise.reject('Promise should not resolve from 404') 526 | ) 527 | .catch(isError) 528 | .then((e) => { 529 | assert.include(e.message.toLowerCase(), 'not found'); 530 | }); 531 | }); 532 | }); 533 | }); 534 | }); 535 | -------------------------------------------------------------------------------- /packages/epub-press-js/tests/nodeTest.js: -------------------------------------------------------------------------------- 1 | const EpubPress = require('../build/index'); 2 | 3 | const book = new EpubPress({ 4 | title: 'A book', 5 | description: 'A book', 6 | urls: [ 7 | 'http://www.cbc.ca/news/canada/toronto/penny-oleksiak-coach-1.3712572', 8 | 'http://www.cbc.ca/news/canada/toronto/penny-oleksiak-coach-1.3712572', 9 | 'http://www.cbc.ca/news/canada/toronto/penny-oleksiak-coach-1.3712572', 10 | 'http://www.cbc.ca/news/canada/toronto/penny-oleksiak-coach-1.3712572', 11 | 'http://www.cbc.ca/news/canada/toronto/penny-oleksiak-coach-1.3712572', 12 | 'http://www.cbc.ca/news/canada/toronto/penny-oleksiak-coach-1.3712572', 13 | 'http://www.cbc.ca/news/canada/toronto/penny-oleksiak-coach-1.3712572', 14 | 'http://www.cbc.ca/news/canada/toronto/penny-oleksiak-coach-1.3712572', 15 | ], 16 | }); 17 | 18 | book.publish().then(() => { 19 | return book.download(); 20 | }).then(() => { 21 | console.log('done'); 22 | }).catch(console.error); 23 | 24 | book.on('statusUpdate', (status) => { 25 | console.log(status); 26 | }); 27 | -------------------------------------------------------------------------------- /packages/epub-press-js/webpack.config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const path = require('path'); 3 | const webpack = require('webpack'); 4 | 5 | const MODULE_RULES = [ 6 | { 7 | test: /\.(js|jsx)$/, 8 | exclude: /node_modules/, 9 | loader: 'babel-loader', 10 | }, 11 | ]; 12 | 13 | let WebpackConfig; 14 | if (process.env.NODE_ENV !== 'test') { 15 | WebpackConfig = { 16 | mode: 'production', 17 | entry: ['isomorphic-fetch', './epub-press.js'], 18 | output: { 19 | filename: 'index.js', 20 | path: path.join(__dirname, 'build'), 21 | library: 'EpubPress', 22 | libraryTarget: 'umd', 23 | }, 24 | module: { 25 | rules: MODULE_RULES, 26 | }, 27 | plugins: [ 28 | new webpack.DefinePlugin({ 29 | 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'), 30 | }), 31 | ], 32 | resolve: { 33 | extensions: ['.js'], 34 | }, 35 | externals: [{ 36 | fs: true, 37 | 'isomorphic-fetch': true, 38 | }], 39 | devServer: { 40 | port: '5000', 41 | inline: true, 42 | }, 43 | }; 44 | } else { 45 | WebpackConfig = { 46 | mode: 'development', 47 | entry: ['fetch-mock', 'mocha-loader!./tests/index.js'], 48 | output: { 49 | filename: 'test.build.js', 50 | path: path.join(__dirname, 'tests'), 51 | }, 52 | module: { 53 | rules: MODULE_RULES, 54 | }, 55 | plugins: [ 56 | new webpack.DefinePlugin({ 57 | 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'test'), 58 | }), 59 | ], 60 | resolve: { 61 | extensions: ['.js'], 62 | }, 63 | externals: [{ 64 | fs: true, 65 | 'isomorphic-fetch': true, 66 | }], 67 | devServer: { 68 | port: '5001', 69 | inline: true, 70 | }, 71 | }; 72 | } 73 | 74 | module.exports = WebpackConfig; 75 | -------------------------------------------------------------------------------- /packages/epub-press-widgets/README.md: -------------------------------------------------------------------------------- 1 | # epub-press-widgets 2 | 3 | A collection of widgets for easily adding EpubPress publishing to your site. 4 | 5 | ### Install 6 | ``` 7 | npm install --save epub-press-widgets 8 | ``` 9 | 10 | ### Build 11 | ``` 12 | npm run-script build 13 | ``` 14 | 15 | ### Test 16 | ``` 17 | npm test 18 | ``` 19 | 20 | ## Item Widget 21 | The item widget lets the user download the current page as an ebook. 22 | 23 | ### Usage 24 | 25 | ```js 26 | import { ItemWidget } from 'epub-press-widgets'; 27 | 28 | const item = new ItemWidget('#epub-press-item'); // Initialize the button within a container. 29 | 30 | // Listen for lifecycle events 31 | item.on('publish-start', (book) => { alert('The current webpage is being pressed!') }); 32 | item.on('publish-end', (book) => { alert('The current webpage has been published!') }); 33 | 34 | item.on('download-start', (book) => { alert('Your book is being downloaded!') }); 35 | item.on('download-end', (book) => { alert('Thanks for reading!') }); 36 | ``` 37 | 38 | ## List Widget 39 | The list widget displays a list of links that the user can select from for creating a book. 40 | 41 | ### Usage 42 | 43 | ```js 44 | import { ListWidget } from 'epub-press-widgets'; 45 | 46 | const list = new ListWidget('#epub-press-list'); // Initialize a list within a container. 47 | 48 | // Set the items of the list 49 | list.set([ 50 | { title: 'Blog Post 1', url: 'http://blog.com/article/1'}, 51 | { title: 'Blog Post 2', url: 'http://blog.com/article/2'}, 52 | { title: 'Blog Post 3', url: 'http://blog.com/article/3'}, 53 | ]); 54 | 55 | // Dynamically add items 56 | list.add({ title: 'EpubPress', url: 'https://epub.press' }); 57 | 58 | // Dynamically remove items 59 | list.remove('Blog Post 1'); // Using title 60 | list.remove('http://blog.com/article/2'); // Usiing url 61 | 62 | // Listen for events 63 | list.on('publish-start', (book) => { 64 | alert('Your book will be ready in a bit!'); 65 | }); 66 | 67 | list.on('publish-end', (book) => { 68 | alert('Your book now exists on EpubPress'); 69 | }); 70 | 71 | list.on('download-start', (book) => { 72 | alert('Your book is being download'); 73 | }); 74 | 75 | list.on('download-end', (book) => { 76 | alert('Thanks for creating a book!'); 77 | }); 78 | ``` 79 | 80 | ## Todo 81 | - [ ] List widget 82 | - [ ] Item widget 83 | -------------------------------------------------------------------------------- /packages/epub-press-widgets/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "epub-press-widgets", 3 | "version": "0.0.1", 4 | "description": "A set of widgets for integrating EpubPress into webpages.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/haroldtreen/epub-press-clients.git" 12 | }, 13 | "keywords": [ 14 | "widget", 15 | "epubpress", 16 | "ebooks", 17 | "epub", 18 | "mobi", 19 | "productivity", 20 | "publishing", 21 | "ereading", 22 | "books" 23 | ], 24 | "author": "EpubPress", 25 | "license": "GPL-3.0+", 26 | "bugs": { 27 | "url": "https://github.com/haroldtreen/epub-press-clients/issues" 28 | }, 29 | "homepage": "https://github.com/haroldtreen/epub-press-clients#readme", 30 | "devDependencies": { 31 | "babel-core": "^6.11.4", 32 | "babel-loader": "^6.2.4", 33 | "babel-plugin-transform-runtime": "^6.9.0", 34 | "babel-preset-es2015": "^6.9.0", 35 | "chai": "^3.5.0", 36 | "fetch-mock": "^5.0.3", 37 | "mocha": "^2.5.3", 38 | "mocha-loader": "^0.7.1", 39 | "webpack": "^1.13.1" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/epub-press-widgets/tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Mocha 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /packages/epub-press-widgets/tests/index.js: -------------------------------------------------------------------------------- 1 | const context = require.context('.', true, /.+-test\.(js|jsx)$/); 2 | context.keys().forEach(context); 3 | module.exports = context; 4 | -------------------------------------------------------------------------------- /packages/epub-press-widgets/webpack.config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const path = require('path'); 3 | const webpack = require('webpack'); 4 | 5 | const MODULE_LOADERS = [ 6 | { 7 | test: /\.json$/, 8 | exclude: /node_modules/, 9 | loader: 'json-loader', 10 | }, 11 | { 12 | test: /\.(js|jsx)$/, 13 | exclude: /node_modules/, 14 | loader: 'babel-loader', 15 | }, 16 | ]; 17 | 18 | let WebpackConfig; 19 | if (process.env.ENV !== 'test') { 20 | WebpackConfig = { 21 | devtool: 'inline-source-map', 22 | entry: ['whatwg-fetch', './widgets.js'], 23 | output: { 24 | filename: 'index.js', 25 | path: path.join(__dirname, 'build'), 26 | }, 27 | module: { 28 | loaders: MODULE_LOADERS, 29 | }, 30 | plugins: [ 31 | new webpack.DefinePlugin({ 32 | 'process.env.ENV': JSON.stringify(process.env.NODE_ENV || 'development') 33 | }), 34 | ], 35 | resolve: { 36 | extensions: ['', '.js'], 37 | }, 38 | devServer: { 39 | hostname: 'localhost', 40 | port: '5000', 41 | inline: true, 42 | }, 43 | }; 44 | } else { 45 | WebpackConfig = { 46 | entry: ['fetch-mock', 'mocha!./tests/index.js'], 47 | output: { 48 | filename: 'test.build.js', 49 | path: path.join(__dirname, 'tests'), 50 | }, 51 | module: { 52 | loaders: MODULE_LOADERS, 53 | }, 54 | plugins: [ 55 | new webpack.DefinePlugin({ 56 | 'process.env.ENV': JSON.stringify(process.env.NODE_ENV || 'test'), 57 | }), 58 | ], 59 | resolve: { 60 | extensions: ['', '.js'], 61 | }, 62 | devServer: { 63 | hostname: 'localhost', 64 | port: '5001', 65 | inline: true, 66 | }, 67 | }; 68 | } 69 | 70 | module.exports = WebpackConfig; 71 | -------------------------------------------------------------------------------- /packages/epub-press-widgets/widgets.js: -------------------------------------------------------------------------------- 1 | import ListWidget from './lib/list.js'; 2 | import ItemWidget from './lib/item.js'; 3 | 4 | export default { ListWidget, ItemWidget }; 5 | -------------------------------------------------------------------------------- /screenshots/custom-news.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/screenshots/custom-news.png -------------------------------------------------------------------------------- /screenshots/wikitravel-guide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haroldtreen/epub-press-clients/c1f8b6c0d44d235cecb3214fe045aaf82a1d972d/screenshots/wikitravel-guide.png --------------------------------------------------------------------------------