├── .gitignore ├── LICENSE ├── README.md ├── github-assets ├── banner.svg └── img │ ├── screenshot0.png │ ├── screenshot1.png │ ├── screenshot2.png │ ├── screenshot3.png │ └── welcomescreen.png └── src ├── RecentUrlsDB.js ├── SettingsDB.js ├── Window.js ├── assets └── img │ ├── 404.png │ ├── 404.svg │ ├── europa_logo.ico │ ├── europa_logo.png │ └── europa_logo.svg ├── build-resources ├── 512x512.png ├── icon.ico ├── icon.png ├── icon.svg └── icons │ ├── 1024x1024.png │ ├── 128x128.png │ ├── 16x16.png │ ├── 256x256.png │ ├── 32x32.png │ ├── 512x512.png │ └── 64x64.png ├── config └── jupyter_keyboard_shortcuts.json ├── css ├── 404.css ├── advanceduser.css ├── common.css ├── dialogbox.css ├── newserver.css ├── settings.css └── welcome.css ├── js ├── 404page.js ├── addUrl.js ├── advancedUser.js ├── begUser.js ├── dialogbox.js ├── modules │ └── winDecorations.js ├── newServer.js ├── preload404.js ├── settingsPage.js └── welcome.js ├── main.js ├── package-lock.json ├── package.json ├── renderer ├── 404_page │ └── 404page.html ├── add_url │ └── add_url.html ├── dialog_box │ └── dialogbox.html ├── new_server │ ├── advanceduser.html │ ├── beginneruser.html │ └── newserver.html ├── settings_page │ └── settings.html └── welcome.html ├── scripts ├── posix │ └── start_jupyter_lab.sh └── windows │ └── start_jupyter_lab.ps1 └── vendor ├── bootstrap-material-design ├── bootstrap-material-design.css └── bootstrap-material-design.js ├── bootstrap └── bootstrap.min.css ├── font-awesome ├── all.css └── all.js ├── jquery └── jquery-3.5.1.slim.js └── popper └── popper.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | build/ 3 | .idea 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | [![GPLv3 license](https://img.shields.io/badge/License-GPLv3-blue.svg)](http://perso.crans.org/besson/LICENSE.html) 6 | 7 | # What is Europa? 8 | Europa is a desktop client for JupyterLab that provides native app experience using standalone windows and keyboard shortcuts. 9 | 10 | Europa supports all the keyboard shortcuts for JupyterLab that you'd expect in a desktop application (like Ctrl+Tab to switch tabs, Ctrl+W to close a tab). More details are on the [Keyboard Shortcuts wiki page](https://github.com/suyashmahar/europa/wiki/Keyboard-shortcuts). 11 | 12 | # Installation 13 | You can either grab a portable app for linux/windows or grab OS specific installer from the [releases](https://github.com/suyashmahar/europa/releases). 14 | 15 | ### Debian/Ubuntu 16 | 17 | ``` 18 | curl -s --compressed "https://europa-sources.suyashmahar.com/debian/KEY.gpg" | sudo apt-key add - 19 | sudo curl -s --compressed -o /etc/apt/sources.list.d/europa.list "https://europa-sources.suyashmahar.com/debian/europa.list" 20 | sudo apt update && sudo apt-get install europa 21 | ``` 22 | 23 | ### Other Operating Systems 24 | Checkout the [Release Page](https://github.com/suyashmahar/europa/releases). 25 | 26 | ## CLI 27 | Europa supports a CLI interface: 28 | ``` 29 | USAGE: 30 | europa [options] 31 | 32 | OPTIONS: 33 | -u,--url Open a europa window for on start. 34 | -v,--version Print version number and exit. 35 | -h,--help Print this help message and exit. 36 | ``` 37 | 38 | # Demo 39 | (YouTube) 40 | [![Europa Demo video](https://imgur.com/download/dyLvkW8/)](https://www.youtube.com/watch?v=Qg6RwUoB6G0) 41 | 42 | # Contributing 43 | If Europa helped you in your work, please consider contributing to the project! 44 | 45 | # Gallery 46 | 47 |

48 | 49 |

50 | 51 | 52 | 53 | # License 54 | This program is distributed under the terms of the [GPL v3](https://perso.crans.org/besson/LICENSE.html), except when noted otherwise. 55 | 56 | Rights to all artworks in this program are reserved, unless noted otherwise. Copyright (c) 2020-22 Suyash Mahar. 57 | -------------------------------------------------------------------------------- /github-assets/banner.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 22 | 25 | 29 | 33 | 34 | 44 | 48 | 54 | 59 | 66 | 72 | 80 | 90 | 96 | 102 | 103 | 104 | 122 | 124 | 125 | 127 | image/svg+xml 128 | 130 | 131 | 132 | 133 | 134 | 139 | 143 | 149 | 154 | 159 | 165 | 171 | 177 | 183 | 189 | 190 | EuropaJupyterLab's Moon 206 | 207 | 208 | -------------------------------------------------------------------------------- /github-assets/img/screenshot0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/github-assets/img/screenshot0.png -------------------------------------------------------------------------------- /github-assets/img/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/github-assets/img/screenshot1.png -------------------------------------------------------------------------------- /github-assets/img/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/github-assets/img/screenshot2.png -------------------------------------------------------------------------------- /github-assets/img/screenshot3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/github-assets/img/screenshot3.png -------------------------------------------------------------------------------- /github-assets/img/welcomescreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/github-assets/img/welcomescreen.png -------------------------------------------------------------------------------- /src/RecentUrlsDB.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Store = require('electron-store') 4 | 5 | /** 6 | * Stores recently accessed URLs 7 | */ 8 | class RecentUrls extends Store { 9 | 10 | /** 11 | * Load urls or initialize to an empty array 12 | * @param {settings} settings Dictionary object for Store 13 | */ 14 | constructor (settings) { 15 | super(settings); 16 | 17 | this.urls = this.get('recentUrls') || []; 18 | } 19 | 20 | /** 21 | * Save all the Urls to a JSON file 22 | */ 23 | saveUrls() { 24 | this.set('recentUrls', this.urls); 25 | return this; 26 | } 27 | 28 | /** 29 | * Get an array of all the URLs 30 | */ 31 | getUrls() { 32 | this.urls = this.get('recentUrls') || []; 33 | return this; 34 | } 35 | 36 | /** 37 | * Adds a new URL to the database and removes the oldest if the list exceeds 38 | * maxItems number of elements 39 | * @param {String} url Url to store 40 | * @param {integer} maxItems Maximum number of urls to keep 41 | */ 42 | pushFront(url, maxItems) { 43 | /* Remove any previous recent item with same URL */ 44 | this.urls = this.urls.filter(function(a){return a !== url;}); 45 | 46 | /* Append the item */ 47 | this.urls.unshift(url); 48 | 49 | while (this.urls.length > maxItems) { 50 | this.urls.pop(); 51 | } 52 | 53 | return this.saveUrls(); 54 | } 55 | 56 | /** 57 | * Removes a url from the DB 58 | * @param {url} todo URL to remove 59 | */ 60 | remove(url) { 61 | // filter out the target url 62 | this.urls = this.urls.filter(function (elem) { 63 | return elem != url; 64 | }); 65 | 66 | return this.saveUrls(); 67 | } 68 | } 69 | 70 | module.exports = RecentUrls 71 | -------------------------------------------------------------------------------- /src/SettingsDB.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Store = require('electron-store') 4 | 5 | /** 6 | * Store and retrieve settings in dictionary format 7 | */ 8 | class SettingsDB extends Store { 9 | DEFAULT_SETTINGS = { 10 | 'show-keyboard-shortcuts-dialog': 'ask', 11 | }; 12 | 13 | /** 14 | * Load settings or initialize to the default settings 15 | * @param {settings} settings Dictionary object for Store 16 | */ 17 | constructor (settings) { 18 | super(settings); 19 | 20 | this.settings = this.get('settingsDB') || this.DEFAULT_SETTINGS; 21 | } 22 | 23 | /** 24 | * Save all the settings to a JSON file 25 | */ 26 | saveSettings(settings) { 27 | this.set('settingsDB', settings); 28 | return this; 29 | } 30 | 31 | /** 32 | * Get a dict of all the settings 33 | */ 34 | getSettings() { 35 | this.settings = this.get('settingsDB') || this.DEFAULT_SETTINGS; 36 | return this.settings; 37 | } 38 | } 39 | 40 | module.exports = SettingsDB; 41 | -------------------------------------------------------------------------------- /src/Window.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { BrowserWindow } = require('electron'); 4 | 5 | // default window settings 6 | const defaultProps = { 7 | width: 1080, 8 | height: 768, 9 | show: false, 10 | 11 | // update for electron V5+ 12 | webPreferences: { 13 | nodeIntegration: true 14 | } 15 | } 16 | 17 | class Window extends BrowserWindow { 18 | constructor ({ file, ...windowSettings }) { 19 | super({ ...defaultProps, ...windowSettings }) 20 | 21 | this.loadFile(file) 22 | 23 | this.once('ready-to-show', () => { 24 | this.show() 25 | }) 26 | } 27 | } 28 | 29 | module.exports = Window 30 | -------------------------------------------------------------------------------- /src/assets/img/404.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/assets/img/404.png -------------------------------------------------------------------------------- /src/assets/img/europa_logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/assets/img/europa_logo.ico -------------------------------------------------------------------------------- /src/assets/img/europa_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/assets/img/europa_logo.png -------------------------------------------------------------------------------- /src/assets/img/europa_logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 22 | 25 | 29 | 33 | 34 | 38 | 42 | 46 | 47 | 57 | 61 | 67 | 72 | 79 | 85 | 93 | 101 | 107 | 113 | 114 | 115 | 133 | 135 | 136 | 138 | image/svg+xml 139 | 141 | 142 | 143 | 144 | 145 | 150 | 155 | 160 | 165 | 171 | 177 | 183 | 189 | 195 | 196 | 197 | -------------------------------------------------------------------------------- /src/build-resources/512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/build-resources/512x512.png -------------------------------------------------------------------------------- /src/build-resources/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/build-resources/icon.ico -------------------------------------------------------------------------------- /src/build-resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/build-resources/icon.png -------------------------------------------------------------------------------- /src/build-resources/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 22 | 25 | 29 | 33 | 34 | 38 | 42 | 46 | 47 | 57 | 61 | 67 | 72 | 79 | 85 | 93 | 101 | 107 | 113 | 114 | 115 | 133 | 135 | 136 | 138 | image/svg+xml 139 | 141 | 142 | 143 | 144 | 145 | 150 | 155 | 160 | 165 | 171 | 177 | 183 | 189 | 195 | 196 | 197 | -------------------------------------------------------------------------------- /src/build-resources/icons/1024x1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/build-resources/icons/1024x1024.png -------------------------------------------------------------------------------- /src/build-resources/icons/128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/build-resources/icons/128x128.png -------------------------------------------------------------------------------- /src/build-resources/icons/16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/build-resources/icons/16x16.png -------------------------------------------------------------------------------- /src/build-resources/icons/256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/build-resources/icons/256x256.png -------------------------------------------------------------------------------- /src/build-resources/icons/32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/build-resources/icons/32x32.png -------------------------------------------------------------------------------- /src/build-resources/icons/512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/build-resources/icons/512x512.png -------------------------------------------------------------------------------- /src/build-resources/icons/64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/build-resources/icons/64x64.png -------------------------------------------------------------------------------- /src/config/jupyter_keyboard_shortcuts.json: -------------------------------------------------------------------------------- 1 | { 2 | // Shortcuts set by Europa 3 | // You can remove, edit or add more shortcuts to this file, Europa will not 4 | // ask again to set them. 5 | "shortcuts": [ 6 | // Disable existing next tab shortcut 7 | { 8 | "command": "application:activate-next-tab", 9 | "keys": [ 10 | "Accel Shift ]" 11 | ], 12 | "selector": "body", 13 | "disabled": true 14 | }, 15 | // Set new 16 | { 17 | "command": "application:activate-next-tab", 18 | "keys": [ 19 | "Accel Tab" 20 | ], 21 | "selector": "body" 22 | }, 23 | // Disable existing previous tab shortcut 24 | { 25 | "command": "application:activate-previous-tab", 26 | "keys": [ 27 | "Accel Shift [" 28 | ], 29 | "selector": "body", 30 | "disabled": true 31 | }, 32 | // Set new 33 | { 34 | "command": "application:activate-previous-tab", 35 | "keys": [ 36 | "Accel Shift Tab" 37 | ], 38 | "selector": "body" 39 | }, 40 | // Disable existing new launcher shortcut 41 | { 42 | "command": "filebrowser:create-main-launcher", 43 | "keys": [ 44 | "Accel Shift L" 45 | ], 46 | "selector": "body", 47 | "disabled": true 48 | }, 49 | // Set new 50 | { 51 | "command": "filebrowser:create-main-launcher", 52 | "keys": [ 53 | "Accel N" 54 | ], 55 | "selector": "body" 56 | }, 57 | // Disable existing close tab shortcut 58 | { 59 | "command": "application:close", 60 | "keys": [ 61 | "Alt W" 62 | ], 63 | "selector": ".jp-Activity", 64 | "disabled": true 65 | }, 66 | // Set new 67 | { 68 | "command": "application:close", 69 | "keys": [ 70 | "Accel W" 71 | ], 72 | "selector": ".jp-Activity" 73 | }, 74 | // Set shortcuts for menu bar 75 | { 76 | "command": "filemenu:open", 77 | "keys": [ 78 | "Alt F" 79 | ], 80 | "selector": "body" 81 | }, 82 | { 83 | "command": "editmenu:open", 84 | "keys": [ 85 | "Alt E" 86 | ], 87 | "selector": "body" 88 | }, 89 | { 90 | "command": "viewmenu:open", 91 | "keys": [ 92 | "Alt V" 93 | ], 94 | "selector": "body" 95 | }, 96 | { 97 | "command": "runmenu:open", 98 | "keys": [ 99 | "Alt R" 100 | ], 101 | "selector": "body" 102 | }, 103 | { 104 | "command": "kernelmenu:open", 105 | "keys": [ 106 | "Alt K" 107 | ], 108 | "selector": "body" 109 | }, 110 | { 111 | "command": "tabsmenu:open", 112 | "keys": [ 113 | "Alt T" 114 | ], 115 | "selector": "body" 116 | }, 117 | { 118 | "command": "settingsmenu:open", 119 | "keys": [ 120 | "Alt S" 121 | ], 122 | "selector": "body" 123 | }, 124 | { 125 | "command": "helpmenu:open", 126 | "keys": [ 127 | "Alt H" 128 | ], 129 | "selector": "body" 130 | }, 131 | 132 | ] 133 | } -------------------------------------------------------------------------------- /src/css/404.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #fffbf6 !important; 3 | } 4 | 5 | .vertical-center { 6 | display: flex; 7 | align-items: center; 8 | } 9 | 10 | .maximum-height { 11 | min-height: 100%; /* Fallback for browsers do NOT support vh unit */ 12 | min-height: 100vh; /* These two lines are counted as one :-) */ 13 | } 14 | 15 | .separator { 16 | height: 10%; 17 | } 18 | 19 | .text-small { 20 | font-size: 0.7em; 21 | } -------------------------------------------------------------------------------- /src/css/advanceduser.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/css/advanceduser.css -------------------------------------------------------------------------------- /src/css/common.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: caption; 3 | background-color: #fffbf6 !important; 4 | } 5 | 6 | /* For window header */ 7 | .large-header { 8 | padding-top: 10%; 9 | padding-bottom: 8%; 10 | padding-left: 0; 11 | } 12 | -------------------------------------------------------------------------------- /src/css/dialogbox.css: -------------------------------------------------------------------------------- 1 | /* html, body { 2 | height: 100%; 3 | } */ 4 | 5 | .container { 6 | padding: 5%; 7 | padding-left: 25px; 8 | padding-right: 15px; 9 | margin: 0; 10 | /* height: 100%; */ 11 | } 12 | 13 | #msgBox { 14 | max-height: 80vh; 15 | overflow-y: auto; 16 | /* margin-bottom: 7%; */ 17 | padding-right: 5%; 18 | padding-bottom: 3%; 19 | } 20 | -------------------------------------------------------------------------------- /src/css/newserver.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #fffbf6 !important; 3 | } 4 | 5 | #loadingSpinner { 6 | display: none; 7 | } 8 | 9 | .loading-spinner-container { 10 | margin: 0; 11 | position: absolute; 12 | top: 50%; 13 | left: 50%; 14 | transform: translate(-50%, -50%); 15 | } 16 | 17 | .loading-spinner-text { 18 | margin: 0; 19 | position: absolute; 20 | top: 60%; 21 | left: 50%; 22 | transform: translate(-50%, -50%); 23 | } 24 | 25 | .need-help-link { 26 | font-size: small; 27 | text-align: right; 28 | position:absolute; 29 | bottom:0; 30 | right:0; 31 | padding-right: 3%; 32 | padding-bottom: 1%; 33 | } 34 | 35 | .result-box { 36 | font-size: small; 37 | text-align: left; 38 | position:absolute; 39 | bottom:0; 40 | left:0; 41 | padding-left: 3%; 42 | padding-bottom: 1%; 43 | } 44 | 45 | .msg { 46 | margin-top: 6%; 47 | text-align: center; 48 | } 49 | 50 | .back-btn { 51 | padding-right: 3%; 52 | } 53 | 54 | #choose-startdir-btn { 55 | float: right; 56 | } 57 | 58 | #simple-config-alert-close-btn { 59 | float: right; 60 | } 61 | 62 | .refill-btn { 63 | display: inline-block; 64 | margin-left: 0; 65 | padding-left: 0; 66 | margin-right: 1%; 67 | margin-top: 1%; 68 | /* float: right; */ 69 | } 70 | 71 | .refill-btn-tool-tip { 72 | margin-left: 0; 73 | display:inline-block; 74 | /* vertical-align: bottom; */ 75 | font-size: smaller; 76 | opacity: 0; 77 | } 78 | 79 | .refill-btn:hover + .refill-btn-tool-tip { 80 | opacity: 1; 81 | transition-delay: 0.3s; 82 | } 83 | 84 | .refill-btn-tool-tip { 85 | } 86 | 87 | /* #beg-config-alert-box {} */ 88 | 89 | .config-btn-grp { 90 | display: inline; 91 | margin-top: 7%; 92 | margin-bottom: 10%; 93 | } 94 | 95 | .form-inline-link-div { 96 | width: 8%; 97 | display: flex; 98 | justify-content: center; 99 | } 100 | 101 | .form-inline-icon { 102 | /* width: 8%; */ 103 | margin: 2%; 104 | margin-left: 0; 105 | display: flex; 106 | justify-content: center; 107 | } 108 | 109 | .align-bottom { 110 | position: absolute; 111 | bottom: 10%; 112 | } 113 | 114 | #begInfoBox { 115 | /* vertical-align: middle; */ 116 | /* line-height: 16vh; */ 117 | height: 16vh; 118 | overflow-y: auto; 119 | word-wrap: break-word ; 120 | margin-bottom: 1%; 121 | margin-left: 8.33vw; 122 | /* margin-top: 20%; */ 123 | } 124 | 125 | #begInputHelpTxt { 126 | margin-left: 1.5%; 127 | } 128 | 129 | .no-bottom-spacing { 130 | margin-bottom: 0; 131 | padding-bottom: 0; 132 | } 133 | 134 | #advanced-config-header, #beg-config-header { 135 | padding-bottom: 10%; 136 | } 137 | 138 | #advanced-config-header-txt, #beg-config-header-txt { 139 | display: inline; 140 | } 141 | 142 | .no-top-padding { 143 | padding-top: 0%; 144 | } 145 | 146 | .vertical-center { 147 | background-color: #fffbf6 !important; 148 | min-height: 100%; /* Fallback for browsers do NOT support vh unit */ 149 | min-height: 100vh; /* These two lines are counted as one :-) */ 150 | 151 | display: flex; 152 | align-items: center; 153 | } 154 | 155 | .icon-col { 156 | margin-right:0%; 157 | padding-right: 0%; 158 | padding-left: 1%; 159 | } 160 | 161 | .text-col { 162 | padding-left: 2.5%; 163 | } 164 | 165 | .descriptive-option { 166 | /* opacity: 0.8; */ 167 | padding-top: 2%; 168 | padding-bottom: 2%; 169 | padding-left: 5%; 170 | height: 20%; 171 | } 172 | 173 | .descriptive-option:hover { 174 | opacity: 1; 175 | background: #ebf0f8; 176 | cursor: pointer; 177 | } 178 | 179 | /* CSS for loading spinner */ 180 | 181 | .animate_loader { 182 | /* background: #fff; */ 183 | /* border-radius: 60px; */ 184 | /* box-shadow: 0 2px 8px rgba(0,0,0,.2); */ 185 | margin: -5px auto; 186 | padding-bottom: 55px; 187 | width: 50px; 188 | } 189 | 190 | .animate_loader:before { 191 | content: ''; 192 | display: block; 193 | padding-top: 100%; 194 | } 195 | 196 | .animate_loader .circular { 197 | animation: rotate 2s linear infinite; 198 | height: 100%; 199 | transform-origin: center center; 200 | width: 100%; 201 | position: absolute; 202 | top: 0; 203 | bottom: 0; 204 | left: 0; 205 | right: 0; 206 | margin: auto; 207 | } 208 | 209 | .animate_loader .path { 210 | stroke-dasharray: 1, 200; 211 | stroke-dashoffset: 0; 212 | animation: dash 1.5s ease-in-out infinite, color 6s ease-in-out infinite; 213 | stroke-linecap: round; 214 | } 215 | 216 | @keyframes rotate{ 217 | 100%{ 218 | transform: rotate(360deg); 219 | } 220 | } 221 | 222 | @keyframes dash{ 223 | 0%{ 224 | stroke-dasharray: 1,200; 225 | stroke-dashoffset: 0; 226 | } 227 | 50%{ 228 | stroke-dasharray: 89,200; 229 | stroke-dashoffset: -35; 230 | } 231 | 100%{ 232 | stroke-dasharray: 89,200; 233 | stroke-dashoffset: -124; 234 | } 235 | } 236 | 237 | @keyframes color{ 238 | 100%, 0%{ 239 | stroke: #9c0; 240 | } 241 | 50%{ 242 | stroke: #9c0; 243 | /* stroke: #FF9300; */ 244 | } 245 | } -------------------------------------------------------------------------------- /src/css/settings.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 0.8em; 3 | } 4 | 5 | .row { 6 | padding-bottom: 5%; 7 | } 8 | 9 | .text-small { 10 | font-size: 0.9em; 11 | } 12 | 13 | .text-normal { 14 | font-size: 1em; 15 | } -------------------------------------------------------------------------------- /src/css/welcome.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: caption; 3 | background-color: #fffbf6 !important; 4 | } 5 | 6 | .recent-item-link {} 7 | 8 | .inline-btn-link-delete { 9 | padding-left: 0.5%; 10 | opacity: 0; 11 | font-size: 80%; 12 | text-decoration: none !important; 13 | } 14 | 15 | .inline-btn-link-delete:hover { 16 | opacity: 1; 17 | color: red; 18 | } 19 | 20 | .logo-col { 21 | width: 8em !important; 22 | flex: 0 0 100px; 23 | padding-top: 1.2%; 24 | margin-left: 0; 25 | padding-left: 0; 26 | } 27 | 28 | .recent-item-link:hover + .inline-btn-link-delete { 29 | opacity: 1; 30 | color: red; 31 | } 32 | 33 | .vertical-center { 34 | background-color: #fffbf6 !important; 35 | min-height: 100%; /* Fallback for browsers do NOT support vh unit */ 36 | min-height: 100vh; /* These two lines are counted as one :-) */ 37 | 38 | display: flex; 39 | align-items: center; 40 | margin-bottom: 0 !important; 41 | } 42 | 43 | .compact-list { 44 | list-style: none; 45 | margin: 0; 46 | padding: 0; 47 | } 48 | 49 | .main-section { 50 | margin-top: 4%; 51 | padding: 1%; 52 | padding-left: 2%; 53 | padding-bottom: 2%; 54 | background: #f8f2eb; 55 | } 56 | 57 | .transparent-main-section { 58 | margin-top: 4%; 59 | background: #fffbf6; 60 | } 61 | 62 | 63 | .section-header { 64 | } 65 | 66 | .recent-item { 67 | } 68 | 69 | 70 | /* Large buttons */ 71 | .large-btn { 72 | width: 10em; 73 | text-align: center; 74 | padding-bottom: 0.5%; 75 | padding-top: 3%; 76 | padding-left: 1%; 77 | padding-right: 1%; 78 | /* margin-right: 1em; */ 79 | } 80 | 81 | .large-btn:hover { 82 | background: #ebf0f8; 83 | cursor: pointer; 84 | } 85 | 86 | .large-btn-icon { 87 | /* padding: 1vh; */ 88 | font-size: 6vw; 89 | } 90 | 91 | .large-btn-txt { 92 | margin-top: 5%; 93 | font-size: 1.5em !important; 94 | height: 3em; 95 | } -------------------------------------------------------------------------------- /src/js/404page.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/js/404page.js -------------------------------------------------------------------------------- /src/js/addUrl.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { ipcRenderer } = require('electron') 4 | const electron = require('electron') 5 | const path = require('path') 6 | const remote = electron.remote 7 | 8 | function main() { 9 | document.getElementById('submit-btn').addEventListener('click', (evt) => { 10 | // prevent default refresh functionality of forms 11 | evt.preventDefault(); 12 | 13 | const input = document.getElementById('add-input'); 14 | 15 | if (input.value != '') { 16 | ipcRenderer.send('open-url', input.value); 17 | 18 | // Close the window 19 | var window = remote.getCurrentWindow(); 20 | window.close(); 21 | } else { 22 | const input = document.getElementById('add-input'); 23 | input.focus(); 24 | } 25 | }) 26 | 27 | document.getElementById('cancel-btn').addEventListener('click', (evt) => { 28 | var window = remote.getCurrentWindow(); 29 | window.close(); 30 | }) 31 | 32 | 33 | var window = remote.getCurrentWindow(); 34 | window.webContents.once('did-finish-load', () => { 35 | const contentSize = window.getContentSize(); 36 | const windowSize = window.getSize(); 37 | const mainContainer =document.getElementById('htmlTag'); 38 | const newHeight = mainContainer.offsetHeight+2; 39 | console.log(contentSize) 40 | console.log(newHeight) 41 | window.setSize( 42 | windowSize[0], 43 | newHeight+(windowSize[1]-contentSize[1]) 44 | ); 45 | }) 46 | } 47 | 48 | main(); -------------------------------------------------------------------------------- /src/js/advancedUser.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { ipcRenderer } = require('electron') 4 | const electron = require('electron') 5 | 6 | const winDecorations = require('../../js/modules/winDecorations'); 7 | 8 | const remote = electron.remote; 9 | const app = remote.app; 10 | 11 | const InputElement = { 12 | PY_INTER: 1, 13 | INIT_DIR: 2, 14 | PORT_NUM: 3, 15 | } 16 | 17 | function updateUI(pythonInterpreterPath) { 18 | console.log(pythonInterpreterPath); 19 | document.getElementById('pythonInterpreterPath').value = pythonInterpreterPath; 20 | document.getElementById('initialPath').value = app.getPath('home'); 21 | } 22 | 23 | function getAndUpdateJLabCfg() { 24 | return new Promise(resolve => { 25 | ipcRenderer.send('get-sys-cfg-jupyter-lab', []) 26 | ipcRenderer.on('asynchronous-reply', (event, result) => { 27 | updateUI(result); 28 | }) 29 | }); 30 | } 31 | 32 | function focusFieldWithError(fieldId) { 33 | switch (fieldId) { 34 | case InputElement.PY_INTER: 35 | document.getElementById('pythonInterpreterPath').focus(); 36 | break; 37 | case InputElement.INIT_DIR: 38 | document.getElementById('initialPath').focus(); 39 | break; 40 | case InputElement.PORT_NUM: 41 | document.getElementById('portNum').focus(); 42 | break; 43 | default: 44 | console.warn('Unknown value ' + fieldId.toString()) 45 | break; 46 | } 47 | } 48 | 49 | function displayMsg(type, msg) { 50 | var resultElem = document.getElementById('resultBox'); 51 | if (type == 'error') { 52 | console.error(msg); 53 | resultElem.innerHTML = ` ${msg}` 54 | } else if (type == 'info') { 55 | console.info(msg); 56 | resultElem.innerHTML = ` ${msg}` 57 | } 58 | } 59 | 60 | // 0 = No issue 61 | // [1-] = First field id that is wrong 62 | function checkValues() { 63 | var result = 0; 64 | 65 | // Check the port number 66 | var portNumStr = document.getElementById('portNum').value; 67 | var portNum = parseInt(portNumStr); 68 | 69 | if ((isNaN(portNum) || portNum > 65535) && portNumStr) { 70 | console.warn('Cannot parse port number: ' + portNumStr); 71 | displayMsg('error', `Port number ${portNumStr} is invalid.`); 72 | result = InputElement.PORT_NUM; 73 | } 74 | 75 | // Check the path to inital directory 76 | var startAt = document.getElementById('initialPath').value; 77 | if (!startAt) { 78 | console.warn('Initial directory not provided') 79 | displayMsg('error', `Path to initial directory is invalid.`); 80 | result = InputElement.INIT_DIR; 81 | } 82 | 83 | // Check the path to python interpreter 84 | var startAt = document.getElementById('pythonInterpreterPath').value; 85 | if (!startAt) { 86 | console.warn('Path to python interpreter not provided') 87 | displayMsg('error', `Path to python interpreter is empty.`); 88 | result = InputElement.PY_INTER; 89 | } 90 | 91 | return result; 92 | } 93 | 94 | function setVisible(selector, visible) { 95 | document.getElementById(selector).style.display = visible ? 'block' : 'none'; 96 | } 97 | 98 | function startServer() { 99 | var retVal = checkValues(); 100 | if (retVal != 0) { 101 | focusFieldWithError(retVal); 102 | } else { 103 | displayMsg('info', ''); 104 | 105 | var py = document.getElementById('pythonInterpreterPath').value; 106 | var startDir = document.getElementById('initialPath').value; 107 | var portNum = document.getElementById('portNum').value; 108 | 109 | if (!portNum) { 110 | portNum = 'auto' 111 | } 112 | 113 | ipcRenderer.send('start-server', py, startDir, portNum); 114 | 115 | // Hide the contents 116 | setVisible('advanced-config-container', 0); 117 | setVisible('loadingSpinner', 1); 118 | } 119 | } 120 | 121 | function startServerResp(event, result) { 122 | console.log(`start-server result: ${result}`); 123 | setVisible('advanced-config-container', 1); 124 | setVisible('loadingSpinner', 0); 125 | 126 | if (String(result).startsWith('Failed')) { 127 | displayMsg('error', `${result}`); 128 | } else { 129 | displayMsg('info', `Got: ${result}`); 130 | var url = String(result) 131 | 132 | // trim white spaces 133 | url = url.replace(/(^[ '\^\$\*#&]+)|([ '\^\$\*#&]+$)/g, '') 134 | 135 | if (url) { 136 | ipcRenderer.send('open-url', url); 137 | var window = remote.getCurrentWindow(); 138 | window.close(); 139 | } 140 | } 141 | } 142 | 143 | function main() { 144 | 145 | ipcRenderer.on('start-server-resp', startServerResp); 146 | 147 | document.getElementById('backBtn').addEventListener('click', (evt) => { 148 | var window = remote.getCurrentWindow(); 149 | window.webContents.goBack(); 150 | }) 151 | 152 | document.getElementById('cancelBtn').addEventListener('click', (evt) => { 153 | var window = remote.getCurrentWindow(); 154 | window.close(); 155 | }) 156 | 157 | document.getElementById('submitBtn').addEventListener('click', (evt) => { 158 | startServer(); 159 | }) 160 | 161 | document.getElementById('refillBtn').addEventListener('click', (evt) => { 162 | getAndUpdateJLabCfg(); 163 | }) 164 | 165 | winDecorations.setupDecorations(); 166 | } 167 | 168 | main(); -------------------------------------------------------------------------------- /src/js/begUser.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { ipcRenderer } = require('electron'); 4 | const electron = require('electron'); 5 | const fs = require('fs'); 6 | const remote = electron.remote; 7 | const dialog = remote.dialog; 8 | const app = remote.app; 9 | const WIN = remote.getCurrentWindow(); 10 | 11 | const winDecorations = require('../../js/modules/winDecorations'); 12 | 13 | function showMessage(msgType, msg="") { 14 | var elem = document.getElementById('begInfoBox'); 15 | if (msgType === 'error') { 16 | elem.innerHTML = ` ${msg}`; 17 | } else if (msgType === 'success') { 18 | elem.innerHTML = ` ${msg}`; 19 | } else if (msgType === 'clear') { 20 | elem.innerHTML = ''; 21 | } else { 22 | console.error(`Unknown msgType: ${msgType} for msg: ${msg}.`); 23 | } 24 | } 25 | 26 | function setVisible(selector, visible) { 27 | document.getElementById(selector).style.display = visible ? 'block' : 'none'; 28 | } 29 | 30 | function startServer(dirPath) { 31 | checkInput(() => { 32 | showMessage('clear', ''); 33 | 34 | var py = "python"; 35 | var startDir = dirPath; 36 | var portNum = 'auto'; 37 | 38 | ipcRenderer.send('start-server', py, startDir, portNum); 39 | 40 | // Hide the contents 41 | setVisible('beg-config-container', 0); 42 | setVisible('loadingSpinner', 1); 43 | }); 44 | } 45 | 46 | function startServerResp(event, result) { 47 | console.log(`start-server result: ${result}`); 48 | setVisible('beg-config-container', 1); 49 | setVisible('loadingSpinner', 0); 50 | 51 | if (String(result).startsWith('Failed')) { 52 | showMessage('error', `${result}`); 53 | } else { 54 | showMessage('info', `Got: ${result}`); 55 | var url = String(result) 56 | 57 | // trim white spaces 58 | url = url.replace(/(^[ '\^\$\*#&]+)|([ '\^\$\*#&]+$)/g, '') 59 | 60 | if (url) { 61 | ipcRenderer.send('open-url', url); 62 | var window = remote.getCurrentWindow(); 63 | window.close(); 64 | } 65 | } 66 | } 67 | 68 | function chooseDir() { 69 | let options = { 70 | title : "Choose JupyterLab's start directory", 71 | defaultPath : app.getPath('home'), 72 | buttonLabel : "Start here", 73 | properties: ['openDirectory'] 74 | } 75 | 76 | var dir = dialog.showOpenDialog(options); 77 | chooseDirResp(dir); 78 | } 79 | 80 | function chooseDirResp(dirPath) { 81 | if (dirPath != undefined) { 82 | console.log(`Directory: ${dirPath}`) 83 | document.getElementById('startDir').value = dirPath; 84 | } 85 | } 86 | 87 | function checkInput(callback) { 88 | var dirPath = document.getElementById('startDir').value; 89 | 90 | if (dirPath) { 91 | fs.stat(dirPath, function (err, stats){ 92 | if (err) { 93 | console.log(`Directory doesn't exist ${dirPath}`); 94 | showMessage('error', `Path does not point to any valid location.`); 95 | } 96 | if (!stats.isDirectory()) { 97 | console.log(`Path is not a directory: ${dirPath}`); 98 | showMessage('error', `Path is not a directory.`); 99 | } else { 100 | console.log(`${dirPath} exists as a directory.`); 101 | callback(); 102 | showMessage('clear'); 103 | } 104 | }); 105 | } else { 106 | showMessage('error', `Please enter a path to an existing directory. `); 107 | } 108 | } 109 | 110 | function main() { 111 | document.getElementById('backBtn').addEventListener('click', (evt) => { 112 | WIN.webContents.goBack(); 113 | }) 114 | 115 | document.getElementById('cancelBtn').addEventListener('click', (evt) => { 116 | WIN.close(); 117 | }) 118 | 119 | document.getElementById('submitBtn').addEventListener('click', (evt) => { 120 | startServer(document.getElementById('startDir').value); 121 | }) 122 | 123 | document.getElementById('chooseDir').addEventListener('click', (evt) => { 124 | chooseDir(); 125 | }) 126 | 127 | winDecorations.setupDecorations(); 128 | 129 | ipcRenderer.on('start-server-resp', startServerResp); 130 | } 131 | 132 | main(); -------------------------------------------------------------------------------- /src/js/dialogbox.js: -------------------------------------------------------------------------------- 1 | const { shell, ipcRenderer, remote } = require('electron'); 2 | 3 | const winDecorations = require('../../js/modules/winDecorations'); 4 | 5 | var callbackName = undefined; 6 | var dialogId = undefined; 7 | // var window = remote.getCurrentWindow(); 8 | 9 | const ICON_HTML_MAP = { 10 | 'info': ``, 11 | 'question': ``, 12 | 'warning': ``, 13 | 'error': ``, 14 | }; 15 | 16 | function setupUI(properties) { 17 | var titleStr, primaryBtnStr, secondaryBtnStr, iconHTML, content; 18 | 19 | if ('title' in properties) { 20 | titleStr = properties['title'] 21 | } else { 22 | titleStr = 'Dialog Box'; 23 | } 24 | 25 | if ('primaryBtn' in properties) { 26 | primaryBtnStr = properties['primaryBtn'] 27 | } else { 28 | primaryBtnStr = 'OK'; 29 | } 30 | 31 | if ('secondaryBtn' in properties) { 32 | secondaryBtnStr = properties['secondaryBtn'] 33 | } else { 34 | secondaryBtnStr = 'Cancel'; 35 | } 36 | 37 | if ('type' in properties) { 38 | iconHTML = ICON_HTML_MAP[properties['type']] 39 | } else { 40 | iconHTML = ICON_HTML_MAP['info']; 41 | } 42 | 43 | if ('content' in properties) { 44 | content = properties['content']; 45 | } else { 46 | content = 'Dialog box content.' 47 | } 48 | 49 | document.getElementById('btnPrimary').innerHTML = primaryBtnStr; 50 | if (secondaryBtnStr) { 51 | document.getElementById('btnSecondary').innerHTML = secondaryBtnStr; 52 | } else { 53 | document.getElementById('btnSecondary').style.visibility = 'hidden'; 54 | } 55 | document.getElementById('msgIcon').innerHTML = iconHTML; 56 | document.getElementById('msgBox').innerHTML = content; 57 | remote.getCurrentWindow().setTitle(titleStr); 58 | } 59 | 60 | function main() { 61 | document.getElementById('btnPrimary').addEventListener('click', (evt) => { 62 | ipcRenderer.send('dialog-result', dialogId, 'primary'); 63 | window.close(); 64 | }) 65 | 66 | document.getElementById('btnSecondary').addEventListener('click', (evt) => { 67 | ipcRenderer.send('dialog-result', dialogId, 'secondary'); 68 | window.close(); 69 | }) 70 | 71 | /** 72 | * @brief Sets up the dialog box 73 | * @param properties Dictionary containing the dialog properties 74 | * title Title of the window 75 | * content Content of the message box 76 | * primaryBtn Text of the primary button 77 | * secvondaryBtn Text of the primary button 78 | * type {'info'|'question'|'warning'|'error'} 79 | * callbackName Name to call on ipcMain on user input 80 | */ 81 | ipcRenderer.on('construct', (event, properties, callbackName) => { 82 | console.log(`Got: ${JSON.stringify(properties)}, ${callbackName}`); 83 | dialogId = callbackName; 84 | resultCallback = callbackName; 85 | setupUI(properties); 86 | }) 87 | 88 | winDecorations.setupDecorations(); 89 | var window = remote.getCurrentWindow(); 90 | window.webContents.once('did-finish-load', () => { 91 | const contentSize = window.getContentSize(); 92 | const windowSize = window.getSize(); 93 | const mainContainer =document.getElementById('htmlTag'); 94 | const newHeight = mainContainer.offsetHeight+2; 95 | console.log(contentSize) 96 | console.log(newHeight) 97 | window.setSize( 98 | windowSize[0], 99 | newHeight+(windowSize[1]-contentSize[1]) 100 | ); 101 | }) 102 | } 103 | 104 | main(); -------------------------------------------------------------------------------- /src/js/modules/winDecorations.js: -------------------------------------------------------------------------------- 1 | const os = require('os'); 2 | // const customTitlebar = require('custom-electron-titlebar'); 3 | 4 | module.exports.setupDecorations = function () { 5 | // if (os.platform != 'linux') { 6 | // new customTitlebar.Titlebar({ 7 | // backgroundColor: customTitlebar.Color.fromHex('#444') 8 | // }); 9 | // } 10 | } 11 | -------------------------------------------------------------------------------- /src/js/newServer.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { ipcRenderer } = require('electron') 4 | const electron = require('electron') 5 | const path = require('path') 6 | const url = require('url') 7 | const remote = electron.remote 8 | 9 | const winDecorations = require('../../js/modules/winDecorations'); 10 | 11 | function main() { 12 | document.getElementById('advancedUser').addEventListener('click', (evt) => { 13 | var filePath = path.join('renderer', 'new_server', 'advanceduser.html'); 14 | remote.getCurrentWindow().loadFile(filePath); 15 | }); 16 | 17 | document.getElementById('beginnerUser').addEventListener('click', (evt) => { 18 | var filePath = path.join('renderer', 'new_server', 'beginneruser.html'); 19 | remote.getCurrentWindow().loadFile(filePath); 20 | }); 21 | 22 | winDecorations.setupDecorations(); 23 | } 24 | 25 | main(); -------------------------------------------------------------------------------- /src/js/preload404.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suyashmahar/europa/8b7ea053d9eef4af6f8fc9c8dd60455f23ec3fee/src/js/preload404.js -------------------------------------------------------------------------------- /src/js/settingsPage.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { ipcRenderer, remote, shell } = require('electron') 4 | 5 | /* How long to show the badge for */ 6 | const STATUS_BADGE_TMOUT = 3000; 7 | 8 | /* When to hide the status badge */ 9 | var statusBadgeHideAt = undefined; 10 | 11 | function updateStatus(status) { 12 | if (status == 'success') { 13 | document.getElementById('statusBadge').style.display = 'block'; 14 | document.getElementById('headerTxt').innerHTML = `Settings saved` 15 | } else if (status == 'failure') { 16 | document.getElementById('statusBadge').style.display = 'block'; 17 | document.getElementById('headerTxt').innerHTML = `Settings failed` 18 | } else { 19 | document.getElementById('statusBadge').style.display = 'block'; 20 | document.getElementById('headerTxt').innerHTML = `Settings ${status}` 21 | } 22 | 23 | statusBadgeHideAt = Date.now() + STATUS_BADGE_TMOUT; 24 | 25 | setTimeout(() => { 26 | console.log(statusBadgeHideAt); 27 | console.log(Date.now()); 28 | if (statusBadgeHideAt) { 29 | /* If the status hide time has not been updated (cur time is within 100 ms) */ 30 | if (statusBadgeHideAt - Date.now() < 100) { 31 | document.getElementById('statusBadge').style.display = 'none'; 32 | } 33 | } 34 | }, STATUS_BADGE_TMOUT); 35 | } 36 | 37 | function saveSettings() { 38 | var settingsObj = {}; 39 | settingsObj["show-keyboard-shortcuts-dialog"] = undefined; 40 | 41 | if (document.getElementById('kbdShortcutsDlgAsk').checked) { 42 | settingsObj["show-keyboard-shortcuts-dialog"] = "ask"; 43 | } else if (document.getElementById('kbdShortcutsDlgNeverAsk').checked) { 44 | settingsObj["show-keyboard-shortcuts-dialog"] = "never"; 45 | } 46 | 47 | ipcRenderer.send('save-settings', settingsObj); 48 | updateStatus('success'); 49 | } 50 | 51 | function updateUI(settingsObj) { 52 | if (settingsObj["show-keyboard-shortcuts-dialog"] == "ask") { 53 | document.getElementById('kbdShortcutsDlgAsk').true; 54 | } else if (settingsObj["show-keyboard-shortcuts-dialog"] == "never") { 55 | document.getElementById('kbdShortcutsDlgNeverAsk').checked = true; 56 | } 57 | } 58 | 59 | function main() { 60 | document.getElementById('saveBtn').addEventListener('click', () => { 61 | saveSettings(); 62 | }); 63 | 64 | document.getElementById('cancelBtn').addEventListener('click', () => { 65 | remote.getCurrentWindow().close(); 66 | }); 67 | 68 | document.getElementById('clearCache').addEventListener('click', () => { 69 | updateStatus('cache cleared'); 70 | ipcRenderer.send('clear-cache'); 71 | }); 72 | 73 | ipcRenderer.on('settings-value', (event, settingsObj) => { 74 | updateUI(settingsObj); 75 | }); 76 | 77 | 78 | } 79 | 80 | main(); -------------------------------------------------------------------------------- /src/js/welcome.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { ipcRenderer, shell } = require('electron') 4 | 5 | const winDecorations = require('../js/modules/winDecorations') 6 | 7 | const recentItemClicked = (e) => { 8 | console.log(e.target.textContent) 9 | ipcRenderer.send('open-url', e.target.textContent) 10 | } 11 | const deleteRecentItemClicked = (e) => { 12 | console.log(e.target.getAttribute('id')) 13 | ipcRenderer.send('delete-recent-url', e.target.getAttribute('id')) 14 | } 15 | 16 | function main () { 17 | document.getElementById('openUrlBtn').addEventListener('click', () => { 18 | ipcRenderer.send('open-new-url') 19 | }) 20 | document.getElementById('newServerBtn').addEventListener('click', () => { 21 | ipcRenderer.send('new-server-window') 22 | }) 23 | document.getElementById('optionsBtn').addEventListener('click', () => { 24 | ipcRenderer.send('options-window') 25 | }) 26 | 27 | // Listeners for help links 28 | document.getElementById('helpReportIssue').addEventListener('click', () => { 29 | shell.openExternal('https://github.com/suyashmahar/europa/issues/new'); 30 | }) 31 | // document.getElementById('helpGitHubRepo').addEventListener('click', () => { 32 | // shell.openExternal('https://github.com/suyashmahar/europa'); 33 | // }); 34 | // document.getElementById('helpProductDocumentation').addEventListener('click', () => { 35 | // shell.openExternal('https://github.com/suyashmahar/europa/wiki'); 36 | // }); 37 | // document.getElementById('helpTipsAndTricks').addEventListener('click', () => { 38 | // shell.openExternal('https://github.com/suyashmahar/europa/wiki/TipsAndTricks'); 39 | // }); 40 | document.getElementById('helpKeyboardShortcuts').addEventListener('click', () => { 41 | shell.openExternal('https://github.com/suyashmahar/europa/wiki/Keyboard-shortcuts'); 42 | }); 43 | document.getElementById('helpAboutEuropa').addEventListener('click', () => { 44 | ipcRenderer.send('show-about-europa'); 45 | }) 46 | 47 | ipcRenderer.on('recent-urls', (event, recentUrls) => { 48 | const recentUrlElem = document.getElementById('recentUrls') 49 | 50 | /* create an html string */ 51 | var recentUrlHtml = recentUrls.reduce((html, item) => { 52 | var itemDeleteBtnHtml = `` 53 | html += `
  • ${item}${itemDeleteBtnHtml}
  • ` 54 | 55 | return html 56 | }, '') 57 | 58 | if (!recentUrlHtml) { 59 | recentUrlHtml = 'No recent items' 60 | } 61 | 62 | /* set list html to the todo items */ 63 | recentUrlElem.innerHTML = recentUrlHtml 64 | 65 | /* Add click handlers to the link */ 66 | document.querySelectorAll('.recent-item-link').forEach(item => { 67 | item.addEventListener('click', recentItemClicked) 68 | }) 69 | 70 | /* Add click handlers to the delete button */ 71 | document.querySelectorAll('.inline-btn-link-delete').forEach(item => { 72 | item.addEventListener('click', deleteRecentItemClicked) 73 | }) 74 | }) 75 | 76 | winDecorations.setupDecorations() 77 | } 78 | 79 | main() 80 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | // -*- js-indent-level: 2; -*- 2 | 3 | 'use strict' 4 | const path = require('path') 5 | const request = require('request') 6 | const { app, BrowserWindow, ipcMain, Menu, session } = require('electron') 7 | const fs = require('fs') 8 | const os = require('os') 9 | const process = require('process') 10 | const contextMenu = require('electron-context-menu'); 11 | 12 | const Window = require('./Window') 13 | const RecentUrlsDB = require('./RecentUrlsDB') 14 | const SettingsDB = require('./SettingsDB') 15 | const electronLocalshortcut = require('electron-localshortcut') 16 | const commandExists = require('command-exists') 17 | const { execSync } = require('child_process') 18 | const { spawn } = require('child_process') 19 | const { pathToFileURL } = require('url') 20 | 21 | const EUROPA_HELP_SHORTCUTS_LINK = 'https://github.com/suyashmahar/europa/wiki/Keyboard-shortcuts' 22 | const EUROPA_UNSUPPORTED_JUPYTER_LINK = 'https://github.com/suyashmahar/europa/wiki/Supported-JupyterLab-Versions' 23 | 24 | const MAX_RECENT_ITEMS = 4 25 | const SHORTCUT_SEND_URL = `/lab/api/settings/@jupyterlab/shortcuts-extension:shortcuts` 26 | const USER_AGENT_STR = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' 27 | const DRAW_FRAME = true 28 | const VERSION_STRING = '1.1.1' 29 | 30 | /* Create all the data stores */ 31 | const recentUrlsDb = new RecentUrlsDB({ name: 'recent_urls' }) 32 | const settingsDb = new SettingsDB({ name: 'global_settings' }) 33 | 34 | let appDir = __dirname 35 | let iconPath 36 | let mainWindow, settingsWin, openUrlWin, newServerDialog 37 | 38 | let referrer 39 | 40 | // Tracks all the url opened so far 41 | let JUPYTER_REQ_FILTER = { 42 | urls: ['*://*/*'] 43 | } 44 | 45 | // url filter to see if the login was successful 46 | let JUPYTER_LOGIN_SUCCESS_FILTER = { 47 | urls: ['*://*/*api/contents/*'] 48 | } 49 | 50 | // Tracks login for a host 51 | let loginTracker = {} 52 | // Tracks window for a url 53 | let windowTracker = {} 54 | // Tracks the dialog box responses 55 | let dialogRespTracker = {} 56 | // Tracks jupyter format cookie for urls 57 | let jupyterCookieTracker = {} 58 | 59 | let fixASARPath = () => { 60 | if (appDir.endsWith('.asar')) { 61 | appDir = path.dirname(appDir) 62 | } 63 | } 64 | 65 | let getPythonInterpreter = () => { 66 | let result 67 | let found = commandExists.sync('python3') || 68 | commandExists.sync('python') 69 | if (found) { 70 | result = execSync(`python -c "import sys; print(sys.executable)"`) 71 | } 72 | 73 | return result 74 | } 75 | 76 | // Monitor the started child process for starting jupyter lab server 77 | let monitorStartServerChild = (event, child) => { 78 | child.stdout.on('data', function (data) { 79 | if (data) { 80 | event.sender.send('start-server-resp', data) 81 | } 82 | }) 83 | child.stderr.on('data', function (data) { 84 | if (data) { 85 | event.sender.send('start-server-resp', data) 86 | } 87 | console.error('Shell Errors: ' + data) 88 | }) 89 | } 90 | 91 | // Configure the context menu for shift+right-click 92 | contextMenu({ 93 | prepend: (defaultAction, params, browserWindow) => [{ 94 | role: "zoomIn", 95 | }, { 96 | role: "zoomOut", 97 | }, { 98 | role: "editMenu", 99 | visible: params.selectionText.trim().length > 0, 100 | }, { 101 | role: "toggleDevTools", 102 | }, { 103 | role: "forceReload", 104 | }] 105 | }); 106 | 107 | /** 108 | * Starts a new JupyterLab server on Windows OS. See @ref startServer 109 | */ 110 | let startServerWindows = (event, py, startAt, portNum) => { 111 | let scriptPath = path.join(appDir, 'scripts', 112 | 'windows', 'start_jupyter_lab.ps1') 113 | 114 | // Execute the command async 115 | let child = spawn('powershell.exe', [scriptPath, `${py} ${startAt} ${portNum}`]) 116 | monitorStartServerChild(event, child) 117 | } 118 | 119 | /** 120 | * Starts a new JupyterLab server in posix environment. See @ref startServer 121 | */ 122 | let startServerLinux = (event, py, startAt, portNum) => { 123 | let scriptPath = path.join(appDir, 'scripts', 124 | 'posix', 'start_jupyter_lab.sh') 125 | 126 | // Execute the command async 127 | let child = spawn('sh', [scriptPath, py, startAt, portNum]) 128 | monitorStartServerChild(event, child) 129 | } 130 | 131 | /** 132 | * Start JupyterLab server using a OS dependent script 133 | * @param {*} event 134 | * @param {String} py Path to python interpreter 135 | * @param {String} startAt Directory to start JupyterLab at 136 | * @param {String} portNum {0-64k|'auto'} 137 | */ 138 | let startServerOS = (event, py, startAt, portNum) => { 139 | if (process.platform === 'win32') { 140 | startServerWindows(event, py, startAt, portNum) 141 | } else if (process.platform === 'linux') { 142 | startServerLinux(event, py, startAt, portNum) 143 | } else { 144 | console.error('Unsupported platform ' + process.platform) 145 | } 146 | } 147 | 148 | /** 149 | * Set platform specific icon file. 150 | */ 151 | function setupIcons () { 152 | if (os.platform() === 'win32') { 153 | iconPath = path.join(__dirname, 'assets', 'img', 'europa_logo.ico') 154 | } else if (os.platform() === 'linux') { 155 | iconPath = path.join(__dirname, 'assets', 'img', 'europa_logo.png') 156 | } else if (os.platform() === 'darwin') { 157 | iconPath = path.join(__dirname, 'assets', 'img', 'europa_logo.icns') 158 | } else { 159 | console.warn(`Platform ${os.platform()} has not icon set.`) 160 | } 161 | } 162 | 163 | /** 164 | * Show warning for an unsupported version of jupyter lab 165 | */ 166 | let showUnsupportedJupyterMsg = (urlObj) => { 167 | const props = { 168 | 'type': 'warning', 169 | 'title': 'Unsupported JupyterLab version', 170 | 'content': `

    Unsupported version of JupyterLab.

    Some of the Europa's functionality will be disabled (e.g., automatic shortcut configuration). Know More.

    `, 171 | 'primaryBtn': 'OK', 172 | 'secondaryBtn': '' 173 | } 174 | createDialog(windowTracker[urlObj.origin], props, `${Date.now()}`, (resp) => {}) 175 | } 176 | 177 | /** 178 | * Check if the shortcuts needs to be set (before asking user) 179 | * Generate a GET request on the keyboard settings URL and compare the response 180 | */ 181 | const shouldSetShortcuts = (urlObj, callback) => { 182 | const userKbdDialogPref = getSettings()['show-keyboard-shortcuts-dialog'] 183 | const shortcutDialogEnabled = (userKbdDialogPref === 'ask') 184 | // Work on urlObj 185 | let pathname = urlObj.pathname 186 | let pathCutTemp = pathname.split('/') 187 | let path = '' 188 | if (pathCutTemp.length >= 3) { 189 | path = pathCutTemp[1] + '/' + pathCutTemp[2] 190 | } 191 | 192 | if (shortcutDialogEnabled === false) { 193 | return 194 | } 195 | 196 | let reqUrl = `${urlObj.origin}/${path}${SHORTCUT_SEND_URL}` 197 | 198 | request.get( 199 | { 200 | url: reqUrl, 201 | headers: { 202 | 'Host': urlObj.host, 203 | 'Origin': urlObj.origin, 204 | 'Connection': 'keep-alive', 205 | 'Content-Type': 'application/json', 206 | 'cookie': jupyterCookieTracker[urlObj.origin]['cookie'], 207 | 'X-XSRFToken': jupyterCookieTracker[urlObj.origin]['xsrf'], 208 | 'User-Agent': USER_AGENT_STR 209 | } 210 | }, 211 | function (error, response, body) { 212 | let result = false 213 | if (!error) { 214 | let rcvData = JSON.parse(body) 215 | if (rcvData['raw']) { 216 | if (rcvData['raw'].length === 2) { 217 | result = true 218 | } 219 | } else { 220 | showUnsupportedJupyterMsg(urlObj) 221 | } 222 | result = true 223 | } else { 224 | showUnsupportedJupyterMsg(urlObj) 225 | } 226 | callback(result) 227 | }) 228 | } 229 | 230 | function askUserForShortcuts (url, window) { 231 | let props = { 232 | 'type': 'question', 233 | 'title': 'Set shorcuts?', 234 | 'primaryBtn': 'Yes', 235 | 'secondaryBtn': 'No', 236 | 'content': ` 237 |

    Set JupyterLab shortcuts for Europa?

    238 |

    E.g., Alt+Tab to switch tabs. Note that these 239 | changes are persistent. 240 | 241 | Know More 242 | 243 |

    ` 244 | } 245 | 246 | let id = url + '_ask_shortcuts' 247 | createDialog(window, props, id, (resp) => { 248 | if (resp === 'primary') { 249 | sendShortcuts(id) 250 | } 251 | }) 252 | } 253 | 254 | /** 255 | * Sends a PUT request for the custom shortcut to link in the id 256 | * @param {string} id url + tag 257 | */ 258 | function sendShortcuts (id) { 259 | let url = id.replace(/_ask_shortcuts/, '') 260 | let urlObj = new URL(url) 261 | 262 | const shortcutsFile = path.join( 263 | appDir, 'config', 'jupyter_keyboard_shortcuts.json' 264 | ) 265 | 266 | const jsonData = fs.readFileSync(shortcutsFile) 267 | 268 | request.put( 269 | { 270 | url: `${urlObj.origin}${SHORTCUT_SEND_URL}?${Date.now()}`, 271 | headers: { 272 | 'Host': urlObj.host, 273 | 'Origin': urlObj.origin, 274 | 'Connection': 'keep-alive', 275 | 'Content-Type': 'text/plain', 276 | 'Content-Length': jsonData.length, 277 | 'cookie': jupyterCookieTracker[urlObj.origin]['cookie'], 278 | 'X-XSRFToken': jupyterCookieTracker[urlObj.origin]['xsrf'], 279 | 'User-Agent': USER_AGENT_STR 280 | }, 281 | body: jsonData 282 | }, 283 | function (error, response, body) { 284 | if (!error) { 285 | windowTracker[urlObj.origin].reload() 286 | } 287 | }) 288 | } 289 | 290 | /** 291 | * Creates a dialog box 292 | * @param {BrowserWindow} window 293 | * @param {dictionary} props Properties of the dialog box, check dialogbox.js 294 | * @param {string} id unique identifier for this dialog box 295 | */ 296 | function createDialog (window, props, id, callback) { 297 | let dialogBox = new Window({ 298 | file: path.join('renderer', 'dialog_box', 'dialogbox.html'), 299 | width: 500, 300 | height: 230, 301 | icon: iconPath, 302 | frame: DRAW_FRAME, 303 | useContentSize: true, 304 | 305 | // close with the main window 306 | parent: window 307 | }) 308 | 309 | electronLocalshortcut.register(dialogBox, 'Esc', () => { 310 | dialogBox.close() 311 | }) 312 | 313 | dialogBox.webContents.on('did-finish-load', () => { 314 | dialogBox.webContents.send('construct', props, id) 315 | }) 316 | 317 | dialogRespTracker[id] = callback 318 | } 319 | 320 | /** 321 | * Starts a request interceptor to check if the user has logged into the server. 322 | * This is done to only show the keyboard shortcut dialog once the user has been 323 | * authenticated. 324 | */ 325 | function startHTTPProxy () { 326 | const webRequest = session.defaultSession.webRequest 327 | webRequest.onBeforeSendHeaders(JUPYTER_REQ_FILTER, 328 | (details, callback) => { 329 | if (details.uploadData) { 330 | referrer = details.referrer 331 | } 332 | callback(details) 333 | }) 334 | 335 | webRequest.onHeadersReceived(JUPYTER_LOGIN_SUCCESS_FILTER, 336 | (details, callback) => { 337 | if (details) { 338 | let urlObj = new URL(details.url) 339 | if (!(urlObj.origin in loginTracker)) { 340 | loginTracker[urlObj.origin] = true 341 | 342 | getCookies(details.url, () => { 343 | shouldSetShortcuts(urlObj, (result) => { 344 | if (result) { 345 | console.log(result) 346 | askUserForShortcuts(details.url, windowTracker[urlObj.origin]) 347 | } 348 | }) 349 | }) 350 | } 351 | } 352 | callback(details) 353 | }) 354 | } 355 | 356 | /** 357 | * Sets all the cookies in jupyterCookieTracker using JupyterLab's format 358 | * @param {String} urlRequested URL to get cookies for 359 | * @param {function} callback Callback function 360 | */ 361 | function getCookies (urlRequested, callback) { 362 | const urlObj = new URL(urlRequested) 363 | let domain = urlObj.hostname 364 | return session.defaultSession.cookies.get( 365 | { domain }, 366 | (error, result) => { 367 | let key = urlObj.origin 368 | 369 | // console.log(`Total ${result.length} cookies found`) 370 | 371 | /* Generate cookie in JupyterLab's format */ 372 | jupyterCookieTracker[key] = { 'cookie': undefined, 'xsrf': undefined } 373 | jupyterCookieTracker[key]['cookie'] = result[0]['name'] 374 | jupyterCookieTracker[key]['cookie'] += '=' 375 | jupyterCookieTracker[key]['cookie'] += result[0]['value'] 376 | jupyterCookieTracker[key]['cookie'] += '; ' 377 | jupyterCookieTracker[key]['cookie'] += result[1]['name'] 378 | jupyterCookieTracker[key]['cookie'] += '=' 379 | jupyterCookieTracker[key]['cookie'] += result[1]['value'] 380 | 381 | // console.log(`Cookie generated: ${jupyterCookieTracker[key]['cookie']}`); 382 | 383 | jupyterCookieTracker[key]['xsrf'] = result[0]['value'] 384 | 385 | // console.log(`XSRF generated: ${jupyterCookieTracker[key]['xsrf']}`); 386 | 387 | callback() 388 | return result 389 | } 390 | ) 391 | } 392 | 393 | function addTrackingForUrl (url) { 394 | 395 | } 396 | 397 | /** 398 | * Rmoves a URL from the list of tracked URL and the existing information is 399 | * lost 400 | * @param {String} url URL to remove tracking for 401 | */ 402 | function removeTrackingForUrl (url) { 403 | const urlObj = new URL(url) 404 | if (urlObj.origin in loginTracker) { 405 | delete loginTracker[urlObj.origin] 406 | } 407 | } 408 | 409 | /** 410 | * Shows a 404 page on event.sender BrowserWindow 411 | * @param {*} event 412 | * @param {*} errorCode 413 | * @param {*} errorDescription 414 | * @param {String} validatedUrl URL that resulted in the error 415 | * @param {*} isMainFrame 416 | */ 417 | function show404 (event, errorCode, errorDescription, validatedUrl, isMainFrame) { 418 | event.sender.webContents.removeListener('did-fail-load', show404) 419 | let errorPagePath = path.join(__dirname, 'renderer', '404_page', '404page.html') 420 | event.sender.loadURL(pathToFileURL(errorPagePath).href) 421 | 422 | electronLocalshortcut.register(event.sender, 'Ctrl+R', () => { 423 | event.sender.loadURL(validatedUrl) 424 | }) 425 | } 426 | 427 | function showOptionsWindow () { 428 | if (!settingsWin) { 429 | settingsWin = new Window({ 430 | file: path.join('renderer', 'settings_page', 'settings.html'), 431 | width: 700, 432 | height: 600, 433 | icon: iconPath, 434 | frame: DRAW_FRAME, 435 | 436 | // close with the main window 437 | parent: mainWindow 438 | }) 439 | 440 | // cleanup 441 | settingsWin.on('closed', () => { 442 | settingsWin = null 443 | }) 444 | 445 | // Register shortcuts 446 | electronLocalshortcut.register(settingsWin, 'Esc', () => { 447 | settingsWin.close() 448 | }) 449 | 450 | settingsWin.webContents.on('did-finish-load', () => { 451 | settingsWin.webContents.send('settings-value', getSettings()) 452 | }) 453 | } 454 | } 455 | 456 | /** 457 | * Clear cache, useful when same site has multiple cookies stored 458 | */ 459 | function clearCache () { 460 | session.defaultSession.clearStorageData() 461 | } 462 | 463 | /** 464 | * Saves settings to disk 465 | * @param {dictionary} settingsObj Settings to save 466 | */ 467 | function setSettings (settingsObj) { 468 | settingsDb.saveSettings(settingsObj) 469 | } 470 | /** 471 | * Gets the settings from disk and returns a dictionary object 472 | */ 473 | function getSettings () { 474 | return settingsDb.getSettings() 475 | } 476 | 477 | /** 478 | * The about dialog box for copyright and license information 479 | */ 480 | function showAboutDialog (win) { 481 | const aboutDialogContents = ` 482 |

    About Europa v${VERSION_STRING}

    483 |

    Copyright © 2020 Suyash Mahar

    484 |

    485 | This program is distributed under the terms of the 486 | GPL v3. 487 | Link to the 488 | 489 | Source code. 490 | 491 |

    492 | ` 493 | 494 | const props = { 495 | 'type': 'info', 496 | 'title': 'About Europa', 497 | 'content': aboutDialogContents, 498 | 'primaryBtn': 'OK', 499 | 'secondaryBtn': '' 500 | } 501 | 502 | createDialog(mainWindow, props, String(Date.now()), () => void 0) 503 | } 504 | 505 | function showOpenURLDialog () { 506 | if (!openUrlWin) { 507 | // create a new add todo window 508 | openUrlWin = new Window({ 509 | file: path.join('renderer', 'add_url', 'add_url.html'), 510 | width: 500, 511 | height: 120, 512 | resizable: false, 513 | icon: iconPath, 514 | frame: DRAW_FRAME, 515 | 516 | // close with the main window 517 | parent: mainWindow 518 | }) 519 | 520 | // cleanup 521 | openUrlWin.on('closed', () => { 522 | openUrlWin = null 523 | }) 524 | 525 | // Register shortcuts 526 | electronLocalshortcut.register(openUrlWin, 'Esc', () => { 527 | openUrlWin.close() 528 | }) 529 | } 530 | } 531 | 532 | /** 533 | * Shows the window for creating a new JuptyerLab server 534 | */ 535 | function showNewServerDialog () { 536 | if (!newServerDialog) { 537 | newServerDialog = new Window({ 538 | file: path.join('renderer', 'new_server', 'newserver.html'), 539 | width: 600, 540 | height: 450, 541 | maxWidth: 600, 542 | maxHeight: 450, 543 | minWidth: 600, 544 | minHeight: 450, 545 | resizable: false, 546 | 547 | // close with the main window 548 | parent: mainWindow, 549 | 550 | icon: iconPath, 551 | frame: DRAW_FRAME 552 | }) 553 | 554 | // Register shortcuts 555 | electronLocalshortcut.register(newServerDialog, 'Esc', () => { 556 | newServerDialog.close() 557 | }) 558 | 559 | // cleanup 560 | newServerDialog.on('closed', () => { 561 | newServerDialog = null 562 | }) 563 | } 564 | } 565 | 566 | /** 567 | * Browse a URL using Europa's browser window 568 | * @param {String} url URL to browse to 569 | */ 570 | function showEuropaBrowser (e, url) { 571 | let urlObj 572 | try { 573 | urlObj = new URL(url) 574 | } catch (error) { 575 | const props = { 576 | 'type': 'error', 577 | 'title': 'URL Error', 578 | 'content': ` 579 |

    Invalid URL entered

    580 |

    Europa did not understant '${url}' as a valid URL. Please make sure that the URL includes the protocol (e.g., http:// or https://).

    `, 581 | 'primaryBtn': 'OK', 582 | 'secondaryBtn': '' 583 | } 584 | createDialog(mainWindow, props, `${Date.now()}`, (resp) => {}) 585 | return 586 | } 587 | 588 | addRecentURL(url) 589 | 590 | // Track for login on the opened url 591 | addTrackingForUrl(url) 592 | 593 | // Create a title for the new window 594 | let windowTitle = 'Europa @ '.concat(url.substring(0, 100)) 595 | if (url.length > 100) { 596 | windowTitle.concat('...') 597 | } 598 | 599 | let newJupyterWin = new BrowserWindow({ 600 | width: 1080, 601 | height: 768, 602 | preload: path.join(appDir, 'js', 'preload404.js'), 603 | webPreferences: { 604 | nodeIntegration: false, 605 | plugins: true 606 | }, 607 | icon: iconPath, 608 | frame: DRAW_FRAME, 609 | title: windowTitle 610 | }) 611 | 612 | windowTracker[urlObj.origin] = newJupyterWin 613 | newJupyterWin.loadURL(url) 614 | 615 | /* Set did-fail-load listener once */ 616 | newJupyterWin.webContents.on('did-fail-load', show404) 617 | 618 | /* cleanup */ 619 | newJupyterWin.on('closed', () => { 620 | newJupyterWin = null 621 | removeTrackingForUrl(url) 622 | }) 623 | 624 | newJupyterWin.once('ready-to-show', () => { 625 | newJupyterWin.show() 626 | }) 627 | 628 | /* Prevent the title from being updated */ 629 | newJupyterWin.on('page-title-updated', (evt) => { 630 | evt.preventDefault() 631 | }) 632 | 633 | /* Register shortcuts */ 634 | electronLocalshortcut.register(newJupyterWin, 'Ctrl+Shift+W', () => { 635 | newJupyterWin.close() 636 | }) 637 | } 638 | 639 | function addMainWindowShortcuts () { 640 | electronLocalshortcut.register(mainWindow, 'Ctrl+O', showOpenURLDialog) 641 | electronLocalshortcut.register(mainWindow, 'Ctrl+N', showNewServerDialog) 642 | } 643 | 644 | /** 645 | * Add a new url to the recent list and update mainWindow 646 | * @param {String} url URL to add to the recent list 647 | */ 648 | function addRecentURL (url) { 649 | const updatedUrls = recentUrlsDb.pushFront(url, MAX_RECENT_ITEMS).urls 650 | mainWindow.send('recent-urls', updatedUrls) 651 | } 652 | 653 | /** 654 | * Add listeners for getting and setting recent URL list 655 | */ 656 | function addRecentURLListeners () { 657 | ipcMain.on('delete-recent-url', (event, url) => { 658 | const updatedUrls = recentUrlsDb.remove(url).urls 659 | mainWindow.send('recent-urls', updatedUrls) 660 | }) 661 | } 662 | 663 | function printCLIHeader() { 664 | console.log("Europa " + VERSION_STRING) 665 | } 666 | 667 | function printCLIHelp(args, header, stderr) { 668 | let log_obj 669 | 670 | if (stderr) { 671 | log_obj = console.error 672 | } else { 673 | log_obj = console.log 674 | } 675 | 676 | if (header) { 677 | printCLIHeader() 678 | log_obj("") 679 | } 680 | 681 | log_obj("USAGE:\n\t" + args[0] + " [options]") 682 | log_obj() 683 | log_obj("OPTIONS:") 684 | log_obj("\t-u,--url \tOpen a europa window for on start.") 685 | log_obj("\t-v,--version \tPrint version number and exit.") 686 | log_obj("\t-h,--help \tPrint this help message and exit.") 687 | log_obj() 688 | log_obj("OTHER:") 689 | log_obj("\tCopyright (c) 2020-21 Europa Authors") 690 | log_obj("\tReport bugs at: https://europa.suyashmahar.com/report-bugs") 691 | } 692 | 693 | function printCLIVersion() { 694 | printCLIHeader(); 695 | } 696 | 697 | /** 698 | * Parse command line arguments 699 | */ 700 | function parseCmdlineArgs() { 701 | let args = process.argv 702 | let result = {'url': ''} 703 | 704 | for (let i = 1; i < args.length; i++) { 705 | if (args[i] == "--help" || args[i] == "-h") { 706 | printCLIHelp(args, true) 707 | app.exit(0) 708 | } else if (args[i] == "--version" || args[i] == "-v") { 709 | printCLIVersion() 710 | app.exit(0) 711 | } else if (args[i] == "--url" || args[i] == "-u") { 712 | if (args.length < i + 2) { 713 | console.error("--url requires exactly one argument") 714 | console.error() 715 | printCLIHelp(args, false, true) 716 | } 717 | 718 | result['url'] = args[i + 1] 719 | i += 1 720 | } else { 721 | console.error("Unknown argument '" + args[i] + "'") 722 | console.error() 723 | printCLIHelp(args, false, true) 724 | app.exit(1) 725 | } 726 | } 727 | 728 | return result 729 | } 730 | 731 | function main () { 732 | let args = parseCmdlineArgs() 733 | 734 | fixASARPath() 735 | 736 | setupIcons() 737 | startHTTPProxy() 738 | 739 | Menu.setApplicationMenu(null) 740 | 741 | mainWindow = new Window({ 742 | file: path.join('renderer', 'welcome.html'), 743 | titleBarStyle: 'hidden', 744 | icon: iconPath, 745 | frame: DRAW_FRAME 746 | }) 747 | 748 | mainWindow.once('show', () => { 749 | mainWindow.webContents.send('recent-urls', recentUrlsDb.urls) 750 | }) 751 | 752 | addMainWindowShortcuts() 753 | addRecentURLListeners() 754 | 755 | ipcMain.on('get-sys-cfg-jupyter-lab', (event) => 756 | event.sender.send('asynchronous-reply', getPythonInterpreter())) 757 | ipcMain.on('start-server', startServerOS) 758 | ipcMain.on('save-settings', (e, settingsObj) => setSettings(settingsObj)) 759 | ipcMain.on('clear-cache', clearCache) 760 | ipcMain.on('options-window', showOptionsWindow) 761 | ipcMain.on('open-new-url', showOpenURLDialog) 762 | ipcMain.on('new-server-window', showNewServerDialog) 763 | ipcMain.on('open-url', showEuropaBrowser) 764 | ipcMain.on('show-about-europa', e => showAboutDialog(e.sender)) 765 | ipcMain.on('dialog-result', (event, id, resp) => dialogRespTracker[id](resp)) 766 | 767 | if (args['url'] != "") { 768 | showEuropaBrowser(null, args.url) 769 | } 770 | } 771 | 772 | app.on('ready', main) 773 | 774 | app.on('window-all-closed', function () { 775 | app.quit() 776 | }) 777 | -------------------------------------------------------------------------------- /src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "europa", 3 | "version": "1.1.1", 4 | "description": "JupyterLab's Desktop client", 5 | "homepage": "europa.suyashmahar.com", 6 | "author": { 7 | "name": "Suyash Mahar", 8 | "email": "contact@suyashmahar.com" 9 | }, 10 | "main": "main.js", 11 | "repository": "https://github.com/suyashmahar/europa", 12 | "keywords": [ 13 | "JupyterLab", 14 | "Jupyter" 15 | ], 16 | "license": "AGPL-3.0-or-later", 17 | "devDependencies": { 18 | "devtron": "^1.4.0", 19 | "electron": "^9.0.0", 20 | "electron-builder": "^22.14.5", 21 | "standard": "^12.0.1" 22 | }, 23 | "dependencies": { 24 | "command-exists": "^1.2.9", 25 | "electron-context-menu": "^3.1.2", 26 | "electron-localshortcut": "^3.2.1", 27 | "electron-reload": "^1.2.5", 28 | "electron-store": "^2.0.0", 29 | "electron-util": "^0.14.2", 30 | "request": "^2.88.2", 31 | "spectre.css": "^0.5.3" 32 | }, 33 | "build": { 34 | "directories": { 35 | "output": "../build/", 36 | "buildResources": "./build-resources/" 37 | }, 38 | "appId": "com.suyashmahar.europa", 39 | "mac": { 40 | "category": "Utilities" 41 | }, 42 | "linux": { 43 | "icon": "build-resources/icon.png", 44 | "category": "Utility", 45 | "target": [ 46 | "AppImage", 47 | "snap", 48 | "deb", 49 | "rpm", 50 | "freebsd", 51 | "pacman", 52 | "zip", 53 | "tar.xz", 54 | "tar.gz" 55 | ] 56 | }, 57 | "win": { 58 | "target": [ 59 | "nsis", 60 | "portable" 61 | ] 62 | }, 63 | "extraResources": [ 64 | { 65 | "from": "assets", 66 | "to": "assets" 67 | }, 68 | { 69 | "from": "config", 70 | "to": "config" 71 | }, 72 | { 73 | "from": "scripts", 74 | "to": "scripts" 75 | } 76 | ] 77 | }, 78 | "scripts": { 79 | "pack": "electron-builder --dir", 80 | "start": "electron .", 81 | "dist": "electron-builder" 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/renderer/404_page/404page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Open a new server 7 | 8 | 9 | 10 | 11 | 12 | 13 |
    14 |
    15 |
    16 |
    17 | 18 |
    19 |
    20 |
    Something went wrong
    21 |
    Europa couldn't load that page.
    22 |
    23 |
    24 | Please make sure that: 25 |
      26 |
    • The URL points to a reachable JupyterLab server.
    • 27 |
    • To access network machine, you have internet connectivity.
    • 28 |
    29 |
    30 | Press Ctrl+R to refresh the page. 31 | 32 | 33 | 34 |
    35 |
    36 |
    37 |
    38 |
    39 |
    40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/renderer/add_url/add_url.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Open a new server 7 | 8 | 9 | 10 | 11 |
    12 |
    13 |
    14 | 15 | Example: http://localhost:8888, https://your-domain.tld:1080 16 |
    17 |
    18 | 19 | 20 |
    21 |
    22 |
    23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/renderer/dialog_box/dialogbox.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Create new server 6 | 7 | 8 | 9 | 10 | 11 |
    12 |
    13 |
    14 | 15 |
    16 |
    17 |
    18 |
    19 | Do you want to set common shortcuts?
    20 | Note: This would save the shortcuts permanently to the server. 21 |
    22 |
    23 |
    24 |
    25 |
    26 |
    27 | 28 | 29 |
    30 |
    31 | 32 |
    33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/renderer/new_server/advanceduser.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Create new server 6 | 7 | 8 | 9 | 10 | 11 |
    12 |
    13 |
    14 |
    15 | 16 | 17 | 18 |
    19 |
    20 |
    21 |
    Starting server...
    22 |
    23 | 24 |
    25 |
    26 | 27 |

    Advanced configuration

    28 |
    29 | 30 |
    31 |
    32 | 33 |
    34 | 35 | 38 |
    39 | 40 |
    41 |
    42 | 43 |
    44 | 45 | 48 |
    49 | 50 |
    51 |
    52 | 53 |
    54 | 55 | 58 |
    59 | 60 | 61 | autofill 62 | 63 |
    64 | 65 | 66 |
    67 | 68 |
    69 | 70 |
    71 | 72 |
    73 | 74 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /src/renderer/new_server/beginneruser.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Create new server 6 | 7 | 8 | 9 | 10 | 11 |
    12 |
    13 |
    14 |
    15 | 16 | 17 | 18 |
    19 |
    20 |
    21 |
    Starting server...
    22 |
    23 | 24 |
    25 |
    26 | 27 |

    Simple config

    28 |
    29 | 30 |
    31 |
    32 | 33 |
    34 |
    35 |
    Choose a directory to start jupyter lab at
    36 | 37 |
    38 |
    39 | 40 |
    41 | 42 |
    43 | 44 |
    45 |
    46 | 47 |
    48 | 49 | 50 |
    51 | 52 |
    53 | 54 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/renderer/new_server/newserver.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Create new server 6 | 7 | 8 | 9 | 10 | 11 | 12 |
    13 |
    14 |

    Create new server

    15 | Choose an option to proceed 16 |
    17 |
    18 |
    19 |
    20 | 21 |
    22 |
    23 |

    Beginner

    24 | I just need local JupyterLab running 25 |
    26 |
    27 |
    28 |
    29 |
    30 |
    31 | 32 |
    33 |
    34 |

    Advanced user

    35 | I want to make sure everything is right 36 |
    37 |
    38 |
    39 | 42 |
    43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/renderer/settings_page/settings.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Options 6 | 7 | 8 | 9 | 10 | 11 | 12 |
    13 |
    14 |

    Options

    15 |
    16 | 17 |
    18 |
    19 |

    Europa extras

    20 |
    21 |
    Keyboard shortcuts dialog
    22 |

    Configure when europa should ask to set shortcuts on a server:

    23 | 24 |
    25 | 26 | 29 |
    30 |
    31 | 32 | 35 |
    36 |
    37 |
    38 |
    39 | 40 |
    41 |
    42 |

    Cookies and cache

    43 |

    You can delete all the saved login information (cookies). 44 | Use this option if you are experiencing issues with server login 45 | or Europa shows unsupported JupyterLab version warning.

    46 |

    Warning: This will log you out of all the servers on Europa.

    47 | Clear cache 48 |
    49 |
    50 | 51 | 59 | 60 |
    61 |
    62 | 63 | 64 |
    65 |
    66 |
    67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/renderer/welcome.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Europa 7 | 8 | 9 | 10 | 11 | 12 |
    13 |
    14 |
    15 |

    Europa

    16 |

    Jupyter Lab's Moon

    17 |
    18 |
    19 |
    20 |
    26 | 27 |
    New server
    28 |
    29 | 30 |
    36 | 37 |
    Open URL
    38 |
    39 | 40 |
    46 | 47 |
    Options
    48 |
    49 | 50 |
    51 |
    52 |
    53 |
    54 | 55 |
    56 |

    Recent

    57 |
      58 |
    • No recent items
    • 59 |
    60 |
    61 | 62 |
    63 |

    Help

    64 | 72 |
    73 |
    74 |
    75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /src/scripts/posix/start_jupyter_lab.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # @file start_jupyter_lab.sh 4 | # @brief Script to start jupyter lab on Linux 5 | # Usage: 6 | # ./start_jupyter_lab.sh {|auto} 7 | # @author Suyash Mahar 8 | 9 | # Run on a successful retrieval of the url 10 | pingSuccess() { 11 | local url="$1" 12 | 13 | echo "$url" 14 | exit 0 15 | } 16 | 17 | # Run if the jupyter server fails to start 18 | pingFailure() { 19 | local msg="$1" 20 | local tempFile="$2" 21 | 22 | echo "Failed: ${msg}. Log at: ${tempFile}" 23 | exit 1 24 | } 25 | 26 | # Parse the input arguments to the script 27 | parseArgs() { 28 | py="$1" 29 | startAt="$2" 30 | portNum="$3" 31 | 32 | if [ "$#" != 3 ]; then 33 | pingFailure "Wrong number of arguments, check docs." "$tempFile" 34 | fi 35 | } 36 | 37 | watchServer() { 38 | local pid="$1" 39 | local tempFile="$2" 40 | 41 | while true; do 42 | # Check if the process is still alive 43 | if ! kill -0 "$pid" > /dev/null 2>&1; then 44 | pingFailure "Command killed" "$tempFile" 45 | fi 46 | 47 | # Check if the tempFile has the url yet 48 | local url=$(cat "$tempFile" | grep -Eo '(http|https)://.*$' | tail -n1) 49 | 50 | if [ "$url" != "" ]; then 51 | pingSuccess "$url" 52 | fi 53 | 54 | sleep 1 55 | done 56 | } 57 | 58 | doChecks() { 59 | local tempFile=$1 60 | 61 | # Check for python 62 | if ! type "${py}" >/dev/null; then 63 | pingFailure "Python not found" "${tempFile}" 64 | fi 65 | 66 | # Check for JupyterLab 67 | if ! "${py}" -m jupyterlab --help >/dev/null 2>&1; then 68 | pingFailure "JupyterLab is not installed" "${tempFile}" 69 | fi 70 | 71 | # Check start directory 72 | if [ ! -d "${startAt}" ]; then 73 | pingFailure "Startup directory does not exist" "${tempFile}" 74 | fi 75 | } 76 | 77 | main() { 78 | parseArgs "$@" 79 | 80 | local tempFile="$(mktemp)" 81 | 82 | doChecks "${tempFile}" 83 | 84 | local portStr="" 85 | if [ "$portNum" != 'auto' ]; then 86 | portStr="--port=${portNum}" 87 | fi 88 | 89 | nohup "${py}"\ 90 | -m jupyterlab \ 91 | "${portStr}" \ 92 | "--notebook-dir=${startAt}" \ 93 | --no-browser > "${tempFile}" 2>&1 & 94 | 95 | watchServer "$!" "$tempFile" 96 | } 97 | 98 | main "$@" 99 | -------------------------------------------------------------------------------- /src/scripts/windows/start_jupyter_lab.ps1: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env pwsh 2 | # @file start_jupyter_lab.ps1 3 | # @brief Script to start jupyter lab 4 | # Usage: 5 | # .\start_jupyter_lab.ps1 -py -startAt -port {|auto} 6 | # @author Suyash Mahar 7 | 8 | # Read parameters 9 | param( 10 | [Parameter(Mandatory)] 11 | [string]$py, 12 | 13 | [Parameter(Mandatory)] 14 | [string]$startAt, 15 | 16 | [Parameter(Mandatory)] 17 | [string]$portNum 18 | ) 19 | 20 | # Parses the tempFile to get the server's URL 21 | function Get-ServerURL($tempFile) { 22 | Get-Content "$tempFile" ` 23 | | Select-String -Pattern '(http|https)://.*$' -All ` 24 | | ForEach-Object { $_.Matches } ` 25 | | ForEach-Object { $_.Value } ` 26 | | Select-Object -Last 1 27 | } 28 | 29 | # If the jupyter server was not started, this function writes 'Failed' to 30 | # stdout. This output is expected to be read by the caller Electron process 31 | # to notify the user 32 | function Ping-Failure() { 33 | Write-Host 'Failed' 34 | } 35 | 36 | # Writes the URL of the server to the stdout on success, this URL is then read 37 | # from the electron process 38 | function Ping-Success($serverURL) { 39 | Write-Host "${serverURL}" 40 | } 41 | 42 | # Check the output of the process 43 | function Watch-Server($job, $tempFile) { 44 | if (!$job) { 45 | Ping-Failure 46 | return 47 | } 48 | 49 | $serverURL = $null 50 | 51 | # Check if we have found something yet 52 | while (($serverURL -eq "") -or ($null -eq $serverURL)) { 53 | 54 | # Check if the process is still running 55 | if ($job.HasExited) { 56 | Ping-Failure 57 | return 58 | } 59 | 60 | $serverURL = Get-ServerURL $tempfile 61 | Start-Sleep 0.5 62 | } 63 | 64 | Ping-Success "$serverURL" 65 | return 66 | } 67 | 68 | # Create a string for the port number 69 | $portStr = "" 70 | if ($portNum -ne "auto") { 71 | $portStr = "--port=${portNum}" 72 | } 73 | 74 | # Create a new temporary file to write output of the process to 75 | $tempFile = New-TemporaryFile 76 | 77 | # Start jupyter lab 78 | $job = Start-Process powershell ` 79 | -NoNewWindow ` 80 | -Argumentlist ` 81 | "${py}", ` 82 | "-m jupyterlab ${portStr} --no-browser --notebook-dir=${startAt} > $tempFile 2>&1"` 83 | -PassThru 84 | 85 | # Watch the status of the server and notify electron 86 | Watch-Server $job $tempFile 87 | -------------------------------------------------------------------------------- /src/vendor/popper/popper.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) Federico Zivolo 2018 3 | Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). 4 | */(function(e,t){'object'==typeof exports&&'undefined'!=typeof module?module.exports=t():'function'==typeof define&&define.amd?define(t):e.Popper=t()})(this,function(){'use strict';function e(e){return e&&'[object Function]'==={}.toString.call(e)}function t(e,t){if(1!==e.nodeType)return[];var o=getComputedStyle(e,null);return t?o[t]:o}function o(e){return'HTML'===e.nodeName?e:e.parentNode||e.host}function n(e){if(!e)return document.body;switch(e.nodeName){case'HTML':case'BODY':return e.ownerDocument.body;case'#document':return e.body;}var i=t(e),r=i.overflow,p=i.overflowX,s=i.overflowY;return /(auto|scroll|overlay)/.test(r+s+p)?e:n(o(e))}function r(e){return 11===e?re:10===e?pe:re||pe}function p(e){if(!e)return document.documentElement;for(var o=r(10)?document.body:null,n=e.offsetParent;n===o&&e.nextElementSibling;)n=(e=e.nextElementSibling).offsetParent;var i=n&&n.nodeName;return i&&'BODY'!==i&&'HTML'!==i?-1!==['TD','TABLE'].indexOf(n.nodeName)&&'static'===t(n,'position')?p(n):n:e?e.ownerDocument.documentElement:document.documentElement}function s(e){var t=e.nodeName;return'BODY'!==t&&('HTML'===t||p(e.firstElementChild)===e)}function d(e){return null===e.parentNode?e:d(e.parentNode)}function a(e,t){if(!e||!e.nodeType||!t||!t.nodeType)return document.documentElement;var o=e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING,n=o?e:t,i=o?t:e,r=document.createRange();r.setStart(n,0),r.setEnd(i,0);var l=r.commonAncestorContainer;if(e!==l&&t!==l||n.contains(i))return s(l)?l:p(l);var f=d(e);return f.host?a(f.host,t):a(e,d(t).host)}function l(e){var t=1=o.clientWidth&&n>=o.clientHeight}),l=0a[e]&&!t.escapeWithReference&&(n=J(f[o],a[e]-('right'===e?f.width:f.height))),ae({},o,n)}};return l.forEach(function(e){var t=-1===['left','top'].indexOf(e)?'secondary':'primary';f=le({},f,m[t](e))}),e.offsets.popper=f,e},priority:['left','right','top','bottom'],padding:5,boundariesElement:'scrollParent'},keepTogether:{order:400,enabled:!0,fn:function(e){var t=e.offsets,o=t.popper,n=t.reference,i=e.placement.split('-')[0],r=Z,p=-1!==['top','bottom'].indexOf(i),s=p?'right':'bottom',d=p?'left':'top',a=p?'width':'height';return o[s]r(n[s])&&(e.offsets.popper[d]=r(n[s])),e}},arrow:{order:500,enabled:!0,fn:function(e,o){var n;if(!q(e.instance.modifiers,'arrow','keepTogether'))return e;var i=o.element;if('string'==typeof i){if(i=e.instance.popper.querySelector(i),!i)return e;}else if(!e.instance.popper.contains(i))return console.warn('WARNING: `arrow.element` must be child of its popper element!'),e;var r=e.placement.split('-')[0],p=e.offsets,s=p.popper,d=p.reference,a=-1!==['left','right'].indexOf(r),l=a?'height':'width',f=a?'Top':'Left',m=f.toLowerCase(),h=a?'left':'top',c=a?'bottom':'right',u=S(i)[l];d[c]-us[c]&&(e.offsets.popper[m]+=d[m]+u-s[c]),e.offsets.popper=g(e.offsets.popper);var b=d[m]+d[l]/2-u/2,y=t(e.instance.popper),w=parseFloat(y['margin'+f],10),E=parseFloat(y['border'+f+'Width'],10),v=b-e.offsets.popper[m]-w-E;return v=$(J(s[l]-u,v),0),e.arrowElement=i,e.offsets.arrow=(n={},ae(n,m,Q(v)),ae(n,h,''),n),e},element:'[x-arrow]'},flip:{order:600,enabled:!0,fn:function(e,t){if(W(e.instance.modifiers,'inner'))return e;if(e.flipped&&e.placement===e.originalPlacement)return e;var o=v(e.instance.popper,e.instance.reference,t.padding,t.boundariesElement,e.positionFixed),n=e.placement.split('-')[0],i=T(n),r=e.placement.split('-')[1]||'',p=[];switch(t.behavior){case he.FLIP:p=[n,i];break;case he.CLOCKWISE:p=z(n);break;case he.COUNTERCLOCKWISE:p=z(n,!0);break;default:p=t.behavior;}return p.forEach(function(s,d){if(n!==s||p.length===d+1)return e;n=e.placement.split('-')[0],i=T(n);var a=e.offsets.popper,l=e.offsets.reference,f=Z,m='left'===n&&f(a.right)>f(l.left)||'right'===n&&f(a.left)f(l.top)||'bottom'===n&&f(a.top)f(o.right),g=f(a.top)f(o.bottom),b='left'===n&&h||'right'===n&&c||'top'===n&&g||'bottom'===n&&u,y=-1!==['top','bottom'].indexOf(n),w=!!t.flipVariations&&(y&&'start'===r&&h||y&&'end'===r&&c||!y&&'start'===r&&g||!y&&'end'===r&&u);(m||b||w)&&(e.flipped=!0,(m||b)&&(n=p[d+1]),w&&(r=G(r)),e.placement=n+(r?'-'+r:''),e.offsets.popper=le({},e.offsets.popper,C(e.instance.popper,e.offsets.reference,e.placement)),e=P(e.instance.modifiers,e,'flip'))}),e},behavior:'flip',padding:5,boundariesElement:'viewport'},inner:{order:700,enabled:!1,fn:function(e){var t=e.placement,o=t.split('-')[0],n=e.offsets,i=n.popper,r=n.reference,p=-1!==['left','right'].indexOf(o),s=-1===['top','left'].indexOf(o);return i[p?'left':'top']=r[o]-(s?i[p?'width':'height']:0),e.placement=T(t),e.offsets.popper=g(i),e}},hide:{order:800,enabled:!0,fn:function(e){if(!q(e.instance.modifiers,'hide','preventOverflow'))return e;var t=e.offsets.reference,o=D(e.instance.modifiers,function(e){return'preventOverflow'===e.name}).boundaries;if(t.bottomo.right||t.top>o.bottom||t.right