Delete node_modules directory
This commit is contained in:
-201
@@ -1,201 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright {yyyy} {name of copyright owner}
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-27
@@ -1,27 +0,0 @@
|
|||||||
# Gitbook Back to Top Button Plugin [](https://badge.fury.io/js/gitbook-plugin-back-to-top-button)
|
|
||||||
|
|
||||||
This plugin adds a back to top button to your GitBook. All three GitBook themes (White, Sepia, Night) are supported.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
Add the plugin to your `book.json`:
|
|
||||||
|
|
||||||
```
|
|
||||||
{
|
|
||||||
"plugins" : [ "back-to-top-button" ]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Screenshots
|
|
||||||
|
|
||||||
The back to top button in action:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Changelog
|
|
||||||
|
|
||||||
* 0.1.0 Releases:
|
|
||||||
* 0.1.0 First working release
|
|
||||||
* 0.1.1 Minimal Gitbook version changed to 3.1.1
|
|
||||||
* 0.1.2 Added link to GitHub repository
|
|
||||||
* 0.1.3 Added support for GitBook themes (White, Sepia, Night)
|
|
||||||
-55
@@ -1,55 +0,0 @@
|
|||||||
.back-to-top {
|
|
||||||
position: fixed;
|
|
||||||
bottom: 25px;
|
|
||||||
right: 25px;
|
|
||||||
background: rgba(0, 0, 0, 0.5);
|
|
||||||
width: 50px;
|
|
||||||
height: 50px;
|
|
||||||
display: block;
|
|
||||||
text-decoration: none;
|
|
||||||
-webkit-border-radius: 35px;
|
|
||||||
-moz-border-radius: 35px;
|
|
||||||
border-radius: 35px;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.back-to-top i {
|
|
||||||
color: #fff;
|
|
||||||
margin: 0;
|
|
||||||
position: relative;
|
|
||||||
left: 15px;
|
|
||||||
top: 14px;
|
|
||||||
font-size: 22px;
|
|
||||||
}
|
|
||||||
.back-to-top:hover {
|
|
||||||
background: rgba(0, 0, 0, 0.9);
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .back-to-top {
|
|
||||||
background: rgba(112, 66, 20, 0.5);
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .back-to-top i {
|
|
||||||
color: #f3eacb;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .back-to-top:hover {
|
|
||||||
background: rgba(112, 66, 20, 0.9);
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .back-to-top {
|
|
||||||
background: rgba(189, 202, 219, 0.5);
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .back-to-top i {
|
|
||||||
color: #1C1F2B;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .back-to-top:hover {
|
|
||||||
background: rgba(189, 202, 219, 0.9);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media only screen
|
|
||||||
and (min-device-width: 320px)
|
|
||||||
and (max-device-width: 480px)
|
|
||||||
and (-webkit-min-device-pixel-ratio: 2)
|
|
||||||
and (orientation: portrait) {
|
|
||||||
.back-to-top {
|
|
||||||
bottom: 10px;
|
|
||||||
right: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
var gitbook = window.gitbook;
|
|
||||||
|
|
||||||
gitbook.events.on('page.change', function() {
|
|
||||||
|
|
||||||
var back_to_top_button = ['<div class="back-to-top"><i class="fa fa-arrow-up"></i></div>'].join("");
|
|
||||||
$(".book").append(back_to_top_button)
|
|
||||||
|
|
||||||
$(".back-to-top").hide();
|
|
||||||
|
|
||||||
$('.book-body,.body-inner').on('scroll', function () {
|
|
||||||
if ($(this).scrollTop() > 100) {
|
|
||||||
$('.back-to-top').fadeIn();
|
|
||||||
} else {
|
|
||||||
$('.back-to-top').fadeOut();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.back-to-top').click(function () {
|
|
||||||
$('.book-body,.body-inner').animate({
|
|
||||||
scrollTop: 0
|
|
||||||
}, 800);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
-11
@@ -1,11 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
website: {
|
|
||||||
assets: './assets',
|
|
||||||
js: [
|
|
||||||
'plugin.js'
|
|
||||||
],
|
|
||||||
css: [
|
|
||||||
'plugin.css'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
-48
@@ -1,48 +0,0 @@
|
|||||||
{
|
|
||||||
"_from": "gitbook-plugin-back-to-top-button",
|
|
||||||
"_id": "gitbook-plugin-back-to-top-button@0.1.4",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-B97MdUp4YhNkSmEc1v+5E21nRaI+ppNKjz2oZelZ8DTuumOMe/e0QizXC2ymxO8iYPkWuaqzaeGedHpxRq/Yhw==",
|
|
||||||
"_location": "/gitbook-plugin-back-to-top-button",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "tag",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "gitbook-plugin-back-to-top-button",
|
|
||||||
"name": "gitbook-plugin-back-to-top-button",
|
|
||||||
"escapedName": "gitbook-plugin-back-to-top-button",
|
|
||||||
"rawSpec": "",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "latest"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmmirror.com/gitbook-plugin-back-to-top-button/-/gitbook-plugin-back-to-top-button-0.1.4.tgz",
|
|
||||||
"_shasum": "e6218338b0ef19d58e6f6600994350b76e8035df",
|
|
||||||
"_spec": "gitbook-plugin-back-to-top-button",
|
|
||||||
"_where": "D:\\Book",
|
|
||||||
"author": {
|
|
||||||
"name": "STÜBER SYSTEMS",
|
|
||||||
"email": "gitbook@stueber.de"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/stuebersystems/gitbook-plugin-back-to-top-button/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Adds a back to top button to your Gitbook",
|
|
||||||
"engines": {
|
|
||||||
"gitbook": ">=3.1.1"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/stuebersystems/gitbook-plugin-back-to-top-button",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"main": "index.js",
|
|
||||||
"name": "gitbook-plugin-back-to-top-button",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/stuebersystems/gitbook-plugin-back-to-top-button.git"
|
|
||||||
},
|
|
||||||
"version": "0.1.4"
|
|
||||||
}
|
|
||||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 24 KiB |
-21
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2017 David Moreno García
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
# Code plugin for GitBook
|
|
||||||
|
|
||||||
Code blocks are cool but can be cooler. This plugin adds lines numbers for multi-line blocks and a copy button to easily copy the content of your block.
|
|
||||||
|
|
||||||
## Cool, can I see it working?
|
|
||||||
|
|
||||||
The next image shows a single line code block:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
When displaying code with multiple lines, line numbers will be added:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## How can I use this plugin?
|
|
||||||
|
|
||||||
You only have to edit your book.json and modify it adding something like this:
|
|
||||||
|
|
||||||
```json
|
|
||||||
"plugins" : [ "code" ],
|
|
||||||
```
|
|
||||||
|
|
||||||
This will set up everything for you. If you want to get rid of the copy buttons use add this section too:
|
|
||||||
|
|
||||||
```json
|
|
||||||
"pluginsConfig": {
|
|
||||||
"code": {
|
|
||||||
"copyButtons": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
-37
@@ -1,37 +0,0 @@
|
|||||||
#code-textarea {
|
|
||||||
height: 0;
|
|
||||||
position: fixed;
|
|
||||||
top: -1000px;
|
|
||||||
width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.code-wrapper {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.code-wrapper i {
|
|
||||||
color: #c1c7cd;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: bold;
|
|
||||||
position: absolute;
|
|
||||||
right: 1em;
|
|
||||||
top: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.code-wrapper pre {
|
|
||||||
background: #f7f8f9;
|
|
||||||
border-radius: 3px;
|
|
||||||
counter-reset: line;
|
|
||||||
font-size: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.code-wrapper pre > code > span.code-line:before {
|
|
||||||
counter-increment: line;
|
|
||||||
color: #c1c7cd;
|
|
||||||
content: counter(line);
|
|
||||||
display: inline-block;
|
|
||||||
font-size: 12px;
|
|
||||||
margin-right: 1.5em;
|
|
||||||
width: 1em;
|
|
||||||
}
|
|
||||||
-91
@@ -1,91 +0,0 @@
|
|||||||
require(['gitbook', 'jQuery'], function(gitbook, $) {
|
|
||||||
|
|
||||||
const TERMINAL_HOOK = '**[terminal]'
|
|
||||||
|
|
||||||
var pluginConfig = {};
|
|
||||||
var timeouts = {};
|
|
||||||
|
|
||||||
function addCopyButton(wrapper) {
|
|
||||||
wrapper.append(
|
|
||||||
$('<i class="fa fa-clone t-copy"></i>')
|
|
||||||
.click(function() {
|
|
||||||
copyCommand($(this));
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addCopyTextarea() {
|
|
||||||
|
|
||||||
/* Add also the text area that will allow to copy */
|
|
||||||
$('body').append('<textarea id="code-textarea" />');
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyCommand(button) {
|
|
||||||
pre = button.parent();
|
|
||||||
textarea = $('#code-textarea');
|
|
||||||
textarea.val(pre.text());
|
|
||||||
textarea.focus();
|
|
||||||
textarea.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
pre.focus();
|
|
||||||
updateCopyButton(button);
|
|
||||||
}
|
|
||||||
|
|
||||||
function initializePlugin(config) {
|
|
||||||
pluginConfig = config.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
function format_code_block(block) {
|
|
||||||
/*
|
|
||||||
* Add line numbers for multiline blocks.
|
|
||||||
*/
|
|
||||||
code = block.children('code');
|
|
||||||
lines = code.html().split('\n');
|
|
||||||
|
|
||||||
if (lines[lines.length - 1] == '') {
|
|
||||||
lines.splice(-1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lines.length > 1) {
|
|
||||||
console.log(lines);
|
|
||||||
lines = lines.map(line => '<span class="code-line">' + line + '</span>');
|
|
||||||
console.log(lines);
|
|
||||||
code.html(lines.join('\n'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add wrapper to pre element
|
|
||||||
wrapper = block.wrap('<div class="code-wrapper"></div>');
|
|
||||||
|
|
||||||
if (pluginConfig.copyButtons) {
|
|
||||||
addCopyButton(wrapper);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateCopyButton(button) {
|
|
||||||
id = button.attr('data-command');
|
|
||||||
button.removeClass('fa-clone').addClass('fa-check');
|
|
||||||
|
|
||||||
// Clear timeout
|
|
||||||
if (id in timeouts) {
|
|
||||||
clearTimeout(timeouts[id]);
|
|
||||||
}
|
|
||||||
timeouts[id] = window.setTimeout(function() {
|
|
||||||
button.removeClass('fa-check').addClass('fa-clone');
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
gitbook.events.bind('start', function(e, config) {
|
|
||||||
initializePlugin(config);
|
|
||||||
|
|
||||||
if (pluginConfig.copyButtons) {
|
|
||||||
addCopyTextarea();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
gitbook.events.bind('page.change', function() {
|
|
||||||
$('pre').each(function() {
|
|
||||||
format_code_block($(this));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
|
|
||||||
website: {
|
|
||||||
assets: './assets',
|
|
||||||
js: [
|
|
||||||
'plugin.js'
|
|
||||||
],
|
|
||||||
css: [
|
|
||||||
'plugin.css'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
-63
@@ -1,63 +0,0 @@
|
|||||||
{
|
|
||||||
"_from": "gitbook-plugin-code",
|
|
||||||
"_id": "gitbook-plugin-code@0.1.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-TE8CUFlN7da4SiN2LYx8qk+FX5w2O2IicEcn48sPTpA8gj9qKQqpYpGEdwgsDEev11shEjCZhDwFN//GQ7bdnA==",
|
|
||||||
"_location": "/gitbook-plugin-code",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "tag",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "gitbook-plugin-code",
|
|
||||||
"name": "gitbook-plugin-code",
|
|
||||||
"escapedName": "gitbook-plugin-code",
|
|
||||||
"rawSpec": "",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "latest"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmmirror.com/gitbook-plugin-code/-/gitbook-plugin-code-0.1.0.tgz",
|
|
||||||
"_shasum": "811a9600baef7558ae193cee7d5810001667e97b",
|
|
||||||
"_spec": "gitbook-plugin-code",
|
|
||||||
"_where": "D:\\Book",
|
|
||||||
"author": {
|
|
||||||
"name": "David Moreno-García",
|
|
||||||
"email": "david.mogar@gmail.com"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/davidmogar/gitbook-plugin-code/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Gitbook plugin to change style of code blocks",
|
|
||||||
"engines": {
|
|
||||||
"gitbook": ">2.5.0"
|
|
||||||
},
|
|
||||||
"gitbook": {
|
|
||||||
"properties": {
|
|
||||||
"copyButtons": {
|
|
||||||
"default": true,
|
|
||||||
"title": "Adds buttons to copy the commands",
|
|
||||||
"type": "boolean"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/davidmogar/gitbook-plugin-code",
|
|
||||||
"keywords": [
|
|
||||||
"gitbook",
|
|
||||||
"github",
|
|
||||||
"code",
|
|
||||||
"plugin"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "index.js",
|
|
||||||
"name": "gitbook-plugin-code",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/davidmogar/gitbook-plugin-code.git"
|
|
||||||
},
|
|
||||||
"version": "0.1.0"
|
|
||||||
}
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
/npm-debug.log
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>gitbook-plugin-expandable-chapters</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
</projectDescription>
|
|
||||||
-202
@@ -1,202 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright {yyyy} {name of copyright owner}
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
-33
@@ -1,33 +0,0 @@
|
|||||||
#Expandable chapters for GitBook
|
|
||||||
==============
|
|
||||||
|
|
||||||
Tiny change to the expandable-chapters plugin from https://github.com/DomainDrivenArchitecture/ to use smaller arrows.
|
|
||||||
|
|
||||||
### How to use it?
|
|
||||||
|
|
||||||
Add it to your `book.json` configuration:
|
|
||||||
|
|
||||||
```
|
|
||||||
{
|
|
||||||
plugins: ["expandable-chapters-small"]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Install your plugins using:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ gitbook install
|
|
||||||
```
|
|
||||||
|
|
||||||
### Configuration
|
|
||||||
|
|
||||||
There is no configuration needed at the moment, can be left empty.
|
|
||||||
|
|
||||||
```
|
|
||||||
{
|
|
||||||
"pluginsConfig": {
|
|
||||||
"expandable-chapters-small":{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Generated
Vendored
-29
@@ -1,29 +0,0 @@
|
|||||||
.book .book-summary .chapter > .articles {
|
|
||||||
overflow: hidden;
|
|
||||||
max-height: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.book .book-summary .chapter.expanded > .articles {
|
|
||||||
max-height: 9999px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.book .book-summary .exc-trigger {
|
|
||||||
position: absolute;
|
|
||||||
left: 12px;
|
|
||||||
top: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.book .book-summary ul.summary li a,
|
|
||||||
.book .book-summary ul.summary li span {
|
|
||||||
padding-left: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.book .book-summary .exc-trigger:before {
|
|
||||||
content: "\f105";
|
|
||||||
}
|
|
||||||
|
|
||||||
.book .book-summary .expanded > a .exc-trigger:before,
|
|
||||||
.book .book-summary .expanded > span .exc-trigger:before {
|
|
||||||
content: "\f107";
|
|
||||||
}
|
|
||||||
|
|
||||||
Generated
Vendored
-68
@@ -1,68 +0,0 @@
|
|||||||
require(['gitbook', 'jQuery'], function(gitbook, $) {
|
|
||||||
var TOGGLE_CLASSNAME = 'expanded',
|
|
||||||
CHAPTER = '.chapter',
|
|
||||||
ARTICLES = '.articles',
|
|
||||||
TRIGGER_TEMPLATE = '<i class="exc-trigger fa"></i>',
|
|
||||||
LS_NAMESPACE = 'expChapters';
|
|
||||||
var init = function () {
|
|
||||||
// adding the trigger element to each ARTICLES parent and binding the event
|
|
||||||
$(ARTICLES)
|
|
||||||
.parent(CHAPTER)
|
|
||||||
.children('a')
|
|
||||||
.append(
|
|
||||||
$(TRIGGER_TEMPLATE)
|
|
||||||
.on('click', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
toggle($(e.target).closest(CHAPTER));
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expand(lsItem());
|
|
||||||
//expand current selected chapter with it's parents
|
|
||||||
var activeChapter = $(CHAPTER + '.active');
|
|
||||||
expand(activeChapter);
|
|
||||||
expand(activeChapter.parents(CHAPTER));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
var toggle = function ($chapter) {
|
|
||||||
if ($chapter.hasClass('expanded')) {
|
|
||||||
collapse($chapter);
|
|
||||||
} else {
|
|
||||||
expand($chapter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var collapse = function ($chapter) {
|
|
||||||
if ($chapter.length && $chapter.hasClass(TOGGLE_CLASSNAME)) {
|
|
||||||
$chapter.removeClass(TOGGLE_CLASSNAME);
|
|
||||||
lsItem($chapter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var expand = function ($chapter) {
|
|
||||||
if ($chapter.length && !$chapter.hasClass(TOGGLE_CLASSNAME)) {
|
|
||||||
$chapter.addClass(TOGGLE_CLASSNAME);
|
|
||||||
lsItem($chapter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var lsItem = function () {
|
|
||||||
var map = JSON.parse(localStorage.getItem(LS_NAMESPACE)) || {}
|
|
||||||
if (arguments.length) {
|
|
||||||
var $chapters = arguments[0];
|
|
||||||
$chapters.each(function (index, element) {
|
|
||||||
var level = $(this).data('level');
|
|
||||||
var value = $(this).hasClass(TOGGLE_CLASSNAME);
|
|
||||||
map[level] = value;
|
|
||||||
})
|
|
||||||
localStorage.setItem(LS_NAMESPACE, JSON.stringify(map));
|
|
||||||
} else {
|
|
||||||
return $(CHAPTER).map(function(index, element){
|
|
||||||
if (map[$(this).data('level')]) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gitbook.events.bind('page.change', function() {
|
|
||||||
init()
|
|
||||||
});
|
|
||||||
});
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
// Extend website resources and html
|
|
||||||
website: {
|
|
||||||
assets: "./book",
|
|
||||||
js: [
|
|
||||||
"expandable-chapters-small.js"
|
|
||||||
],
|
|
||||||
css: [
|
|
||||||
"expandable-chapters-small.css"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
-44
@@ -1,44 +0,0 @@
|
|||||||
{
|
|
||||||
"_from": "gitbook-plugin-expandable-chapters-small",
|
|
||||||
"_id": "gitbook-plugin-expandable-chapters-small@0.1.7",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-bgmPN6AtXqFXH1q9HgWRHJbx0OXS3nuCU8gLgWEARz8adbFaW0p98NTCX3CaEuYTuU3t/UYWASAjQqI+zpCdng==",
|
|
||||||
"_location": "/gitbook-plugin-expandable-chapters-small",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "tag",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "gitbook-plugin-expandable-chapters-small",
|
|
||||||
"name": "gitbook-plugin-expandable-chapters-small",
|
|
||||||
"escapedName": "gitbook-plugin-expandable-chapters-small",
|
|
||||||
"rawSpec": "",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "latest"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmmirror.com/gitbook-plugin-expandable-chapters-small/-/gitbook-plugin-expandable-chapters-small-0.1.7.tgz",
|
|
||||||
"_shasum": "afc9e597b6851156fa7b00231ff8ab93f4feba4c",
|
|
||||||
"_spec": "gitbook-plugin-expandable-chapters-small",
|
|
||||||
"_where": "D:\\Book",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/chrisjake/gitbook-plugin-expandable-chapters-small/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Expandable chapters for convenient navigation within a gitbook",
|
|
||||||
"engines": {
|
|
||||||
"gitbook": ">=0.4.6"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/chrisjake/gitbook-plugin-expandable-chapters-small",
|
|
||||||
"license": "Apache 2",
|
|
||||||
"main": "index.js",
|
|
||||||
"name": "gitbook-plugin-expandable-chapters-small",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/chrisjake/gitbook-plugin-expandable-chapters-small.git"
|
|
||||||
},
|
|
||||||
"version": "0.1.7"
|
|
||||||
}
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"rules": {
|
|
||||||
"no-extra-boolean-cast": [ 0 ],
|
|
||||||
"indent": [ 2, 4 ],
|
|
||||||
"quotes": [ 2, "single" ],
|
|
||||||
"linebreak-style": [ 2, "unix" ],
|
|
||||||
"semi": [ 2, "always" ],
|
|
||||||
"no-unused-vars": [ 2, {
|
|
||||||
"vars": "all",
|
|
||||||
"args": "none"
|
|
||||||
} ],
|
|
||||||
"spaced-comment": [ 2, "always" ]
|
|
||||||
},
|
|
||||||
"env": {
|
|
||||||
"node": true,
|
|
||||||
"mocha": true,
|
|
||||||
"browser": true
|
|
||||||
},
|
|
||||||
"extends": "eslint:recommended"
|
|
||||||
}
|
|
||||||
-2
@@ -1,2 +0,0 @@
|
|||||||
!assets/website.css
|
|
||||||
less
|
|
||||||
-202
@@ -1,202 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright {yyyy} {name of copyright owner}
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
-288
@@ -1,288 +0,0 @@
|
|||||||
# plugin-fontsettings
|
|
||||||
|
|
||||||
This plugin adds font settings button in the GitBook website.
|
|
||||||
|
|
||||||
### Disable this plugin
|
|
||||||
|
|
||||||
This is a default plugin and it can be disabled using a `book.json` configuration:
|
|
||||||
|
|
||||||
```
|
|
||||||
{
|
|
||||||
plugins: ["-fontsettings"]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Configuration
|
|
||||||
|
|
||||||
This plugin can be configured in the `book.json`:
|
|
||||||
|
|
||||||
Default configuration is:
|
|
||||||
|
|
||||||
```js
|
|
||||||
{
|
|
||||||
"pluginsConfig": {
|
|
||||||
"fontsettings": {
|
|
||||||
"theme": 'white', // 'sepia', 'night' or 'white',
|
|
||||||
"family": 'sans', // 'serif' or 'sans',
|
|
||||||
"size": 2 // 1 - 4
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Plugin API
|
|
||||||
|
|
||||||
This plugin exposes the following API to easily allow new themes to manage the plugin behavior.
|
|
||||||
|
|
||||||
All API functions are called using the prefix `gitbook.fontsettings.`, for instance `gitbook.fontsettings.enlargeFontSize()`.
|
|
||||||
|
|
||||||
#### Font manipulation
|
|
||||||
|
|
||||||
##### `gitbook.fontsettings.enlargeFontSize()`
|
|
||||||
|
|
||||||
Increases the font size of the document by one. Max value is `4`.
|
|
||||||
|
|
||||||
##### `gitbook.fontsettings.reduceFontSize()`
|
|
||||||
|
|
||||||
Decreases the font size of the document by one. Min value is `1`.
|
|
||||||
|
|
||||||
#### Font families
|
|
||||||
|
|
||||||
Each font family should be described as:
|
|
||||||
|
|
||||||
```js
|
|
||||||
var fontFamily = {
|
|
||||||
config: 'sans', // name of the font family in book.json for your theme
|
|
||||||
text: 'Sans', // display name of the font family in menu
|
|
||||||
id: 0 // the id appended to the CSS class for this font-family
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
The `text` property will be used to display the font-family name in the fontsettings dropdown menu.
|
|
||||||
|
|
||||||
The `config` property allows you to let the users of your theme choose a default font family in their `book.json`. You will have to handle setting the chosen font family in your theme's frontend JavaScript.
|
|
||||||
|
|
||||||
For instance:
|
|
||||||
|
|
||||||
```json
|
|
||||||
// book.json
|
|
||||||
{
|
|
||||||
plugins: ["my-theme"],
|
|
||||||
pluginsConfig: {
|
|
||||||
"my-theme": {
|
|
||||||
"font-family": "sans"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
```js
|
|
||||||
// my-theme.js
|
|
||||||
require('gitbook', function(gitbook) {
|
|
||||||
var FONT_FAMILIES = [
|
|
||||||
{
|
|
||||||
config: 'sans',
|
|
||||||
text: 'Sans',
|
|
||||||
id: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
config: 'serif',
|
|
||||||
text: 'Serif',
|
|
||||||
id: 1
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
gitbook.events.on('start', function(e, config) {
|
|
||||||
// Read configuration
|
|
||||||
var themeConfig = config['my-theme'],
|
|
||||||
defaultFont = themeConfig['font-family'];
|
|
||||||
|
|
||||||
// Initialize new font families
|
|
||||||
gitbook.fontsettings.setFamilies(FONT_FAMILIES);
|
|
||||||
// Set to configured font-family
|
|
||||||
gitbook.fontsettings.setFamily(defaultFont);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
The `id` property lets you define a specific id to use for your CSS rules as explained below.
|
|
||||||
|
|
||||||
##### CSS rules
|
|
||||||
|
|
||||||
The CSS class `font-family-<id>` will be applied to the theme book's root element `<div class="book">` when a font family is selected in the menu.
|
|
||||||
|
|
||||||
The CSS rules for the font-family can then easily be defined using the parent selector `.book.font-family-<id>`:
|
|
||||||
|
|
||||||
```CSS
|
|
||||||
.book.font-family-<id> {
|
|
||||||
font-family: 'My Awesome Font';
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Managing the font families
|
|
||||||
|
|
||||||
##### `gitbook.fontsettings.getFamilies()`
|
|
||||||
|
|
||||||
Returns the currently set font families.
|
|
||||||
|
|
||||||
By default, the font families are:
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Default font families
|
|
||||||
var FAMILIES = [
|
|
||||||
{
|
|
||||||
config: 'serif',
|
|
||||||
text: 'Serif',
|
|
||||||
id: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
config: 'sans',
|
|
||||||
text: 'Sans',
|
|
||||||
id: 1
|
|
||||||
}
|
|
||||||
];
|
|
||||||
```
|
|
||||||
|
|
||||||
##### `gitbook.fontsettings.setFamilies()`
|
|
||||||
|
|
||||||
Set the new font families configuration, as an array of font family objects, used by the `plugin-fontsettings` in the form:
|
|
||||||
|
|
||||||
```js
|
|
||||||
var FONT_FAMILIES = [
|
|
||||||
{
|
|
||||||
config: 'sans',
|
|
||||||
text: 'Sans',
|
|
||||||
id: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
config: 'serif',
|
|
||||||
text: 'Serif',
|
|
||||||
id: 1
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
gitbook.fontsettings.setFamilies(FONT_FAMILIES);
|
|
||||||
```
|
|
||||||
|
|
||||||
This will recreate the fontsettings menu to reflect the changes.
|
|
||||||
|
|
||||||
##### `gitbook.fontsettings.setFamily()`
|
|
||||||
|
|
||||||
Takes a font-family `config` key as an argument and updates the font-family used for this book.
|
|
||||||
|
|
||||||
This will basically apply the CSS class with the corresponding family `id`: `.font-family-<id>`.
|
|
||||||
|
|
||||||
#### Color themes
|
|
||||||
|
|
||||||
Setting and manipulating color themes follow the exact same rules as font families.
|
|
||||||
|
|
||||||
Here are the default value for the color themes in the plugin:
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Default themes
|
|
||||||
var THEMES = [
|
|
||||||
{
|
|
||||||
config: 'white',
|
|
||||||
text: 'White',
|
|
||||||
id: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
config: 'sepia',
|
|
||||||
text: 'Sepia',
|
|
||||||
id: 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
config: 'night',
|
|
||||||
text: 'Night',
|
|
||||||
id: 2
|
|
||||||
}
|
|
||||||
];
|
|
||||||
```
|
|
||||||
|
|
||||||
##### CSS rules
|
|
||||||
|
|
||||||
The applied CSS classes for color themes will be in the form: `.color-theme-<id>`.
|
|
||||||
|
|
||||||
**Caution**: No CSS class for color theme with `id: 0` will be applied. Basically, the first color theme corresponds to your default theme's colors.
|
|
||||||
|
|
||||||
For instance, using the default color themes:
|
|
||||||
|
|
||||||
```js
|
|
||||||
gitbook.fontsettings.setTheme('night');
|
|
||||||
```
|
|
||||||
|
|
||||||
will result in the following HTML state for the root element:
|
|
||||||
|
|
||||||
```HTML
|
|
||||||
<div class="book color-theme-2">
|
|
||||||
```
|
|
||||||
|
|
||||||
While:
|
|
||||||
|
|
||||||
```js
|
|
||||||
gitbook.fontsettings.setTheme('white');
|
|
||||||
```
|
|
||||||
|
|
||||||
will reset the HTML state for the root element:
|
|
||||||
|
|
||||||
```HTML
|
|
||||||
<div class="book">
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Managing the color themes
|
|
||||||
|
|
||||||
##### `gitbook.fontsettings.getFamilies()`
|
|
||||||
|
|
||||||
Returns the currently set color themes.
|
|
||||||
|
|
||||||
By default, the font families are:
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Default themes
|
|
||||||
var THEMES = [
|
|
||||||
{
|
|
||||||
config: 'white',
|
|
||||||
text: 'White',
|
|
||||||
id: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
config: 'sepia',
|
|
||||||
text: 'Sepia',
|
|
||||||
id: 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
config: 'night',
|
|
||||||
text: 'Night',
|
|
||||||
id: 2
|
|
||||||
}
|
|
||||||
];
|
|
||||||
```
|
|
||||||
|
|
||||||
##### `gitbook.fontsettings.setThemes()`
|
|
||||||
|
|
||||||
Set the new color themes configuration, as an array of font family objects, used by the `plugin-fontsettings` in the form:
|
|
||||||
|
|
||||||
```js
|
|
||||||
var COLOR_THEMES = [
|
|
||||||
{
|
|
||||||
config: 'light',
|
|
||||||
text: 'Light',
|
|
||||||
id: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
config: 'dark',
|
|
||||||
text: 'Dark',
|
|
||||||
id: 1
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
gitbook.fontsettings.setThemes(COLOR_THEMES);
|
|
||||||
```
|
|
||||||
|
|
||||||
This will recreate the fontsettings menu to reflect the changes.
|
|
||||||
|
|
||||||
##### `gitbook.fontsettings.setTheme()`
|
|
||||||
|
|
||||||
Takes a color theme `config` key as an argument and updates the color theme used for this book.
|
|
||||||
|
|
||||||
This will basically apply the CSS class with the corresponding theme `id`: `.color-theme-<id>`, or remove the applied CSS class if the selected theme `id` is `0`.
|
|
||||||
-240
@@ -1,240 +0,0 @@
|
|||||||
require(['gitbook', 'jquery'], function(gitbook, $) {
|
|
||||||
// Configuration
|
|
||||||
var MAX_SIZE = 4,
|
|
||||||
MIN_SIZE = 0,
|
|
||||||
BUTTON_ID;
|
|
||||||
|
|
||||||
// Current fontsettings state
|
|
||||||
var fontState;
|
|
||||||
|
|
||||||
// Default themes
|
|
||||||
var THEMES = [
|
|
||||||
{
|
|
||||||
config: 'white',
|
|
||||||
text: 'White',
|
|
||||||
id: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
config: 'sepia',
|
|
||||||
text: 'Sepia',
|
|
||||||
id: 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
config: 'night',
|
|
||||||
text: 'Night',
|
|
||||||
id: 2
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
// Default font families
|
|
||||||
var FAMILIES = [
|
|
||||||
{
|
|
||||||
config: 'serif',
|
|
||||||
text: 'Serif',
|
|
||||||
id: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
config: 'sans',
|
|
||||||
text: 'Sans',
|
|
||||||
id: 1
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
// Return configured themes
|
|
||||||
function getThemes() {
|
|
||||||
return THEMES;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modify configured themes
|
|
||||||
function setThemes(themes) {
|
|
||||||
THEMES = themes;
|
|
||||||
updateButtons();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return configured font families
|
|
||||||
function getFamilies() {
|
|
||||||
return FAMILIES;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modify configured font families
|
|
||||||
function setFamilies(families) {
|
|
||||||
FAMILIES = families;
|
|
||||||
updateButtons();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save current font settings
|
|
||||||
function saveFontSettings() {
|
|
||||||
gitbook.storage.set('fontState', fontState);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Increase font size
|
|
||||||
function enlargeFontSize(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
if (fontState.size >= MAX_SIZE) return;
|
|
||||||
|
|
||||||
fontState.size++;
|
|
||||||
saveFontSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decrease font size
|
|
||||||
function reduceFontSize(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
if (fontState.size <= MIN_SIZE) return;
|
|
||||||
|
|
||||||
fontState.size--;
|
|
||||||
saveFontSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Change font family
|
|
||||||
function changeFontFamily(configName, e) {
|
|
||||||
if (e && e instanceof Event) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
var familyId = getFontFamilyId(configName);
|
|
||||||
fontState.family = familyId;
|
|
||||||
saveFontSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Change type of color theme
|
|
||||||
function changeColorTheme(configName, e) {
|
|
||||||
if (e && e instanceof Event) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
var $book = gitbook.state.$book;
|
|
||||||
|
|
||||||
// Remove currently applied color theme
|
|
||||||
if (fontState.theme !== 0)
|
|
||||||
$book.removeClass('color-theme-'+fontState.theme);
|
|
||||||
|
|
||||||
// Set new color theme
|
|
||||||
var themeId = getThemeId(configName);
|
|
||||||
fontState.theme = themeId;
|
|
||||||
if (fontState.theme !== 0)
|
|
||||||
$book.addClass('color-theme-'+fontState.theme);
|
|
||||||
|
|
||||||
saveFontSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the correct id for a font-family config key
|
|
||||||
// Default to first font-family
|
|
||||||
function getFontFamilyId(configName) {
|
|
||||||
// Search for plugin configured font family
|
|
||||||
var configFamily = $.grep(FAMILIES, function(family) {
|
|
||||||
return family.config == configName;
|
|
||||||
})[0];
|
|
||||||
// Fallback to default font family
|
|
||||||
return (!!configFamily)? configFamily.id : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the correct id for a theme config key
|
|
||||||
// Default to first theme
|
|
||||||
function getThemeId(configName) {
|
|
||||||
// Search for plugin configured theme
|
|
||||||
var configTheme = $.grep(THEMES, function(theme) {
|
|
||||||
return theme.config == configName;
|
|
||||||
})[0];
|
|
||||||
// Fallback to default theme
|
|
||||||
return (!!configTheme)? configTheme.id : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function update() {
|
|
||||||
var $book = gitbook.state.$book;
|
|
||||||
|
|
||||||
$('.font-settings .font-family-list li').removeClass('active');
|
|
||||||
$('.font-settings .font-family-list li:nth-child('+(fontState.family+1)+')').addClass('active');
|
|
||||||
|
|
||||||
$book[0].className = $book[0].className.replace(/\bfont-\S+/g, '');
|
|
||||||
$book.addClass('font-size-'+fontState.size);
|
|
||||||
$book.addClass('font-family-'+fontState.family);
|
|
||||||
|
|
||||||
if(fontState.theme !== 0) {
|
|
||||||
$book[0].className = $book[0].className.replace(/\bcolor-theme-\S+/g, '');
|
|
||||||
$book.addClass('color-theme-'+fontState.theme);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function init(config) {
|
|
||||||
// Search for plugin configured font family
|
|
||||||
var configFamily = getFontFamilyId(config.family),
|
|
||||||
configTheme = getThemeId(config.theme);
|
|
||||||
|
|
||||||
// Instantiate font state object
|
|
||||||
fontState = gitbook.storage.get('fontState', {
|
|
||||||
size: config.size || 2,
|
|
||||||
family: configFamily,
|
|
||||||
theme: configTheme
|
|
||||||
});
|
|
||||||
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateButtons() {
|
|
||||||
// Remove existing fontsettings buttons
|
|
||||||
if (!!BUTTON_ID) {
|
|
||||||
gitbook.toolbar.removeButton(BUTTON_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create buttons in toolbar
|
|
||||||
BUTTON_ID = gitbook.toolbar.createButton({
|
|
||||||
icon: 'fa fa-font',
|
|
||||||
label: 'Font Settings',
|
|
||||||
className: 'font-settings',
|
|
||||||
dropdown: [
|
|
||||||
[
|
|
||||||
{
|
|
||||||
text: 'A',
|
|
||||||
className: 'font-reduce',
|
|
||||||
onClick: reduceFontSize
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'A',
|
|
||||||
className: 'font-enlarge',
|
|
||||||
onClick: enlargeFontSize
|
|
||||||
}
|
|
||||||
],
|
|
||||||
$.map(FAMILIES, function(family) {
|
|
||||||
family.onClick = function(e) {
|
|
||||||
return changeFontFamily(family.config, e);
|
|
||||||
};
|
|
||||||
|
|
||||||
return family;
|
|
||||||
}),
|
|
||||||
$.map(THEMES, function(theme) {
|
|
||||||
theme.onClick = function(e) {
|
|
||||||
return changeColorTheme(theme.config, e);
|
|
||||||
};
|
|
||||||
|
|
||||||
return theme;
|
|
||||||
})
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init configuration at start
|
|
||||||
gitbook.events.bind('start', function(e, config) {
|
|
||||||
var opts = config.fontsettings;
|
|
||||||
|
|
||||||
// Generate buttons at start
|
|
||||||
updateButtons();
|
|
||||||
|
|
||||||
// Init current settings
|
|
||||||
init(opts);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Expose API
|
|
||||||
gitbook.fontsettings = {
|
|
||||||
enlargeFontSize: enlargeFontSize,
|
|
||||||
reduceFontSize: reduceFontSize,
|
|
||||||
setTheme: changeColorTheme,
|
|
||||||
setFamily: changeFontFamily,
|
|
||||||
getThemes: getThemes,
|
|
||||||
setThemes: setThemes,
|
|
||||||
getFamilies: getFamilies,
|
|
||||||
setFamilies: setFamilies
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
-291
@@ -1,291 +0,0 @@
|
|||||||
/*
|
|
||||||
* Theme 1
|
|
||||||
*/
|
|
||||||
.color-theme-1 .dropdown-menu {
|
|
||||||
background-color: #111111;
|
|
||||||
border-color: #7e888b;
|
|
||||||
}
|
|
||||||
.color-theme-1 .dropdown-menu .dropdown-caret .caret-inner {
|
|
||||||
border-bottom: 9px solid #111111;
|
|
||||||
}
|
|
||||||
.color-theme-1 .dropdown-menu .buttons {
|
|
||||||
border-color: #7e888b;
|
|
||||||
}
|
|
||||||
.color-theme-1 .dropdown-menu .button {
|
|
||||||
color: #afa790;
|
|
||||||
}
|
|
||||||
.color-theme-1 .dropdown-menu .button:hover {
|
|
||||||
color: #73553c;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Theme 2
|
|
||||||
*/
|
|
||||||
.color-theme-2 .dropdown-menu {
|
|
||||||
background-color: #2d3143;
|
|
||||||
border-color: #272a3a;
|
|
||||||
}
|
|
||||||
.color-theme-2 .dropdown-menu .dropdown-caret .caret-inner {
|
|
||||||
border-bottom: 9px solid #2d3143;
|
|
||||||
}
|
|
||||||
.color-theme-2 .dropdown-menu .buttons {
|
|
||||||
border-color: #272a3a;
|
|
||||||
}
|
|
||||||
.color-theme-2 .dropdown-menu .button {
|
|
||||||
color: #62677f;
|
|
||||||
}
|
|
||||||
.color-theme-2 .dropdown-menu .button:hover {
|
|
||||||
color: #f4f4f5;
|
|
||||||
}
|
|
||||||
.book .book-header .font-settings .font-enlarge {
|
|
||||||
line-height: 30px;
|
|
||||||
font-size: 1.4em;
|
|
||||||
}
|
|
||||||
.book .book-header .font-settings .font-reduce {
|
|
||||||
line-height: 30px;
|
|
||||||
font-size: 1em;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body {
|
|
||||||
color: #704214;
|
|
||||||
background: #f3eacb;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section {
|
|
||||||
background: #f3eacb;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body {
|
|
||||||
color: #bdcadb;
|
|
||||||
background: #1c1f2b;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section {
|
|
||||||
background: #1c1f2b;
|
|
||||||
}
|
|
||||||
.book.font-size-0 .book-body .page-inner section {
|
|
||||||
font-size: 1.2rem;
|
|
||||||
}
|
|
||||||
.book.font-size-1 .book-body .page-inner section {
|
|
||||||
font-size: 1.4rem;
|
|
||||||
}
|
|
||||||
.book.font-size-2 .book-body .page-inner section {
|
|
||||||
font-size: 1.6rem;
|
|
||||||
}
|
|
||||||
.book.font-size-3 .book-body .page-inner section {
|
|
||||||
font-size: 2.2rem;
|
|
||||||
}
|
|
||||||
.book.font-size-4 .book-body .page-inner section {
|
|
||||||
font-size: 4rem;
|
|
||||||
}
|
|
||||||
.book.font-family-0 {
|
|
||||||
font-family: Georgia, serif;
|
|
||||||
}
|
|
||||||
.book.font-family-1 {
|
|
||||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal {
|
|
||||||
color: #704214;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal a {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h1,
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h2,
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h3,
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h4,
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h5,
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h6 {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h1,
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h2 {
|
|
||||||
border-color: inherit;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h6 {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal hr {
|
|
||||||
background-color: inherit;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal blockquote {
|
|
||||||
border-color: inherit;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre,
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code {
|
|
||||||
background: #fdf6e3;
|
|
||||||
color: #657b83;
|
|
||||||
border-color: #f8df9c;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal .highlight {
|
|
||||||
background-color: inherit;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table th,
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table td {
|
|
||||||
border-color: #f5d06c;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table tr {
|
|
||||||
color: inherit;
|
|
||||||
background-color: #fdf6e3;
|
|
||||||
border-color: #444444;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table tr:nth-child(2n) {
|
|
||||||
background-color: #fbeecb;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal {
|
|
||||||
color: #bdcadb;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal a {
|
|
||||||
color: #3eb1d0;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h1,
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h2,
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h3,
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h4,
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h5,
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h6 {
|
|
||||||
color: #fffffa;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h1,
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h2 {
|
|
||||||
border-color: #373b4e;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h6 {
|
|
||||||
color: #373b4e;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal hr {
|
|
||||||
background-color: #373b4e;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal blockquote {
|
|
||||||
border-color: #373b4e;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre,
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code {
|
|
||||||
color: #9dbed8;
|
|
||||||
background: #2d3143;
|
|
||||||
border-color: #2d3143;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal .highlight {
|
|
||||||
background-color: #282a39;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table th,
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table td {
|
|
||||||
border-color: #3b3f54;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table tr {
|
|
||||||
color: #b6c2d2;
|
|
||||||
background-color: #2d3143;
|
|
||||||
border-color: #3b3f54;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table tr:nth-child(2n) {
|
|
||||||
background-color: #35394b;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-header {
|
|
||||||
color: #afa790;
|
|
||||||
background: transparent;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-header .btn {
|
|
||||||
color: #afa790;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-header .btn:hover {
|
|
||||||
color: #73553c;
|
|
||||||
background: none;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-header h1 {
|
|
||||||
color: #704214;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-header {
|
|
||||||
color: #7e888b;
|
|
||||||
background: transparent;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-header .btn {
|
|
||||||
color: #3b3f54;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-header .btn:hover {
|
|
||||||
color: #fffff5;
|
|
||||||
background: none;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-header h1 {
|
|
||||||
color: #bdcadb;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body .navigation {
|
|
||||||
color: #afa790;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-body .navigation:hover {
|
|
||||||
color: #73553c;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body .navigation {
|
|
||||||
color: #383f52;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-body .navigation:hover {
|
|
||||||
color: #fffff5;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Theme 1
|
|
||||||
*/
|
|
||||||
.book.color-theme-1 .book-summary {
|
|
||||||
color: #afa790;
|
|
||||||
background: #111111;
|
|
||||||
border-right: 1px solid rgba(0, 0, 0, 0.07);
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-summary .book-search {
|
|
||||||
background: transparent;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-summary .book-search input,
|
|
||||||
.book.color-theme-1 .book-summary .book-search input:focus {
|
|
||||||
border: 1px solid transparent;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-summary ul.summary li.divider {
|
|
||||||
background: #7e888b;
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-summary ul.summary li i.fa-check {
|
|
||||||
color: #33cc33;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-summary ul.summary li.done > a {
|
|
||||||
color: #877f6a;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-summary ul.summary li a,
|
|
||||||
.book.color-theme-1 .book-summary ul.summary li span {
|
|
||||||
color: #877f6a;
|
|
||||||
background: transparent;
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
.book.color-theme-1 .book-summary ul.summary li.active > a,
|
|
||||||
.book.color-theme-1 .book-summary ul.summary li a:hover {
|
|
||||||
color: #704214;
|
|
||||||
background: transparent;
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Theme 2
|
|
||||||
*/
|
|
||||||
.book.color-theme-2 .book-summary {
|
|
||||||
color: #bcc1d2;
|
|
||||||
background: #2d3143;
|
|
||||||
border-right: none;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-summary .book-search {
|
|
||||||
background: transparent;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-summary .book-search input,
|
|
||||||
.book.color-theme-2 .book-summary .book-search input:focus {
|
|
||||||
border: 1px solid transparent;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-summary ul.summary li.divider {
|
|
||||||
background: #272a3a;
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-summary ul.summary li i.fa-check {
|
|
||||||
color: #33cc33;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-summary ul.summary li.done > a {
|
|
||||||
color: #62687f;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-summary ul.summary li a,
|
|
||||||
.book.color-theme-2 .book-summary ul.summary li span {
|
|
||||||
color: #c1c6d7;
|
|
||||||
background: transparent;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
.book.color-theme-2 .book-summary ul.summary li.active > a,
|
|
||||||
.book.color-theme-2 .book-summary ul.summary li a:hover {
|
|
||||||
color: #f4f4f5;
|
|
||||||
background: #252737;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
|
|
||||||
module.exports = {
|
|
||||||
book: {
|
|
||||||
assets: './assets',
|
|
||||||
js: [
|
|
||||||
'fontsettings.js'
|
|
||||||
],
|
|
||||||
css: [
|
|
||||||
'website.css'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
-81
@@ -1,81 +0,0 @@
|
|||||||
{
|
|
||||||
"_from": "gitbook-plugin-fontsettings",
|
|
||||||
"_id": "gitbook-plugin-fontsettings@2.0.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-bZpz/Jev7lL1d3VNp41KHZD67UYqyqdOwbsJE6YEW93R2mGiLfZLpUs86d2nrY61BedhlNck1xF52FNT6sWeig==",
|
|
||||||
"_location": "/gitbook-plugin-fontsettings",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "tag",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "gitbook-plugin-fontsettings",
|
|
||||||
"name": "gitbook-plugin-fontsettings",
|
|
||||||
"escapedName": "gitbook-plugin-fontsettings",
|
|
||||||
"rawSpec": "",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "latest"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmmirror.com/gitbook-plugin-fontsettings/-/gitbook-plugin-fontsettings-2.0.0.tgz",
|
|
||||||
"_shasum": "835f900ae3dd111086fe7ed4425ee3de024861ab",
|
|
||||||
"_spec": "gitbook-plugin-fontsettings",
|
|
||||||
"_where": "D:\\Book\\Sec-Interview",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/GitbookIO/plugin-fontsettings/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Fonts and colors themes settings the website for a better reading experience",
|
|
||||||
"devDependencies": {
|
|
||||||
"eslint": "^2.7.0",
|
|
||||||
"less": "2.5.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"gitbook": ">=2.4.0"
|
|
||||||
},
|
|
||||||
"gitbook": {
|
|
||||||
"properties": {
|
|
||||||
"theme": {
|
|
||||||
"type": "string",
|
|
||||||
"default": "white",
|
|
||||||
"title": "Default theme",
|
|
||||||
"enum": [
|
|
||||||
"white",
|
|
||||||
"sepia",
|
|
||||||
"night"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"family": {
|
|
||||||
"type": "string",
|
|
||||||
"default": "sans",
|
|
||||||
"title": "Default font family",
|
|
||||||
"enum": [
|
|
||||||
"sans",
|
|
||||||
"serif"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"size": {
|
|
||||||
"type": "number",
|
|
||||||
"default": 2,
|
|
||||||
"title": "Default font size",
|
|
||||||
"min": 1,
|
|
||||||
"max": 4
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/GitbookIO/plugin-fontsettings",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"main": "index.js",
|
|
||||||
"name": "gitbook-plugin-fontsettings",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/GitbookIO/plugin-fontsettings.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"prepublish": "lessc ./less/website.less > ./assets/website.css;"
|
|
||||||
},
|
|
||||||
"version": "2.0.0"
|
|
||||||
}
|
|
||||||
-201
@@ -1,201 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright {yyyy} {name of copyright owner}
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
# GitBook Plugin
|
|
||||||
|
|
||||||
Hide the element that you don't want to see.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```
|
|
||||||
{
|
|
||||||
"plugins": [
|
|
||||||
"hide-element"
|
|
||||||
],
|
|
||||||
"pluginsConfig": {
|
|
||||||
"hide-element": {
|
|
||||||
"elements": [".gitbook-link"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
require(['gitbook', 'jquery'], function(gitbook, $) {
|
|
||||||
var opts;
|
|
||||||
|
|
||||||
gitbook.events.bind('start', function(e, config) {
|
|
||||||
opts = config['hide-element'].elements;
|
|
||||||
});
|
|
||||||
|
|
||||||
gitbook.events.bind('page.change', function() {
|
|
||||||
$.map(opts, function(ele) {
|
|
||||||
$(ele).hide();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
-6
@@ -1,6 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
book: {
|
|
||||||
assets: "./book",
|
|
||||||
js: ["plugin.js"]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
-44
@@ -1,44 +0,0 @@
|
|||||||
{
|
|
||||||
"_from": "gitbook-plugin-hide-element",
|
|
||||||
"_id": "gitbook-plugin-hide-element@0.0.4",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-EHlhMdFAIWf73clRjT7lyuAA0qfP61K4CLzqzQYBzQJjdYlB5lVd4ymMWo+TIAXXei/WMdOTaJOUm4ThqS9vgA==",
|
|
||||||
"_location": "/gitbook-plugin-hide-element",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "tag",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "gitbook-plugin-hide-element",
|
|
||||||
"name": "gitbook-plugin-hide-element",
|
|
||||||
"escapedName": "gitbook-plugin-hide-element",
|
|
||||||
"rawSpec": "",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "latest"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmmirror.com/gitbook-plugin-hide-element/-/gitbook-plugin-hide-element-0.0.4.tgz",
|
|
||||||
"_shasum": "93a3de76aeebd535261597d257f71876f0d1dc34",
|
|
||||||
"_spec": "gitbook-plugin-hide-element",
|
|
||||||
"_where": "D:\\Book",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/gonjay/gitbook-plugin-hide-element/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Hide the element that you don't want to see.",
|
|
||||||
"engines": {
|
|
||||||
"gitbook": "*"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/gonjay/gitbook-plugin-hide-element",
|
|
||||||
"license": "ISC",
|
|
||||||
"main": "index.js",
|
|
||||||
"name": "gitbook-plugin-hide-element",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/gonjay/gitbook-plugin-hide-element.git"
|
|
||||||
},
|
|
||||||
"version": "0.0.4"
|
|
||||||
}
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
.idea
|
|
||||||
.history
|
|
||||||
*.swp
|
|
||||||
/examples
|
|
||||||
-202
@@ -1,202 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright {yyyy} {name of copyright owner}
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
-57
@@ -1,57 +0,0 @@
|
|||||||
## gitbook-plugin-search-pro
|
|
||||||
|
|
||||||
Gitbook search engine pro. (支持中文搜索)
|
|
||||||
|
|
||||||
You can search any characters(utf-8) and highlight it in your GitBook, not only english(exp:Chinese).
|
|
||||||
|
|
||||||
> Note: Only gitbook >= 3.0.0 support
|
|
||||||
|
|
||||||
### Demo preview
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Usage
|
|
||||||
|
|
||||||
Before use this plugin, you should disable the default search plugin first,
|
|
||||||
Here is a `book.js` configuration example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
{
|
|
||||||
"plugins": [
|
|
||||||
"-lunr", "-search", "search-pro"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
After installed gitbook.
|
|
||||||
|
|
||||||
```
|
|
||||||
> git clone git@github.com:gitbook-plugins/gitbook-plugin-search-pro.git -b gh-pages
|
|
||||||
> cd ./gitbook-plugin-search-pro
|
|
||||||
> npm install
|
|
||||||
> gitbook serve ./
|
|
||||||
```
|
|
||||||
|
|
||||||
And then open http://127.0.0.1:4000
|
|
||||||
|
|
||||||
|
|
||||||
### Thanks:
|
|
||||||
* [lwdgit](https://github.com/lwdgit/gitbook-plugin-search-plus)
|
|
||||||
* [gitbook-plugin-lunr](https://github.com/GitbookIO/plugin-lunr)
|
|
||||||
* [gitbook-plugin-search](https://github.com/GitbookIO/plugin-search)
|
|
||||||
* [mark.js](https://github.com/julmot/mark.js)
|
|
||||||
|
|
||||||
-28
@@ -1,28 +0,0 @@
|
|||||||
{% extends template.self %}
|
|
||||||
|
|
||||||
{% block search_input %}
|
|
||||||
<div id="book-search-input" role="search">
|
|
||||||
<input type="text" placeholder="{{ 'SEARCH_PLACEHOLDER'|t }}" />
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block search_results %}
|
|
||||||
<div id="book-search-results">
|
|
||||||
<div class="search-noresults">
|
|
||||||
{{ super() }}
|
|
||||||
</div>
|
|
||||||
<div class="search-results">
|
|
||||||
<div class="has-results">
|
|
||||||
{% block search_has_results %}
|
|
||||||
<h1 class="search-results-title">{{ 'SEARCH_RESULTS_TITLE'|t|safe }}</h1>
|
|
||||||
<ul class="search-results-list"></ul>
|
|
||||||
{% endblock %}
|
|
||||||
</div>
|
|
||||||
<div class="no-results">
|
|
||||||
{% block search_no_results %}
|
|
||||||
<h1 class="search-results-title">{{ 'SEARCH_NO_RESULTS_TITLE'|t|safe }}</h1>
|
|
||||||
{% endblock %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
-7
File diff suppressed because one or more lines are too long
-41
@@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
This CSS only styled the search results section, not the search input
|
|
||||||
It defines the basic interraction to hide content when displaying results, etc
|
|
||||||
*/
|
|
||||||
#book-search-input {
|
|
||||||
background: inherit;
|
|
||||||
}
|
|
||||||
#book-search-results .search-results {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
#book-search-results .search-results ul.search-results-list {
|
|
||||||
list-style-type: none;
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
#book-search-results .search-results ul.search-results-list li {
|
|
||||||
margin-bottom: 1.5rem;
|
|
||||||
padding-bottom: 0.5rem;
|
|
||||||
/* Highlight results */
|
|
||||||
}
|
|
||||||
#book-search-results .search-results ul.search-results-list li p em {
|
|
||||||
background-color: rgba(255, 220, 0, 0.4);
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
#book-search-results .search-results .no-results {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
#book-search-results.open .search-results {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
#book-search-results.open .search-noresults {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
#book-search-results.no-results .search-results .has-results {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
#book-search-results.no-results .search-results .no-results {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
#book-search-results span.search-highlight-keyword {
|
|
||||||
background: #ff0;
|
|
||||||
}
|
|
||||||
-261
@@ -1,261 +0,0 @@
|
|||||||
require([
|
|
||||||
'gitbook',
|
|
||||||
'jquery'
|
|
||||||
], function(gitbook, $) {
|
|
||||||
var MAX_DESCRIPTION_SIZE = 500;
|
|
||||||
var state = gitbook.state;
|
|
||||||
var INDEX_DATA = {};
|
|
||||||
var usePushState = (typeof history.pushState !== 'undefined');
|
|
||||||
|
|
||||||
// DOM Elements
|
|
||||||
var $body = $('body');
|
|
||||||
var $bookSearchResults;
|
|
||||||
var $searchList;
|
|
||||||
var $searchTitle;
|
|
||||||
var $searchResultsCount;
|
|
||||||
var $searchQuery;
|
|
||||||
|
|
||||||
// Throttle search
|
|
||||||
function throttle(fn, wait) {
|
|
||||||
var timeout;
|
|
||||||
|
|
||||||
return function() {
|
|
||||||
var ctx = this,
|
|
||||||
args = arguments;
|
|
||||||
if (!timeout) {
|
|
||||||
timeout = setTimeout(function() {
|
|
||||||
timeout = null;
|
|
||||||
fn.apply(ctx, args);
|
|
||||||
}, wait);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function displayResults(res) {
|
|
||||||
$bookSearchResults = $('#book-search-results');
|
|
||||||
$searchList = $bookSearchResults.find('.search-results-list');
|
|
||||||
$searchTitle = $bookSearchResults.find('.search-results-title');
|
|
||||||
$searchResultsCount = $searchTitle.find('.search-results-count');
|
|
||||||
$searchQuery = $searchTitle.find('.search-query');
|
|
||||||
|
|
||||||
$bookSearchResults.addClass('open');
|
|
||||||
|
|
||||||
var noResults = res.count == 0;
|
|
||||||
$bookSearchResults.toggleClass('no-results', noResults);
|
|
||||||
|
|
||||||
// Clear old results
|
|
||||||
$searchList.empty();
|
|
||||||
|
|
||||||
// Display title for research
|
|
||||||
$searchResultsCount.text(res.count);
|
|
||||||
$searchQuery.text(res.query);
|
|
||||||
|
|
||||||
// Create an <li> element for each result
|
|
||||||
res.results.forEach(function(item) {
|
|
||||||
var $li = $('<li>', {
|
|
||||||
'class': 'search-results-item'
|
|
||||||
});
|
|
||||||
|
|
||||||
var $title = $('<h3>');
|
|
||||||
|
|
||||||
var $link = $('<a>', {
|
|
||||||
'href': gitbook.state.basePath + '/' + item.url + '?h=' + encodeURIComponent(res.query),
|
|
||||||
'text': item.title,
|
|
||||||
'data-is-search': 1
|
|
||||||
});
|
|
||||||
|
|
||||||
if ($link[0].href.split('?')[0] === location.href.split('?')[0]) {
|
|
||||||
$link[0].setAttribute('data-need-reload', 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
var content = item.body.trim();
|
|
||||||
if (content.length > MAX_DESCRIPTION_SIZE) {
|
|
||||||
content = content + '...';
|
|
||||||
}
|
|
||||||
var $content = $('<p>').html(content);
|
|
||||||
|
|
||||||
$link.appendTo($title);
|
|
||||||
$title.appendTo($li);
|
|
||||||
$content.appendTo($li);
|
|
||||||
$li.appendTo($searchList);
|
|
||||||
});
|
|
||||||
$('.body-inner').scrollTop(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function escapeReg(keyword) {
|
|
||||||
//escape regexp prevserve word
|
|
||||||
return String(keyword).replace(/([\*\.\?\+\$\^\[\]\(\)\{\}\|\/\\])/g, '\\$1');
|
|
||||||
}
|
|
||||||
|
|
||||||
function query(keyword) {
|
|
||||||
if (keyword == null || keyword.trim() === '') return;
|
|
||||||
|
|
||||||
var results = [],
|
|
||||||
index = -1;
|
|
||||||
for (var page in INDEX_DATA) {
|
|
||||||
if ((index = INDEX_DATA[page].body.toLowerCase().indexOf(keyword.toLowerCase())) !== -1) {
|
|
||||||
results.push({
|
|
||||||
url: page,
|
|
||||||
title: INDEX_DATA[page].title,
|
|
||||||
body: INDEX_DATA[page].body.substr(Math.max(0, index - 50), MAX_DESCRIPTION_SIZE).replace(new RegExp('(' + escapeReg(keyword) + ')', 'gi'), '<span class="search-highlight-keyword">$1</span>')
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
displayResults({
|
|
||||||
count: results.length,
|
|
||||||
query: keyword,
|
|
||||||
results: results
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function launchSearch(keyword) {
|
|
||||||
// Add class for loading
|
|
||||||
$body.addClass('with-search');
|
|
||||||
$body.addClass('search-loading');
|
|
||||||
|
|
||||||
function doSearch() {
|
|
||||||
query(keyword);
|
|
||||||
$body.removeClass('search-loading');
|
|
||||||
}
|
|
||||||
|
|
||||||
throttle(doSearch)();
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeSearch() {
|
|
||||||
$body.removeClass('with-search');
|
|
||||||
$('#book-search-results').removeClass('open');
|
|
||||||
}
|
|
||||||
|
|
||||||
function bindSearch() {
|
|
||||||
// Bind DOM
|
|
||||||
var $body = $('body');
|
|
||||||
|
|
||||||
// Launch query based on input content
|
|
||||||
function handleUpdate() {
|
|
||||||
var $searchInput = $('#book-search-input input');
|
|
||||||
var keyword = $searchInput.val();
|
|
||||||
|
|
||||||
if (keyword.length == 0) {
|
|
||||||
closeSearch();
|
|
||||||
} else {
|
|
||||||
launchSearch(keyword);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$body.on('keyup', '#book-search-input input', function(e) {
|
|
||||||
if (e.keyCode === 13) {
|
|
||||||
if (usePushState) {
|
|
||||||
var uri = updateQueryString('q', $(this).val());
|
|
||||||
history.pushState({
|
|
||||||
path: uri
|
|
||||||
}, null, uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
handleUpdate();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Push to history on blur
|
|
||||||
$body.on('blur', '#book-search-input input', function(e) {
|
|
||||||
// Update history state
|
|
||||||
if (usePushState) {
|
|
||||||
var uri = updateQueryString('q', $(this).val());
|
|
||||||
history.pushState({
|
|
||||||
path: uri
|
|
||||||
}, null, uri);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
gitbook.events.on('start', function() {
|
|
||||||
bindSearch();
|
|
||||||
$.getJSON(state.basePath + "/search_plus_index.json").then(function(data) {
|
|
||||||
INDEX_DATA = data;
|
|
||||||
showResult();
|
|
||||||
closeSearch();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// 高亮文本
|
|
||||||
var highLightPageInner = function(keyword) {
|
|
||||||
$('.page-inner').mark(keyword, {
|
|
||||||
'ignoreJoiners': true,
|
|
||||||
'acrossElements': true,
|
|
||||||
'separateWordSearch': false
|
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(function() {
|
|
||||||
var mark = $('mark[data-markjs="true"]');
|
|
||||||
if (mark.length) {
|
|
||||||
mark[0].scrollIntoView();
|
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
};
|
|
||||||
|
|
||||||
function showResult() {
|
|
||||||
var keyword, type;
|
|
||||||
if (/\b(q|h)=([^&]+)/.test(location.search)) {
|
|
||||||
type = RegExp.$1;
|
|
||||||
keyword = decodeURIComponent(RegExp.$2);
|
|
||||||
if (type === 'q') {
|
|
||||||
launchSearch(keyword);
|
|
||||||
} else {
|
|
||||||
highLightPageInner(keyword);
|
|
||||||
}
|
|
||||||
$('#book-search-input input').val(keyword);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gitbook.events.on('page.change', showResult);
|
|
||||||
|
|
||||||
function getParameterByName(name) {
|
|
||||||
var url = window.location.href;
|
|
||||||
name = name.replace(/[\[\]]/g, '\\$&');
|
|
||||||
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)', 'i'),
|
|
||||||
results = regex.exec(url);
|
|
||||||
if (!results) return null;
|
|
||||||
if (!results[2]) return '';
|
|
||||||
return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateQueryString(key, value) {
|
|
||||||
value = encodeURIComponent(value);
|
|
||||||
|
|
||||||
var url = window.location.href.replace(/([?&])(?:q|h)=([^&]+)(&|$)/, function(all, pre, value, end) {
|
|
||||||
if (end === '&') {
|
|
||||||
return pre;
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
});
|
|
||||||
var re = new RegExp('([?&])' + key + '=.*?(&|#|$)(.*)', 'gi'),
|
|
||||||
hash;
|
|
||||||
|
|
||||||
if (re.test(url)) {
|
|
||||||
if (typeof value !== 'undefined' && value !== null)
|
|
||||||
return url.replace(re, '$1' + key + '=' + value + '$2$3');
|
|
||||||
else {
|
|
||||||
hash = url.split('#');
|
|
||||||
url = hash[0].replace(re, '$1$3').replace(/(&|\?)$/, '');
|
|
||||||
if (typeof hash[1] !== 'undefined' && hash[1] !== null)
|
|
||||||
url += '#' + hash[1];
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (typeof value !== 'undefined' && value !== null) {
|
|
||||||
var separator = url.indexOf('?') !== -1 ? '&' : '?';
|
|
||||||
hash = url.split('#');
|
|
||||||
url = hash[0] + separator + key + '=' + value;
|
|
||||||
if (typeof hash[1] !== 'undefined' && hash[1] !== null)
|
|
||||||
url += '#' + hash[1];
|
|
||||||
return url;
|
|
||||||
} else
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
window.addEventListener('click', function(e) {
|
|
||||||
if (e.target.tagName === 'A' && e.target.getAttribute('data-need-reload')) {
|
|
||||||
setTimeout(function() {
|
|
||||||
location.reload();
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
});
|
|
||||||
-64
@@ -1,64 +0,0 @@
|
|||||||
var Entities = require('html-entities').AllHtmlEntities;
|
|
||||||
|
|
||||||
var Html = new Entities();
|
|
||||||
|
|
||||||
// Map of Lunr ref to document
|
|
||||||
var documentsStore = {};
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
book: {
|
|
||||||
assets: './assets',
|
|
||||||
js: [
|
|
||||||
'jquery.mark.min.js',
|
|
||||||
'search.js'
|
|
||||||
],
|
|
||||||
css: [
|
|
||||||
'search.css'
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
hooks: {
|
|
||||||
// Index each page
|
|
||||||
'page': function(page) {
|
|
||||||
if (this.output.name != 'website' || page.search === false) {
|
|
||||||
return page;
|
|
||||||
}
|
|
||||||
|
|
||||||
var text;
|
|
||||||
|
|
||||||
this.log.debug.ln('index page', page.path);
|
|
||||||
|
|
||||||
text = page.content;
|
|
||||||
// Decode HTML
|
|
||||||
text = Html.decode(text);
|
|
||||||
// Strip HTML tags
|
|
||||||
text = text.replace(/(<([^>]+)>)/ig, '');
|
|
||||||
text = text.replace(/[\n ]+/g, ' ');
|
|
||||||
var keywords = [];
|
|
||||||
if (page.search) {
|
|
||||||
keywords = page.search.keywords || [];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add to index
|
|
||||||
var doc = {
|
|
||||||
url: this.output.toURL(page.path),
|
|
||||||
title: page.title,
|
|
||||||
summary: page.description,
|
|
||||||
keywords: keywords.join(' '),
|
|
||||||
body: text
|
|
||||||
};
|
|
||||||
|
|
||||||
documentsStore[doc.url] = doc;
|
|
||||||
|
|
||||||
return page;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Write index to disk
|
|
||||||
'finish': function() {
|
|
||||||
if (this.output.name != 'website') return;
|
|
||||||
|
|
||||||
this.log.debug.ln('write search index');
|
|
||||||
return this.output.writeFile('search_plus_index.json', JSON.stringify(documentsStore));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
-59
@@ -1,59 +0,0 @@
|
|||||||
{
|
|
||||||
"_from": "gitbook-plugin-search-pro",
|
|
||||||
"_id": "gitbook-plugin-search-pro@2.0.2",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-JZvfwp1DPsoAeGjGwLsYNr4BBgreAUYBfrpZbnLKg3COAO+OsFYOKEAexHKATOajCEhiQMfkN1rnFGTYP2XTkA==",
|
|
||||||
"_location": "/gitbook-plugin-search-pro",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "tag",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "gitbook-plugin-search-pro",
|
|
||||||
"name": "gitbook-plugin-search-pro",
|
|
||||||
"escapedName": "gitbook-plugin-search-pro",
|
|
||||||
"rawSpec": "",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "latest"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmmirror.com/gitbook-plugin-search-pro/-/gitbook-plugin-search-pro-2.0.2.tgz",
|
|
||||||
"_shasum": "7ce76e8f65c2044489b9c692736b23f81fe6a1f2",
|
|
||||||
"_spec": "gitbook-plugin-search-pro",
|
|
||||||
"_where": "D:\\Book",
|
|
||||||
"analyze": true,
|
|
||||||
"author": {
|
|
||||||
"name": "xunuo",
|
|
||||||
"email": "i@xunuo.com"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/gitbook-plugins/gitbook-plugin-search-pro/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"dependencies": {
|
|
||||||
"html-entities": "1.2.0"
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Gitbook search engine pro. (支持中文搜索)",
|
|
||||||
"engines": {
|
|
||||||
"gitbook": ">=3.0.0"
|
|
||||||
},
|
|
||||||
"homepage": "https://xunuo.com",
|
|
||||||
"keywords": [
|
|
||||||
"中文",
|
|
||||||
"搜索",
|
|
||||||
"chinese",
|
|
||||||
"gitbook",
|
|
||||||
"search",
|
|
||||||
"utf-8"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"name": "gitbook-plugin-search-pro",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/gitbook-plugins/gitbook-plugin-search-pro.git"
|
|
||||||
},
|
|
||||||
"version": "2.0.2"
|
|
||||||
}
|
|
||||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 MiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 MiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 624 KiB |
-92
@@ -1,92 +0,0 @@
|
|||||||
### https://raw.github.com/github/gitignore/a4ec7f03ca5ae0bf09fad42c0fb7d1e8346bcf25/Node.gitignore
|
|
||||||
|
|
||||||
# Logs
|
|
||||||
logs
|
|
||||||
*.log
|
|
||||||
|
|
||||||
# Runtime data
|
|
||||||
pids
|
|
||||||
*.pid
|
|
||||||
*.seed
|
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
||||||
lib-cov
|
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
|
||||||
coverage
|
|
||||||
|
|
||||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
|
||||||
.grunt
|
|
||||||
|
|
||||||
# node-waf configuration
|
|
||||||
.lock-wscript
|
|
||||||
|
|
||||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
|
||||||
build/Release
|
|
||||||
|
|
||||||
# Dependency directory
|
|
||||||
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
|
|
||||||
node_modules
|
|
||||||
|
|
||||||
|
|
||||||
### https://raw.github.com/github/gitignore/a4ec7f03ca5ae0bf09fad42c0fb7d1e8346bcf25/Global/OSX.gitignore
|
|
||||||
|
|
||||||
.DS_Store
|
|
||||||
.AppleDouble
|
|
||||||
.LSOverride
|
|
||||||
|
|
||||||
# Icon must end with two \r
|
|
||||||
Icon␍
|
|
||||||
|
|
||||||
# Thumbnails
|
|
||||||
._*
|
|
||||||
|
|
||||||
# Files that might appear in the root of a volume
|
|
||||||
.DocumentRevisions-V100
|
|
||||||
.fseventsd
|
|
||||||
.Spotlight-V100
|
|
||||||
.TemporaryItems
|
|
||||||
.Trashes
|
|
||||||
.VolumeIcon.icns
|
|
||||||
|
|
||||||
# Directories potentially created on remote AFP share
|
|
||||||
.AppleDB
|
|
||||||
.AppleDesktop
|
|
||||||
Network Trash Folder
|
|
||||||
Temporary Items
|
|
||||||
.apdisk
|
|
||||||
|
|
||||||
|
|
||||||
### https://raw.github.com/github/gitignore/a4ec7f03ca5ae0bf09fad42c0fb7d1e8346bcf25/Global/Windows.gitignore
|
|
||||||
|
|
||||||
# Windows image file caches
|
|
||||||
Thumbs.db
|
|
||||||
ehthumbs.db
|
|
||||||
|
|
||||||
# Folder config file
|
|
||||||
Desktop.ini
|
|
||||||
|
|
||||||
# Recycle Bin used on file shares
|
|
||||||
$RECYCLE.BIN/
|
|
||||||
|
|
||||||
# Windows Installer files
|
|
||||||
*.cab
|
|
||||||
*.msi
|
|
||||||
*.msm
|
|
||||||
*.msp
|
|
||||||
|
|
||||||
# Windows shortcuts
|
|
||||||
*.lnk
|
|
||||||
|
|
||||||
|
|
||||||
### https://raw.github.com/github/gitignore/a4ec7f03ca5ae0bf09fad42c0fb7d1e8346bcf25/Global/Linux.gitignore
|
|
||||||
|
|
||||||
*~
|
|
||||||
|
|
||||||
# KDE directory preferences
|
|
||||||
.directory
|
|
||||||
|
|
||||||
# Linux trash folder which might appear on any partition or disk
|
|
||||||
.Trash-*
|
|
||||||
|
|
||||||
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2015 yoshidax
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
-45
@@ -1,45 +0,0 @@
|
|||||||
gitbook-plugin-splitter
|
|
||||||
==============
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
this plug-in provides a vertical bar that divides the summary and main content.
|
|
||||||
|
|
||||||
[](https://nodei.co/npm/gitbook-plugin-splitter/)
|
|
||||||
|
|
||||||
### other feature
|
|
||||||
|
|
||||||
* It will save the position information of the splitter to sessionStorage.
|
|
||||||
|
|
||||||
### How to use it?
|
|
||||||
|
|
||||||
Add it to your `book.json` configuration:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"plugins": ["splitter"]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Install your plugins using:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ gitbook install
|
|
||||||
```
|
|
||||||
|
|
||||||
### change logs
|
|
||||||
|
|
||||||
#### version 0.0.6 (2016-12-06T16:54:38)
|
|
||||||
|
|
||||||
* fix: Fixed not to do anything when the width of the screen size was 600px or less (#6)
|
|
||||||
* fix: changed the position of the bar position from "localStorage" to "sessiongStorage" (#10)
|
|
||||||
|
|
||||||
#### version 0.0.6 (2015-11-06T16:54:38)
|
|
||||||
|
|
||||||
* supported Gitbook v3
|
|
||||||
|
|
||||||
#### version 0.0.5 (2015-11-06T16:54:38)
|
|
||||||
|
|
||||||
* fixed don't work toggle button of summary view display from Gitbook V2.5.x
|
|
||||||
|
|
||||||
This software is released under the MIT License, see LICENSE.txt.
|
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
.divider-content-summary {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
height: 100%;
|
|
||||||
width: 5px;
|
|
||||||
display: table;
|
|
||||||
cursor: col-resize;
|
|
||||||
color: #ccc;
|
|
||||||
-webkit-transition: color 350ms ease;
|
|
||||||
-moz-transition: color 350ms ease;
|
|
||||||
-o-transition: color 350ms ease;
|
|
||||||
transition: color 350ms ease
|
|
||||||
}
|
|
||||||
.divider-content-summary:hover {
|
|
||||||
color: #444;
|
|
||||||
}
|
|
||||||
.divider-content-summary__icon {
|
|
||||||
display: table-cell;
|
|
||||||
vertical-align: middle;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
-128
@@ -1,128 +0,0 @@
|
|||||||
require(['gitbook', 'jQuery'], function (gitbook, $) {
|
|
||||||
|
|
||||||
// MEMO:
|
|
||||||
// Gitbook is calculated as "calc (100% - 60px)" in the horizontal width when the width of the screen size is 600px
|
|
||||||
// or less.
|
|
||||||
// In this case, since contradiction occurs in the implementation of this module, return.
|
|
||||||
if($(window).width() <= 600) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gitbook.events.bind('start', function () {
|
|
||||||
});
|
|
||||||
|
|
||||||
gitbook.events.bind('page.change', function () {
|
|
||||||
|
|
||||||
var KEY_SPLIT_STATE = 'plugin_gitbook_split';
|
|
||||||
|
|
||||||
var dividerWidth = null;
|
|
||||||
var isDraggable = false;
|
|
||||||
var dividerCenterOffsetLeft = null;
|
|
||||||
var splitState = null;
|
|
||||||
var grabPointWidth = null;
|
|
||||||
|
|
||||||
var $body = $('body');
|
|
||||||
var $book = $('.book');
|
|
||||||
var $summary = $('.book-summary');
|
|
||||||
var $bookBody = $('.book-body');
|
|
||||||
var $divider = $('<div class="divider-content-summary">' +
|
|
||||||
'<div class="divider-content-summary__icon">' +
|
|
||||||
'<i class="fa fa-ellipsis-v"></i>' +
|
|
||||||
'</div>' +
|
|
||||||
'</div>');
|
|
||||||
|
|
||||||
$summary.append($divider);
|
|
||||||
|
|
||||||
dividerWidth = $divider.outerWidth();
|
|
||||||
dividerCenterOffsetLeft = $divider.outerWidth() / 2;
|
|
||||||
|
|
||||||
// restore split state from sessionStorage
|
|
||||||
splitState = getSplitState();
|
|
||||||
setSplitState(
|
|
||||||
splitState.summaryWidth,
|
|
||||||
splitState.summaryOffset,
|
|
||||||
splitState.bookBodyOffset
|
|
||||||
);
|
|
||||||
|
|
||||||
setTimeout(function() {
|
|
||||||
var isGreaterThanEqualGitbookV2_5 = !Boolean($('.toggle-summary').length);
|
|
||||||
|
|
||||||
var $toggleSummary = isGreaterThanEqualGitbookV2_5
|
|
||||||
? $('.fa.fa-align-justify').parent() : $('.toggle-summary');
|
|
||||||
|
|
||||||
$toggleSummary.on('click', function () {
|
|
||||||
|
|
||||||
var summaryOffset = null;
|
|
||||||
var bookBodyOffset = null;
|
|
||||||
|
|
||||||
var isOpen = isGreaterThanEqualGitbookV2_5
|
|
||||||
? !gitbook.sidebar.isOpen() : $book.hasClass('with-summary');
|
|
||||||
|
|
||||||
if (isOpen) {
|
|
||||||
summaryOffset = -($summary.outerWidth());
|
|
||||||
bookBodyOffset = 0;
|
|
||||||
} else {
|
|
||||||
summaryOffset = 0;
|
|
||||||
bookBodyOffset = $summary.outerWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
setSplitState($summary.outerWidth(), summaryOffset, bookBodyOffset);
|
|
||||||
saveSplitState($summary.outerWidth(), summaryOffset, bookBodyOffset);
|
|
||||||
});
|
|
||||||
}, 1);
|
|
||||||
|
|
||||||
$divider.on('mousedown', function (event) {
|
|
||||||
event.stopPropagation();
|
|
||||||
isDraggable = true;
|
|
||||||
grabPointWidth = $summary.outerWidth() - event.pageX;
|
|
||||||
});
|
|
||||||
|
|
||||||
$body.on('mouseup', function (event) {
|
|
||||||
event.stopPropagation();
|
|
||||||
isDraggable = false;
|
|
||||||
saveSplitState(
|
|
||||||
$summary.outerWidth(),
|
|
||||||
$summary.position().left,
|
|
||||||
$bookBody.position().left
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
$body.on('mousemove', function (event) {
|
|
||||||
if (!isDraggable) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
$summary.outerWidth(event.pageX + grabPointWidth);
|
|
||||||
$bookBody.offset({ left: event.pageX + grabPointWidth });
|
|
||||||
});
|
|
||||||
|
|
||||||
function getSplitState() {
|
|
||||||
var splitState = JSON.parse(sessionStorage.getItem(KEY_SPLIT_STATE));
|
|
||||||
splitState || (splitState = {});
|
|
||||||
splitState.summaryWidth || (splitState.summaryWidth = $summary.outerWidth());
|
|
||||||
splitState.summaryOffset || (splitState.summaryOffset = $summary.position().left);
|
|
||||||
splitState.bookBodyOffset || (splitState.bookBodyOffset = $bookBody.position().left);
|
|
||||||
return splitState;
|
|
||||||
}
|
|
||||||
|
|
||||||
function saveSplitState(summaryWidth, summaryWidthOffset, bookBodyOffset) {
|
|
||||||
sessionStorage.setItem(KEY_SPLIT_STATE, JSON.stringify({
|
|
||||||
summaryWidth: summaryWidth,
|
|
||||||
summaryOffset: summaryWidthOffset,
|
|
||||||
bookBodyOffset: bookBodyOffset,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
function setSplitState(summaryWidth, summaryOffset, bookBodyOffset) {
|
|
||||||
$summary.outerWidth(summaryWidth);
|
|
||||||
$summary.offset({ left: summaryOffset });
|
|
||||||
$bookBody.offset({ left: bookBodyOffset });
|
|
||||||
// improved broken layout in windows chrome.
|
|
||||||
// "$(x).offset" automatically add to "position:relative".
|
|
||||||
// but it cause layout broken..
|
|
||||||
$summary.css({ position: 'absolute' });
|
|
||||||
$bookBody.css({ position: 'absolute' });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 274 KiB |
-11
@@ -1,11 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
website: {
|
|
||||||
assets: './book',
|
|
||||||
js: [
|
|
||||||
'splitter.js'
|
|
||||||
],
|
|
||||||
css: [
|
|
||||||
'splitter.css'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
-51
@@ -1,51 +0,0 @@
|
|||||||
{
|
|
||||||
"_from": "gitbook-plugin-splitter",
|
|
||||||
"_id": "gitbook-plugin-splitter@0.0.8",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-EGyaiGNPAOhkc5TDqYCMNa17eFTZJX6aD6M7imJ5JbHtIkKmx3mZhoAnI2ovZrxx3x1tq/lmhq94nkayCl8WdQ==",
|
|
||||||
"_location": "/gitbook-plugin-splitter",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "tag",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "gitbook-plugin-splitter",
|
|
||||||
"name": "gitbook-plugin-splitter",
|
|
||||||
"escapedName": "gitbook-plugin-splitter",
|
|
||||||
"rawSpec": "",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "latest"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmmirror.com/gitbook-plugin-splitter/-/gitbook-plugin-splitter-0.0.8.tgz",
|
|
||||||
"_shasum": "f2b0513060fc9266b46b04182e4eca1d4b71fafc",
|
|
||||||
"_spec": "gitbook-plugin-splitter",
|
|
||||||
"_where": "D:\\Book",
|
|
||||||
"author": {
|
|
||||||
"name": "yoshidax"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/yoshidax/gitbook-plugin-splitter/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "this plug-in provides a vertical bar that divides the summary and main content.",
|
|
||||||
"engines": {
|
|
||||||
"gitbook": ">1.x.x"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/yoshidax/gitbook-plugin-splitter#readme",
|
|
||||||
"keywords": [
|
|
||||||
"gitbook"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "index.js",
|
|
||||||
"name": "gitbook-plugin-splitter",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/yoshidax/gitbook-plugin-splitter.git"
|
|
||||||
},
|
|
||||||
"scripts": {},
|
|
||||||
"version": "0.0.8"
|
|
||||||
}
|
|
||||||
-201
@@ -1,201 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright {yyyy} {name of copyright owner}
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
# gitbook-plugin-tbfed-pagefooter
|
|
||||||
|
|
||||||
* 插件配置
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
"tbfed-pagefooter": {
|
|
||||||
"copyright":"© Taobao FED Team",
|
|
||||||
"modify_label": "该文件修订时间:",
|
|
||||||
"modify_format": "YYYY-MM-DD HH:mm:ss"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
> copyright 和 modify_label 支持 html 代码
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
.page-footer {
|
|
||||||
margin-top: 50px;
|
|
||||||
border-top: 1px solid #ccc;
|
|
||||||
overflow: hidden;
|
|
||||||
padding: 10px 0;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #808080;
|
|
||||||
}
|
|
||||||
.page-footer a {
|
|
||||||
color: #808080!important;
|
|
||||||
text-decoration: underline!important;
|
|
||||||
}
|
|
||||||
.footer-modification {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
-36
@@ -1,36 +0,0 @@
|
|||||||
var moment = require('moment');
|
|
||||||
module.exports = {
|
|
||||||
book: {
|
|
||||||
assets: './assets',
|
|
||||||
css: [
|
|
||||||
'footer.css'
|
|
||||||
],
|
|
||||||
},
|
|
||||||
hooks: {
|
|
||||||
'page:before': function(page) {
|
|
||||||
var _label = 'File Modify: ',
|
|
||||||
_format = 'YYYY-MM-DD HH:mm:ss',
|
|
||||||
_copy = 'powered by Gitbook'
|
|
||||||
if(this.options.pluginsConfig['tbfed-pagefooter']) {
|
|
||||||
_label = this.options.pluginsConfig['tbfed-pagefooter']['modify_label'] || _label;
|
|
||||||
_format = this.options.pluginsConfig['tbfed-pagefooter']['modify_format'] || _format;
|
|
||||||
|
|
||||||
var _c = this.options.pluginsConfig['tbfed-pagefooter']['copyright'];
|
|
||||||
_copy = _c ? _c + ' all right reserved,' + _copy : _copy;
|
|
||||||
}
|
|
||||||
var _copy = '<span class="copyright">'+_copy+'</span>'
|
|
||||||
var str = ' \n\n<footer class="page-footer">' + _copy +
|
|
||||||
'<span class="footer-modification">' +
|
|
||||||
_label +
|
|
||||||
'\n{{file.mtime | date("' + _format +
|
|
||||||
'")}}\n</span></footer>'
|
|
||||||
page.content = page.content + str;
|
|
||||||
return page;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
filters: {
|
|
||||||
date: function(d, format) {
|
|
||||||
return moment(d).format(format)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
-54
@@ -1,54 +0,0 @@
|
|||||||
{
|
|
||||||
"_from": "gitbook-plugin-tbfed-pagefooter",
|
|
||||||
"_id": "gitbook-plugin-tbfed-pagefooter@0.0.1",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-HUuC0bksLgkpGy+chdmYcPYdrYlThU7mFcev43dmUW4JlcbAtxL3I5R82gXQv9nSCE9vL1mrscC8+oZSqNBhdQ==",
|
|
||||||
"_location": "/gitbook-plugin-tbfed-pagefooter",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "tag",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "gitbook-plugin-tbfed-pagefooter",
|
|
||||||
"name": "gitbook-plugin-tbfed-pagefooter",
|
|
||||||
"escapedName": "gitbook-plugin-tbfed-pagefooter",
|
|
||||||
"rawSpec": "",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "latest"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmmirror.com/gitbook-plugin-tbfed-pagefooter/-/gitbook-plugin-tbfed-pagefooter-0.0.1.tgz",
|
|
||||||
"_shasum": "16ee784062dd8504264c477e8765fc49c41bed3d",
|
|
||||||
"_spec": "gitbook-plugin-tbfed-pagefooter",
|
|
||||||
"_where": "D:\\Book",
|
|
||||||
"author": {
|
|
||||||
"name": "zhj3618",
|
|
||||||
"email": "zhj3618@gmail.com"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"dependencies": {
|
|
||||||
"moment": "^2.10.6"
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "定制每篇文章的页脚,可以添加版权和显示文件修改时间",
|
|
||||||
"engines": {
|
|
||||||
"gitbook": ">=2.4.3"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/zhj3618/gitbook-plugin-tbfed-pagefooter",
|
|
||||||
"keywords": [
|
|
||||||
"gitbook",
|
|
||||||
"gitbook-plugin",
|
|
||||||
"footer",
|
|
||||||
"modification"
|
|
||||||
],
|
|
||||||
"license": "Apache 2",
|
|
||||||
"main": "index.js",
|
|
||||||
"name": "gitbook-plugin-tbfed-pagefooter",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": ""
|
|
||||||
},
|
|
||||||
"version": "0.0.1"
|
|
||||||
}
|
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
Copyright (c) 2013 Dulin Marat
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
-61
@@ -1,61 +0,0 @@
|
|||||||
node-html-entities
|
|
||||||
==================
|
|
||||||
|
|
||||||
[](https://travis-ci.org/mdevils/node-html-entities)
|
|
||||||
[](https://coveralls.io/github/mdevils/node-html-entities?branch=master)
|
|
||||||
|
|
||||||
Fast html entities library.
|
|
||||||
|
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
|
|
||||||
npm install html-entities
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-----
|
|
||||||
|
|
||||||
####XML entities####
|
|
||||||
|
|
||||||
HTML validity and XSS attack prevention you can achieve from XmlEntities class.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var Entities = require('html-entities').XmlEntities;
|
|
||||||
|
|
||||||
entities = new Entities();
|
|
||||||
|
|
||||||
console.log(entities.encode('<>"\'&©®')); // <>"'&©®
|
|
||||||
console.log(entities.encodeNonUTF('<>"\'&©®')); // <>"'&©®
|
|
||||||
console.log(entities.encodeNonASCII('<>"\'&©®')); // <>"\'&©®
|
|
||||||
console.log(entities.decode('<>"'&©®∆')); // <>"'&©®∆
|
|
||||||
```
|
|
||||||
|
|
||||||
####All HTML entities encoding/decoding####
|
|
||||||
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var Entities = require('html-entities').AllHtmlEntities;
|
|
||||||
|
|
||||||
entities = new Entities();
|
|
||||||
|
|
||||||
console.log(entities.encode('<>"&©®∆')); // <>"&©®∆
|
|
||||||
console.log(entities.encodeNonUTF('<>"&©®∆')); // <>"&©®∆
|
|
||||||
console.log(entities.encodeNonASCII('<>"&©®∆')); // <>"&©®∆
|
|
||||||
console.log(entities.decode('<>"&©®')); // <>"&©®
|
|
||||||
```
|
|
||||||
|
|
||||||
####Available classes####
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var XmlEntities = require('html-entities').XmlEntities, // <>"'& + &#...; decoding
|
|
||||||
Html4Entities = require('html-entities').Html4Entities, // HTML4 entities.
|
|
||||||
Html5Entities = require('html-entities').Html5Entities, // HTML5 entities.
|
|
||||||
AllHtmlEntities = require('html-entities').AllHtmlEntities; // Synonym for HTML5 entities.
|
|
||||||
```
|
|
||||||
|
|
||||||
Supports four methods for every class:
|
|
||||||
|
|
||||||
* encode — encodes, replacing characters to its entity representations. Ignores UTF characters with no entity representation.
|
|
||||||
* encodeNonUTF — encodes, replacing characters to its entity representations. Inserts numeric entities for UTF characters.
|
|
||||||
* encodeNonASCII — encodes, replacing only non-ASCII characters to its numeric entity representations.
|
|
||||||
* decode — decodes, replacing entities to characters. Unknown entities are left as is.
|
|
||||||
-6
@@ -1,6 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
XmlEntities: require('./lib/xml-entities.js'),
|
|
||||||
Html4Entities: require('./lib/html4-entities.js'),
|
|
||||||
Html5Entities: require('./lib/html5-entities.js'),
|
|
||||||
AllHtmlEntities: require('./lib/html5-entities.js')
|
|
||||||
};
|
|
||||||
-147
@@ -1,147 +0,0 @@
|
|||||||
var HTML_ALPHA = ['apos', 'nbsp', 'iexcl', 'cent', 'pound', 'curren', 'yen', 'brvbar', 'sect', 'uml', 'copy', 'ordf', 'laquo', 'not', 'shy', 'reg', 'macr', 'deg', 'plusmn', 'sup2', 'sup3', 'acute', 'micro', 'para', 'middot', 'cedil', 'sup1', 'ordm', 'raquo', 'frac14', 'frac12', 'frac34', 'iquest', 'Agrave', 'Aacute', 'Acirc', 'Atilde', 'Auml', 'Aring', 'Aelig', 'Ccedil', 'Egrave', 'Eacute', 'Ecirc', 'Euml', 'Igrave', 'Iacute', 'Icirc', 'Iuml', 'ETH', 'Ntilde', 'Ograve', 'Oacute', 'Ocirc', 'Otilde', 'Ouml', 'times', 'Oslash', 'Ugrave', 'Uacute', 'Ucirc', 'Uuml', 'Yacute', 'THORN', 'szlig', 'agrave', 'aacute', 'acirc', 'atilde', 'auml', 'aring', 'aelig', 'ccedil', 'egrave', 'eacute', 'ecirc', 'euml', 'igrave', 'iacute', 'icirc', 'iuml', 'eth', 'ntilde', 'ograve', 'oacute', 'ocirc', 'otilde', 'ouml', 'divide', 'Oslash', 'ugrave', 'uacute', 'ucirc', 'uuml', 'yacute', 'thorn', 'yuml', 'quot', 'amp', 'lt', 'gt', 'oelig', 'oelig', 'scaron', 'scaron', 'yuml', 'circ', 'tilde', 'ensp', 'emsp', 'thinsp', 'zwnj', 'zwj', 'lrm', 'rlm', 'ndash', 'mdash', 'lsquo', 'rsquo', 'sbquo', 'ldquo', 'rdquo', 'bdquo', 'dagger', 'dagger', 'permil', 'lsaquo', 'rsaquo', 'euro', 'fnof', 'alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', 'omicron', 'pi', 'rho', 'sigma', 'tau', 'upsilon', 'phi', 'chi', 'psi', 'omega', 'alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', 'omicron', 'pi', 'rho', 'sigmaf', 'sigma', 'tau', 'upsilon', 'phi', 'chi', 'psi', 'omega', 'thetasym', 'upsih', 'piv', 'bull', 'hellip', 'prime', 'prime', 'oline', 'frasl', 'weierp', 'image', 'real', 'trade', 'alefsym', 'larr', 'uarr', 'rarr', 'darr', 'harr', 'crarr', 'larr', 'uarr', 'rarr', 'darr', 'harr', 'forall', 'part', 'exist', 'empty', 'nabla', 'isin', 'notin', 'ni', 'prod', 'sum', 'minus', 'lowast', 'radic', 'prop', 'infin', 'ang', 'and', 'or', 'cap', 'cup', 'int', 'there4', 'sim', 'cong', 'asymp', 'ne', 'equiv', 'le', 'ge', 'sub', 'sup', 'nsub', 'sube', 'supe', 'oplus', 'otimes', 'perp', 'sdot', 'lceil', 'rceil', 'lfloor', 'rfloor', 'lang', 'rang', 'loz', 'spades', 'clubs', 'hearts', 'diams'];
|
|
||||||
var HTML_CODES = [39, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 34, 38, 60, 62, 338, 339, 352, 353, 376, 710, 732, 8194, 8195, 8201, 8204, 8205, 8206, 8207, 8211, 8212, 8216, 8217, 8218, 8220, 8221, 8222, 8224, 8225, 8240, 8249, 8250, 8364, 402, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 977, 978, 982, 8226, 8230, 8242, 8243, 8254, 8260, 8472, 8465, 8476, 8482, 8501, 8592, 8593, 8594, 8595, 8596, 8629, 8656, 8657, 8658, 8659, 8660, 8704, 8706, 8707, 8709, 8711, 8712, 8713, 8715, 8719, 8721, 8722, 8727, 8730, 8733, 8734, 8736, 8743, 8744, 8745, 8746, 8747, 8756, 8764, 8773, 8776, 8800, 8801, 8804, 8805, 8834, 8835, 8836, 8838, 8839, 8853, 8855, 8869, 8901, 8968, 8969, 8970, 8971, 9001, 9002, 9674, 9824, 9827, 9829, 9830];
|
|
||||||
|
|
||||||
var alphaIndex = {};
|
|
||||||
var numIndex = {};
|
|
||||||
|
|
||||||
var i = 0;
|
|
||||||
var length = HTML_ALPHA.length;
|
|
||||||
while (i < length) {
|
|
||||||
var a = HTML_ALPHA[i];
|
|
||||||
var c = HTML_CODES[i];
|
|
||||||
alphaIndex[a] = String.fromCharCode(c);
|
|
||||||
numIndex[c] = a;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function Html4Entities() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
Html4Entities.prototype.decode = function(str) {
|
|
||||||
if (str.length === 0) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
return str.replace(/&(#?[\w\d]+);?/g, function(s, entity) {
|
|
||||||
var chr;
|
|
||||||
if (entity.charAt(0) === "#") {
|
|
||||||
var code = entity.charAt(1).toLowerCase() === 'x' ?
|
|
||||||
parseInt(entity.substr(2), 16) :
|
|
||||||
parseInt(entity.substr(1));
|
|
||||||
|
|
||||||
if (!(isNaN(code) || code < -32768 || code > 65535)) {
|
|
||||||
chr = String.fromCharCode(code);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
chr = alphaIndex[entity];
|
|
||||||
}
|
|
||||||
return chr || s;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
Html4Entities.decode = function(str) {
|
|
||||||
return new Html4Entities().decode(str);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
Html4Entities.prototype.encode = function(str) {
|
|
||||||
var strLength = str.length;
|
|
||||||
if (strLength === 0) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
var result = '';
|
|
||||||
var i = 0;
|
|
||||||
while (i < strLength) {
|
|
||||||
var alpha = numIndex[str.charCodeAt(i)];
|
|
||||||
result += alpha ? "&" + alpha + ";" : str.charAt(i);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
Html4Entities.encode = function(str) {
|
|
||||||
return new Html4Entities().encode(str);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
Html4Entities.prototype.encodeNonUTF = function(str) {
|
|
||||||
var strLength = str.length;
|
|
||||||
if (strLength === 0) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
var result = '';
|
|
||||||
var i = 0;
|
|
||||||
while (i < strLength) {
|
|
||||||
var cc = str.charCodeAt(i);
|
|
||||||
var alpha = numIndex[cc];
|
|
||||||
if (alpha) {
|
|
||||||
result += "&" + alpha + ";";
|
|
||||||
} else if (cc < 32 || cc > 126) {
|
|
||||||
result += "&#" + cc + ";";
|
|
||||||
} else {
|
|
||||||
result += str.charAt(i);
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
Html4Entities.encodeNonUTF = function(str) {
|
|
||||||
return new Html4Entities().encodeNonUTF(str);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
Html4Entities.prototype.encodeNonASCII = function(str) {
|
|
||||||
var strLength = str.length;
|
|
||||||
if (strLength === 0) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
var result = '';
|
|
||||||
var i = 0;
|
|
||||||
while (i < strLength) {
|
|
||||||
var c = str.charCodeAt(i);
|
|
||||||
if (c <= 255) {
|
|
||||||
result += str[i++];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
result += '&#' + c + ';';
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
Html4Entities.encodeNonASCII = function(str) {
|
|
||||||
return new Html4Entities().encodeNonASCII(str);
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = Html4Entities;
|
|
||||||
-190
File diff suppressed because one or more lines are too long
-155
@@ -1,155 +0,0 @@
|
|||||||
var ALPHA_INDEX = {
|
|
||||||
'<': '<',
|
|
||||||
'>': '>',
|
|
||||||
'"': '"',
|
|
||||||
'&apos': '\'',
|
|
||||||
'&': '&',
|
|
||||||
'<': '<',
|
|
||||||
'>': '>',
|
|
||||||
'"': '"',
|
|
||||||
''': '\'',
|
|
||||||
'&': '&'
|
|
||||||
};
|
|
||||||
|
|
||||||
var CHAR_INDEX = {
|
|
||||||
60: 'lt',
|
|
||||||
62: 'gt',
|
|
||||||
34: 'quot',
|
|
||||||
39: 'apos',
|
|
||||||
38: 'amp'
|
|
||||||
};
|
|
||||||
|
|
||||||
var CHAR_S_INDEX = {
|
|
||||||
'<': '<',
|
|
||||||
'>': '>',
|
|
||||||
'"': '"',
|
|
||||||
'\'': ''',
|
|
||||||
'&': '&'
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function XmlEntities() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
XmlEntities.prototype.encode = function(str) {
|
|
||||||
if (str.length === 0) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
return str.replace(/<|>|"|'|&/g, function(s) {
|
|
||||||
return CHAR_S_INDEX[s];
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
XmlEntities.encode = function(str) {
|
|
||||||
return new XmlEntities().encode(str);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
XmlEntities.prototype.decode = function(str) {
|
|
||||||
if (str.length === 0) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
return str.replace(/&#?[0-9a-zA-Z]+;?/g, function(s) {
|
|
||||||
if (s.charAt(1) === '#') {
|
|
||||||
var code = s.charAt(2).toLowerCase() === 'x' ?
|
|
||||||
parseInt(s.substr(3), 16) :
|
|
||||||
parseInt(s.substr(2));
|
|
||||||
|
|
||||||
if (isNaN(code) || code < -32768 || code > 65535) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
return String.fromCharCode(code);
|
|
||||||
}
|
|
||||||
return ALPHA_INDEX[s] || s;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
XmlEntities.decode = function(str) {
|
|
||||||
return new XmlEntities().decode(str);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
XmlEntities.prototype.encodeNonUTF = function(str) {
|
|
||||||
var strLength = str.length;
|
|
||||||
if (strLength === 0) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
var result = '';
|
|
||||||
var i = 0;
|
|
||||||
while (i < strLength) {
|
|
||||||
var c = str.charCodeAt(i);
|
|
||||||
var alpha = CHAR_INDEX[c];
|
|
||||||
if (alpha) {
|
|
||||||
result += "&" + alpha + ";";
|
|
||||||
i++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c < 32 || c > 126) {
|
|
||||||
result += '&#' + c + ';';
|
|
||||||
} else {
|
|
||||||
result += str.charAt(i);
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
XmlEntities.encodeNonUTF = function(str) {
|
|
||||||
return new XmlEntities().encodeNonUTF(str);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
XmlEntities.prototype.encodeNonASCII = function(str) {
|
|
||||||
var strLenght = str.length;
|
|
||||||
if (strLenght === 0) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
var result = '';
|
|
||||||
var i = 0;
|
|
||||||
while (i < strLenght) {
|
|
||||||
var c = str.charCodeAt(i);
|
|
||||||
if (c <= 255) {
|
|
||||||
result += str[i++];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
result += '&#' + c + ';';
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {String} str
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
XmlEntities.encodeNonASCII = function(str) {
|
|
||||||
return new XmlEntities().encodeNonASCII(str);
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = XmlEntities;
|
|
||||||
-88
@@ -1,88 +0,0 @@
|
|||||||
{
|
|
||||||
"_args": [
|
|
||||||
[
|
|
||||||
"html-entities@1.2.0",
|
|
||||||
"D:\\Book"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "html-entities@1.2.0",
|
|
||||||
"_id": "html-entities@1.2.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-0md7tlUUyb0BEQGsZzbqty1CgV6RESOoxdivt94AScqhBhYsPCCQCOaGvur/RospMjYpPJ7iFe3zw4Bu4SVA8g==",
|
|
||||||
"_location": "/html-entities",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "html-entities@1.2.0",
|
|
||||||
"name": "html-entities",
|
|
||||||
"escapedName": "html-entities",
|
|
||||||
"rawSpec": "1.2.0",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "1.2.0"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/gitbook-plugin-search-pro"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmmirror.com/html-entities/-/html-entities-1.2.0.tgz",
|
|
||||||
"_spec": "1.2.0",
|
|
||||||
"_where": "D:\\Book",
|
|
||||||
"author": {
|
|
||||||
"name": "Marat Dulin",
|
|
||||||
"email": "mdevils@yandex.ru"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/mdevils/node-html-entities/issues"
|
|
||||||
},
|
|
||||||
"dependencies": {},
|
|
||||||
"description": "Faster HTML entities encode/decode library.",
|
|
||||||
"devDependencies": {
|
|
||||||
"chai": "^1.9.1",
|
|
||||||
"coveralls": "^2.11.2",
|
|
||||||
"entities": "*",
|
|
||||||
"mocha": "^1.21.4",
|
|
||||||
"node-html-encoder": "*",
|
|
||||||
"unit-coverage": "^3.0.1"
|
|
||||||
},
|
|
||||||
"engines": [
|
|
||||||
"node >= 0.4.0"
|
|
||||||
],
|
|
||||||
"files": [
|
|
||||||
"index.js",
|
|
||||||
"lib",
|
|
||||||
"LICENSE"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/mdevils/node-html-entities#readme",
|
|
||||||
"keywords": [
|
|
||||||
"html",
|
|
||||||
"html entities",
|
|
||||||
"html entities encode",
|
|
||||||
"html entities decode",
|
|
||||||
"entities",
|
|
||||||
"entities encode",
|
|
||||||
"entities decode"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "index",
|
|
||||||
"name": "html-entities",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/mdevils/node-html-entities.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"benchmark": "node benchmark/benchmark",
|
|
||||||
"coverage": "unit-coverage run -p common",
|
|
||||||
"coverage-html": "unit-coverage run -p common -r html -o coverage.html",
|
|
||||||
"test": "mocha --recursive -R spec test",
|
|
||||||
"travis": "npm test && unit-coverage run -p common -r lcov -o coverage.lcov && cat coverage.lcov | coveralls"
|
|
||||||
},
|
|
||||||
"unit-coverage": {
|
|
||||||
"common": [
|
|
||||||
"-s",
|
|
||||||
"lib/**/*.js",
|
|
||||||
"-t",
|
|
||||||
"test/**/*.js"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"version": "1.2.0"
|
|
||||||
}
|
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
|
||||||
Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas,
|
|
||||||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
a copy of this software and associated documentation files (the
|
|
||||||
"Software"), to deal in the Software without restriction, including
|
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
-121
@@ -1,121 +0,0 @@
|
|||||||
# lodash v3.10.1
|
|
||||||
|
|
||||||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) modules.
|
|
||||||
|
|
||||||
Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
|
|
||||||
```bash
|
|
||||||
$ lodash modularize modern exports=node -o ./
|
|
||||||
$ lodash modern -d -o ./index.js
|
|
||||||
```
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
Using npm:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ {sudo -H} npm i -g npm
|
|
||||||
$ npm i --save lodash
|
|
||||||
```
|
|
||||||
|
|
||||||
In Node.js/io.js:
|
|
||||||
|
|
||||||
```js
|
|
||||||
// load the modern build
|
|
||||||
var _ = require('lodash');
|
|
||||||
// or a method category
|
|
||||||
var array = require('lodash/array');
|
|
||||||
// or a method (great for smaller builds with browserify/webpack)
|
|
||||||
var chunk = require('lodash/array/chunk');
|
|
||||||
```
|
|
||||||
|
|
||||||
See the [package source](https://github.com/lodash/lodash/tree/3.10.1-npm) for more details.
|
|
||||||
|
|
||||||
**Note:**<br>
|
|
||||||
Don’t assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.<br>
|
|
||||||
Install [n_](https://www.npmjs.com/package/n_) for a REPL that includes lodash by default.
|
|
||||||
|
|
||||||
## Module formats
|
|
||||||
|
|
||||||
lodash is also available in a variety of other builds & module formats.
|
|
||||||
|
|
||||||
* npm packages for [modern](https://www.npmjs.com/package/lodash), [compatibility](https://www.npmjs.com/package/lodash-compat), & [per method](https://www.npmjs.com/browse/keyword/lodash-modularized) builds
|
|
||||||
* AMD modules for [modern](https://github.com/lodash/lodash/tree/3.10.1-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.10.1-amd) builds
|
|
||||||
* ES modules for the [modern](https://github.com/lodash/lodash/tree/3.10.1-es) build
|
|
||||||
|
|
||||||
## Further Reading
|
|
||||||
|
|
||||||
* [API Documentation](https://lodash.com/docs)
|
|
||||||
* [Build Differences](https://github.com/lodash/lodash/wiki/Build-Differences)
|
|
||||||
* [Changelog](https://github.com/lodash/lodash/wiki/Changelog)
|
|
||||||
* [Roadmap](https://github.com/lodash/lodash/wiki/Roadmap)
|
|
||||||
* [More Resources](https://github.com/lodash/lodash/wiki/Resources)
|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
* ~100% [code coverage](https://coveralls.io/r/lodash)
|
|
||||||
* Follows [semantic versioning](http://semver.org/) for releases
|
|
||||||
* [Lazily evaluated](http://filimanjaro.com/blog/2014/introducing-lazy-evaluation/) chaining
|
|
||||||
* [_(…)](https://lodash.com/docs#_) supports implicit chaining
|
|
||||||
* [_.ary](https://lodash.com/docs#ary) & [_.rearg](https://lodash.com/docs#rearg) to change function argument limits & order
|
|
||||||
* [_.at](https://lodash.com/docs#at) for cherry-picking collection values
|
|
||||||
* [_.attempt](https://lodash.com/docs#attempt) to execute functions which may error without a try-catch
|
|
||||||
* [_.before](https://lodash.com/docs#before) to complement [_.after](https://lodash.com/docs#after)
|
|
||||||
* [_.bindKey](https://lodash.com/docs#bindKey) for binding [*“lazy”*](http://michaux.ca/articles/lazy-function-definition-pattern) defined methods
|
|
||||||
* [_.chunk](https://lodash.com/docs#chunk) for splitting an array into chunks of a given size
|
|
||||||
* [_.clone](https://lodash.com/docs#clone) supports shallow cloning of `Date` & `RegExp` objects
|
|
||||||
* [_.cloneDeep](https://lodash.com/docs#cloneDeep) for deep cloning arrays & objects
|
|
||||||
* [_.curry](https://lodash.com/docs#curry) & [_.curryRight](https://lodash.com/docs#curryRight) for creating [curried](http://hughfdjackson.com/javascript/why-curry-helps/) functions
|
|
||||||
* [_.debounce](https://lodash.com/docs#debounce) & [_.throttle](https://lodash.com/docs#throttle) are cancelable & accept options for more control
|
|
||||||
* [_.defaultsDeep](https://lodash.com/docs#defaultsDeep) for recursively assigning default properties
|
|
||||||
* [_.fill](https://lodash.com/docs#fill) to fill arrays with values
|
|
||||||
* [_.findKey](https://lodash.com/docs#findKey) for finding keys
|
|
||||||
* [_.flow](https://lodash.com/docs#flow) to complement [_.flowRight](https://lodash.com/docs#flowRight) (a.k.a `_.compose`)
|
|
||||||
* [_.forEach](https://lodash.com/docs#forEach) supports exiting early
|
|
||||||
* [_.forIn](https://lodash.com/docs#forIn) for iterating all enumerable properties
|
|
||||||
* [_.forOwn](https://lodash.com/docs#forOwn) for iterating own properties
|
|
||||||
* [_.get](https://lodash.com/docs#get) & [_.set](https://lodash.com/docs#set) for deep property getting & setting
|
|
||||||
* [_.gt](https://lodash.com/docs#gt), [_.gte](https://lodash.com/docs#gte), [_.lt](https://lodash.com/docs#lt), & [_.lte](https://lodash.com/docs#lte) relational methods
|
|
||||||
* [_.inRange](https://lodash.com/docs#inRange) for checking whether a number is within a given range
|
|
||||||
* [_.isNative](https://lodash.com/docs#isNative) to check for native functions
|
|
||||||
* [_.isPlainObject](https://lodash.com/docs#isPlainObject) & [_.toPlainObject](https://lodash.com/docs#toPlainObject) to check for & convert to `Object` objects
|
|
||||||
* [_.isTypedArray](https://lodash.com/docs#isTypedArray) to check for typed arrays
|
|
||||||
* [_.mapKeys](https://lodash.com/docs#mapKeys) for mapping keys to an object
|
|
||||||
* [_.matches](https://lodash.com/docs#matches) supports deep object comparisons
|
|
||||||
* [_.matchesProperty](https://lodash.com/docs#matchesProperty) to complement [_.matches](https://lodash.com/docs#matches) & [_.property](https://lodash.com/docs#property)
|
|
||||||
* [_.merge](https://lodash.com/docs#merge) for a deep [_.extend](https://lodash.com/docs#extend)
|
|
||||||
* [_.method](https://lodash.com/docs#method) & [_.methodOf](https://lodash.com/docs#methodOf) to create functions that invoke methods
|
|
||||||
* [_.modArgs](https://lodash.com/docs#modArgs) for more advanced functional composition
|
|
||||||
* [_.parseInt](https://lodash.com/docs#parseInt) for consistent cross-environment behavior
|
|
||||||
* [_.pull](https://lodash.com/docs#pull), [_.pullAt](https://lodash.com/docs#pullAt), & [_.remove](https://lodash.com/docs#remove) for mutating arrays
|
|
||||||
* [_.random](https://lodash.com/docs#random) supports returning floating-point numbers
|
|
||||||
* [_.restParam](https://lodash.com/docs#restParam) & [_.spread](https://lodash.com/docs#spread) for applying rest parameters & spreading arguments to functions
|
|
||||||
* [_.runInContext](https://lodash.com/docs#runInContext) for collisionless mixins & easier mocking
|
|
||||||
* [_.slice](https://lodash.com/docs#slice) for creating subsets of array-like values
|
|
||||||
* [_.sortByAll](https://lodash.com/docs#sortByAll) & [_.sortByOrder](https://lodash.com/docs#sortByOrder) for sorting by multiple properties & orders
|
|
||||||
* [_.support](https://lodash.com/docs#support) for flagging environment features
|
|
||||||
* [_.template](https://lodash.com/docs#template) supports [*“imports”*](https://lodash.com/docs#templateSettings-imports) options & [ES template delimiters](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components)
|
|
||||||
* [_.transform](https://lodash.com/docs#transform) as a powerful alternative to [_.reduce](https://lodash.com/docs#reduce) for transforming objects
|
|
||||||
* [_.unzipWith](https://lodash.com/docs#unzipWith) & [_.zipWith](https://lodash.com/docs#zipWith) to specify how grouped values should be combined
|
|
||||||
* [_.valuesIn](https://lodash.com/docs#valuesIn) for getting values of all enumerable properties
|
|
||||||
* [_.xor](https://lodash.com/docs#xor) to complement [_.difference](https://lodash.com/docs#difference), [_.intersection](https://lodash.com/docs#intersection), & [_.union](https://lodash.com/docs#union)
|
|
||||||
* [_.add](https://lodash.com/docs#add), [_.round](https://lodash.com/docs#round), [_.sum](https://lodash.com/docs#sum), &
|
|
||||||
[more](https://lodash.com/docs "_.ceil & _.floor") math methods
|
|
||||||
* [_.bind](https://lodash.com/docs#bind), [_.curry](https://lodash.com/docs#curry), [_.partial](https://lodash.com/docs#partial), &
|
|
||||||
[more](https://lodash.com/docs "_.bindKey, _.curryRight, _.partialRight") support customizable argument placeholders
|
|
||||||
* [_.capitalize](https://lodash.com/docs#capitalize), [_.trim](https://lodash.com/docs#trim), &
|
|
||||||
[more](https://lodash.com/docs "_.camelCase, _.deburr, _.endsWith, _.escapeRegExp, _.kebabCase, _.pad, _.padLeft, _.padRight, _.repeat, _.snakeCase, _.startCase, _.startsWith, _.trimLeft, _.trimRight, _.trunc, _.words") string methods
|
|
||||||
* [_.clone](https://lodash.com/docs#clone), [_.isEqual](https://lodash.com/docs#isEqual), &
|
|
||||||
[more](https://lodash.com/docs "_.assign, _.cloneDeep, _.merge") accept customizer callbacks
|
|
||||||
* [_.dropWhile](https://lodash.com/docs#dropWhile), [_.takeWhile](https://lodash.com/docs#takeWhile), &
|
|
||||||
[more](https://lodash.com/docs "_.drop, _.dropRight, _.dropRightWhile, _.take, _.takeRight, _.takeRightWhile") to complement [_.first](https://lodash.com/docs#first), [_.initial](https://lodash.com/docs#initial), [_.last](https://lodash.com/docs#last), & [_.rest](https://lodash.com/docs#rest)
|
|
||||||
* [_.findLast](https://lodash.com/docs#findLast), [_.findLastKey](https://lodash.com/docs#findLastKey), &
|
|
||||||
[more](https://lodash.com/docs "_.curryRight, _.dropRight, _.dropRightWhile, _.flowRight, _.forEachRight, _.forInRight, _.forOwnRight, _.padRight, partialRight, _.takeRight, _.trimRight, _.takeRightWhile") right-associative methods
|
|
||||||
* [_.includes](https://lodash.com/docs#includes), [_.toArray](https://lodash.com/docs#toArray), &
|
|
||||||
[more](https://lodash.com/docs "_.at, _.countBy, _.every, _.filter, _.find, _.findLast, _.findWhere, _.forEach, _.forEachRight, _.groupBy, _.indexBy, _.invoke, _.map, _.max, _.min, _.partition, _.pluck, _.reduce, _.reduceRight, _.reject, _.shuffle, _.size, _.some, _.sortBy, _.sortByAll, _.sortByOrder, _.sum, _.where") accept strings
|
|
||||||
* [_#commit](https://lodash.com/docs#prototype-commit) & [_#plant](https://lodash.com/docs#prototype-plant) for working with chain sequences
|
|
||||||
* [_#thru](https://lodash.com/docs#thru) to pass values thru a chain sequence
|
|
||||||
|
|
||||||
## Support
|
|
||||||
|
|
||||||
Tested in Chrome 43-44, Firefox 38-39, IE 6-11, MS Edge, Safari 5-8, ChakraNode 0.12.2, io.js 2.5.0, Node.js 0.8.28, 0.10.40, & 0.12.7, PhantomJS 1.9.8, RingoJS 0.11, & Rhino 1.7.6.
|
|
||||||
Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available. Special thanks to [Sauce Labs](https://saucelabs.com/) for providing automated browser testing.
|
|
||||||
-44
@@ -1,44 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
'chunk': require('./array/chunk'),
|
|
||||||
'compact': require('./array/compact'),
|
|
||||||
'difference': require('./array/difference'),
|
|
||||||
'drop': require('./array/drop'),
|
|
||||||
'dropRight': require('./array/dropRight'),
|
|
||||||
'dropRightWhile': require('./array/dropRightWhile'),
|
|
||||||
'dropWhile': require('./array/dropWhile'),
|
|
||||||
'fill': require('./array/fill'),
|
|
||||||
'findIndex': require('./array/findIndex'),
|
|
||||||
'findLastIndex': require('./array/findLastIndex'),
|
|
||||||
'first': require('./array/first'),
|
|
||||||
'flatten': require('./array/flatten'),
|
|
||||||
'flattenDeep': require('./array/flattenDeep'),
|
|
||||||
'head': require('./array/head'),
|
|
||||||
'indexOf': require('./array/indexOf'),
|
|
||||||
'initial': require('./array/initial'),
|
|
||||||
'intersection': require('./array/intersection'),
|
|
||||||
'last': require('./array/last'),
|
|
||||||
'lastIndexOf': require('./array/lastIndexOf'),
|
|
||||||
'object': require('./array/object'),
|
|
||||||
'pull': require('./array/pull'),
|
|
||||||
'pullAt': require('./array/pullAt'),
|
|
||||||
'remove': require('./array/remove'),
|
|
||||||
'rest': require('./array/rest'),
|
|
||||||
'slice': require('./array/slice'),
|
|
||||||
'sortedIndex': require('./array/sortedIndex'),
|
|
||||||
'sortedLastIndex': require('./array/sortedLastIndex'),
|
|
||||||
'tail': require('./array/tail'),
|
|
||||||
'take': require('./array/take'),
|
|
||||||
'takeRight': require('./array/takeRight'),
|
|
||||||
'takeRightWhile': require('./array/takeRightWhile'),
|
|
||||||
'takeWhile': require('./array/takeWhile'),
|
|
||||||
'union': require('./array/union'),
|
|
||||||
'uniq': require('./array/uniq'),
|
|
||||||
'unique': require('./array/unique'),
|
|
||||||
'unzip': require('./array/unzip'),
|
|
||||||
'unzipWith': require('./array/unzipWith'),
|
|
||||||
'without': require('./array/without'),
|
|
||||||
'xor': require('./array/xor'),
|
|
||||||
'zip': require('./array/zip'),
|
|
||||||
'zipObject': require('./array/zipObject'),
|
|
||||||
'zipWith': require('./array/zipWith')
|
|
||||||
};
|
|
||||||
-46
@@ -1,46 +0,0 @@
|
|||||||
var baseSlice = require('../internal/baseSlice'),
|
|
||||||
isIterateeCall = require('../internal/isIterateeCall');
|
|
||||||
|
|
||||||
/* Native method references for those with the same name as other `lodash` methods. */
|
|
||||||
var nativeCeil = Math.ceil,
|
|
||||||
nativeFloor = Math.floor,
|
|
||||||
nativeMax = Math.max;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an array of elements split into groups the length of `size`.
|
|
||||||
* If `collection` can't be split evenly, the final chunk will be the remaining
|
|
||||||
* elements.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to process.
|
|
||||||
* @param {number} [size=1] The length of each chunk.
|
|
||||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
||||||
* @returns {Array} Returns the new array containing chunks.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.chunk(['a', 'b', 'c', 'd'], 2);
|
|
||||||
* // => [['a', 'b'], ['c', 'd']]
|
|
||||||
*
|
|
||||||
* _.chunk(['a', 'b', 'c', 'd'], 3);
|
|
||||||
* // => [['a', 'b', 'c'], ['d']]
|
|
||||||
*/
|
|
||||||
function chunk(array, size, guard) {
|
|
||||||
if (guard ? isIterateeCall(array, size, guard) : size == null) {
|
|
||||||
size = 1;
|
|
||||||
} else {
|
|
||||||
size = nativeMax(nativeFloor(size) || 1, 1);
|
|
||||||
}
|
|
||||||
var index = 0,
|
|
||||||
length = array ? array.length : 0,
|
|
||||||
resIndex = -1,
|
|
||||||
result = Array(nativeCeil(length / size));
|
|
||||||
|
|
||||||
while (index < length) {
|
|
||||||
result[++resIndex] = baseSlice(array, index, (index += size));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = chunk;
|
|
||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
/**
|
|
||||||
* Creates an array with all falsey values removed. The values `false`, `null`,
|
|
||||||
* `0`, `""`, `undefined`, and `NaN` are falsey.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to compact.
|
|
||||||
* @returns {Array} Returns the new array of filtered values.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.compact([0, 1, false, 2, '', 3]);
|
|
||||||
* // => [1, 2, 3]
|
|
||||||
*/
|
|
||||||
function compact(array) {
|
|
||||||
var index = -1,
|
|
||||||
length = array ? array.length : 0,
|
|
||||||
resIndex = -1,
|
|
||||||
result = [];
|
|
||||||
|
|
||||||
while (++index < length) {
|
|
||||||
var value = array[index];
|
|
||||||
if (value) {
|
|
||||||
result[++resIndex] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = compact;
|
|
||||||
-29
@@ -1,29 +0,0 @@
|
|||||||
var baseDifference = require('../internal/baseDifference'),
|
|
||||||
baseFlatten = require('../internal/baseFlatten'),
|
|
||||||
isArrayLike = require('../internal/isArrayLike'),
|
|
||||||
isObjectLike = require('../internal/isObjectLike'),
|
|
||||||
restParam = require('../function/restParam');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an array of unique `array` values not included in the other
|
|
||||||
* provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
|
||||||
* for equality comparisons.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to inspect.
|
|
||||||
* @param {...Array} [values] The arrays of values to exclude.
|
|
||||||
* @returns {Array} Returns the new array of filtered values.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.difference([1, 2, 3], [4, 2]);
|
|
||||||
* // => [1, 3]
|
|
||||||
*/
|
|
||||||
var difference = restParam(function(array, values) {
|
|
||||||
return (isObjectLike(array) && isArrayLike(array))
|
|
||||||
? baseDifference(array, baseFlatten(values, false, true))
|
|
||||||
: [];
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = difference;
|
|
||||||
-39
@@ -1,39 +0,0 @@
|
|||||||
var baseSlice = require('../internal/baseSlice'),
|
|
||||||
isIterateeCall = require('../internal/isIterateeCall');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a slice of `array` with `n` elements dropped from the beginning.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to query.
|
|
||||||
* @param {number} [n=1] The number of elements to drop.
|
|
||||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
||||||
* @returns {Array} Returns the slice of `array`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.drop([1, 2, 3]);
|
|
||||||
* // => [2, 3]
|
|
||||||
*
|
|
||||||
* _.drop([1, 2, 3], 2);
|
|
||||||
* // => [3]
|
|
||||||
*
|
|
||||||
* _.drop([1, 2, 3], 5);
|
|
||||||
* // => []
|
|
||||||
*
|
|
||||||
* _.drop([1, 2, 3], 0);
|
|
||||||
* // => [1, 2, 3]
|
|
||||||
*/
|
|
||||||
function drop(array, n, guard) {
|
|
||||||
var length = array ? array.length : 0;
|
|
||||||
if (!length) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
if (guard ? isIterateeCall(array, n, guard) : n == null) {
|
|
||||||
n = 1;
|
|
||||||
}
|
|
||||||
return baseSlice(array, n < 0 ? 0 : n);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = drop;
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
var baseSlice = require('../internal/baseSlice'),
|
|
||||||
isIterateeCall = require('../internal/isIterateeCall');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a slice of `array` with `n` elements dropped from the end.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to query.
|
|
||||||
* @param {number} [n=1] The number of elements to drop.
|
|
||||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
||||||
* @returns {Array} Returns the slice of `array`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.dropRight([1, 2, 3]);
|
|
||||||
* // => [1, 2]
|
|
||||||
*
|
|
||||||
* _.dropRight([1, 2, 3], 2);
|
|
||||||
* // => [1]
|
|
||||||
*
|
|
||||||
* _.dropRight([1, 2, 3], 5);
|
|
||||||
* // => []
|
|
||||||
*
|
|
||||||
* _.dropRight([1, 2, 3], 0);
|
|
||||||
* // => [1, 2, 3]
|
|
||||||
*/
|
|
||||||
function dropRight(array, n, guard) {
|
|
||||||
var length = array ? array.length : 0;
|
|
||||||
if (!length) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
if (guard ? isIterateeCall(array, n, guard) : n == null) {
|
|
||||||
n = 1;
|
|
||||||
}
|
|
||||||
n = length - (+n || 0);
|
|
||||||
return baseSlice(array, 0, n < 0 ? 0 : n);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = dropRight;
|
|
||||||
-59
@@ -1,59 +0,0 @@
|
|||||||
var baseCallback = require('../internal/baseCallback'),
|
|
||||||
baseWhile = require('../internal/baseWhile');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a slice of `array` excluding elements dropped from the end.
|
|
||||||
* Elements are dropped until `predicate` returns falsey. The predicate is
|
|
||||||
* bound to `thisArg` and invoked with three arguments: (value, index, array).
|
|
||||||
*
|
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
|
||||||
* style callback returns the property value of the given element.
|
|
||||||
*
|
|
||||||
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
||||||
* style callback returns `true` for elements that have a matching property
|
|
||||||
* value, else `false`.
|
|
||||||
*
|
|
||||||
* If an object is provided for `predicate` the created `_.matches` style
|
|
||||||
* callback returns `true` for elements that match the properties of the given
|
|
||||||
* object, else `false`.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to query.
|
|
||||||
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
||||||
* per iteration.
|
|
||||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
||||||
* @returns {Array} Returns the slice of `array`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.dropRightWhile([1, 2, 3], function(n) {
|
|
||||||
* return n > 1;
|
|
||||||
* });
|
|
||||||
* // => [1]
|
|
||||||
*
|
|
||||||
* var users = [
|
|
||||||
* { 'user': 'barney', 'active': true },
|
|
||||||
* { 'user': 'fred', 'active': false },
|
|
||||||
* { 'user': 'pebbles', 'active': false }
|
|
||||||
* ];
|
|
||||||
*
|
|
||||||
* // using the `_.matches` callback shorthand
|
|
||||||
* _.pluck(_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user');
|
|
||||||
* // => ['barney', 'fred']
|
|
||||||
*
|
|
||||||
* // using the `_.matchesProperty` callback shorthand
|
|
||||||
* _.pluck(_.dropRightWhile(users, 'active', false), 'user');
|
|
||||||
* // => ['barney']
|
|
||||||
*
|
|
||||||
* // using the `_.property` callback shorthand
|
|
||||||
* _.pluck(_.dropRightWhile(users, 'active'), 'user');
|
|
||||||
* // => ['barney', 'fred', 'pebbles']
|
|
||||||
*/
|
|
||||||
function dropRightWhile(array, predicate, thisArg) {
|
|
||||||
return (array && array.length)
|
|
||||||
? baseWhile(array, baseCallback(predicate, thisArg, 3), true, true)
|
|
||||||
: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = dropRightWhile;
|
|
||||||
-59
@@ -1,59 +0,0 @@
|
|||||||
var baseCallback = require('../internal/baseCallback'),
|
|
||||||
baseWhile = require('../internal/baseWhile');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a slice of `array` excluding elements dropped from the beginning.
|
|
||||||
* Elements are dropped until `predicate` returns falsey. The predicate is
|
|
||||||
* bound to `thisArg` and invoked with three arguments: (value, index, array).
|
|
||||||
*
|
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
|
||||||
* style callback returns the property value of the given element.
|
|
||||||
*
|
|
||||||
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
||||||
* style callback returns `true` for elements that have a matching property
|
|
||||||
* value, else `false`.
|
|
||||||
*
|
|
||||||
* If an object is provided for `predicate` the created `_.matches` style
|
|
||||||
* callback returns `true` for elements that have the properties of the given
|
|
||||||
* object, else `false`.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to query.
|
|
||||||
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
||||||
* per iteration.
|
|
||||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
||||||
* @returns {Array} Returns the slice of `array`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.dropWhile([1, 2, 3], function(n) {
|
|
||||||
* return n < 3;
|
|
||||||
* });
|
|
||||||
* // => [3]
|
|
||||||
*
|
|
||||||
* var users = [
|
|
||||||
* { 'user': 'barney', 'active': false },
|
|
||||||
* { 'user': 'fred', 'active': false },
|
|
||||||
* { 'user': 'pebbles', 'active': true }
|
|
||||||
* ];
|
|
||||||
*
|
|
||||||
* // using the `_.matches` callback shorthand
|
|
||||||
* _.pluck(_.dropWhile(users, { 'user': 'barney', 'active': false }), 'user');
|
|
||||||
* // => ['fred', 'pebbles']
|
|
||||||
*
|
|
||||||
* // using the `_.matchesProperty` callback shorthand
|
|
||||||
* _.pluck(_.dropWhile(users, 'active', false), 'user');
|
|
||||||
* // => ['pebbles']
|
|
||||||
*
|
|
||||||
* // using the `_.property` callback shorthand
|
|
||||||
* _.pluck(_.dropWhile(users, 'active'), 'user');
|
|
||||||
* // => ['barney', 'fred', 'pebbles']
|
|
||||||
*/
|
|
||||||
function dropWhile(array, predicate, thisArg) {
|
|
||||||
return (array && array.length)
|
|
||||||
? baseWhile(array, baseCallback(predicate, thisArg, 3), true)
|
|
||||||
: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = dropWhile;
|
|
||||||
-44
@@ -1,44 +0,0 @@
|
|||||||
var baseFill = require('../internal/baseFill'),
|
|
||||||
isIterateeCall = require('../internal/isIterateeCall');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fills elements of `array` with `value` from `start` up to, but not
|
|
||||||
* including, `end`.
|
|
||||||
*
|
|
||||||
* **Note:** This method mutates `array`.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to fill.
|
|
||||||
* @param {*} value The value to fill `array` with.
|
|
||||||
* @param {number} [start=0] The start position.
|
|
||||||
* @param {number} [end=array.length] The end position.
|
|
||||||
* @returns {Array} Returns `array`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* var array = [1, 2, 3];
|
|
||||||
*
|
|
||||||
* _.fill(array, 'a');
|
|
||||||
* console.log(array);
|
|
||||||
* // => ['a', 'a', 'a']
|
|
||||||
*
|
|
||||||
* _.fill(Array(3), 2);
|
|
||||||
* // => [2, 2, 2]
|
|
||||||
*
|
|
||||||
* _.fill([4, 6, 8], '*', 1, 2);
|
|
||||||
* // => [4, '*', 8]
|
|
||||||
*/
|
|
||||||
function fill(array, value, start, end) {
|
|
||||||
var length = array ? array.length : 0;
|
|
||||||
if (!length) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
|
|
||||||
start = 0;
|
|
||||||
end = length;
|
|
||||||
}
|
|
||||||
return baseFill(array, value, start, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = fill;
|
|
||||||
-53
@@ -1,53 +0,0 @@
|
|||||||
var createFindIndex = require('../internal/createFindIndex');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is like `_.find` except that it returns the index of the first
|
|
||||||
* element `predicate` returns truthy for instead of the element itself.
|
|
||||||
*
|
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
|
||||||
* style callback returns the property value of the given element.
|
|
||||||
*
|
|
||||||
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
||||||
* style callback returns `true` for elements that have a matching property
|
|
||||||
* value, else `false`.
|
|
||||||
*
|
|
||||||
* If an object is provided for `predicate` the created `_.matches` style
|
|
||||||
* callback returns `true` for elements that have the properties of the given
|
|
||||||
* object, else `false`.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to search.
|
|
||||||
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
||||||
* per iteration.
|
|
||||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
||||||
* @returns {number} Returns the index of the found element, else `-1`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* var users = [
|
|
||||||
* { 'user': 'barney', 'active': false },
|
|
||||||
* { 'user': 'fred', 'active': false },
|
|
||||||
* { 'user': 'pebbles', 'active': true }
|
|
||||||
* ];
|
|
||||||
*
|
|
||||||
* _.findIndex(users, function(chr) {
|
|
||||||
* return chr.user == 'barney';
|
|
||||||
* });
|
|
||||||
* // => 0
|
|
||||||
*
|
|
||||||
* // using the `_.matches` callback shorthand
|
|
||||||
* _.findIndex(users, { 'user': 'fred', 'active': false });
|
|
||||||
* // => 1
|
|
||||||
*
|
|
||||||
* // using the `_.matchesProperty` callback shorthand
|
|
||||||
* _.findIndex(users, 'active', false);
|
|
||||||
* // => 0
|
|
||||||
*
|
|
||||||
* // using the `_.property` callback shorthand
|
|
||||||
* _.findIndex(users, 'active');
|
|
||||||
* // => 2
|
|
||||||
*/
|
|
||||||
var findIndex = createFindIndex();
|
|
||||||
|
|
||||||
module.exports = findIndex;
|
|
||||||
-53
@@ -1,53 +0,0 @@
|
|||||||
var createFindIndex = require('../internal/createFindIndex');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is like `_.findIndex` except that it iterates over elements
|
|
||||||
* of `collection` from right to left.
|
|
||||||
*
|
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
|
||||||
* style callback returns the property value of the given element.
|
|
||||||
*
|
|
||||||
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
||||||
* style callback returns `true` for elements that have a matching property
|
|
||||||
* value, else `false`.
|
|
||||||
*
|
|
||||||
* If an object is provided for `predicate` the created `_.matches` style
|
|
||||||
* callback returns `true` for elements that have the properties of the given
|
|
||||||
* object, else `false`.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to search.
|
|
||||||
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
||||||
* per iteration.
|
|
||||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
||||||
* @returns {number} Returns the index of the found element, else `-1`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* var users = [
|
|
||||||
* { 'user': 'barney', 'active': true },
|
|
||||||
* { 'user': 'fred', 'active': false },
|
|
||||||
* { 'user': 'pebbles', 'active': false }
|
|
||||||
* ];
|
|
||||||
*
|
|
||||||
* _.findLastIndex(users, function(chr) {
|
|
||||||
* return chr.user == 'pebbles';
|
|
||||||
* });
|
|
||||||
* // => 2
|
|
||||||
*
|
|
||||||
* // using the `_.matches` callback shorthand
|
|
||||||
* _.findLastIndex(users, { 'user': 'barney', 'active': true });
|
|
||||||
* // => 0
|
|
||||||
*
|
|
||||||
* // using the `_.matchesProperty` callback shorthand
|
|
||||||
* _.findLastIndex(users, 'active', false);
|
|
||||||
* // => 2
|
|
||||||
*
|
|
||||||
* // using the `_.property` callback shorthand
|
|
||||||
* _.findLastIndex(users, 'active');
|
|
||||||
* // => 0
|
|
||||||
*/
|
|
||||||
var findLastIndex = createFindIndex(true);
|
|
||||||
|
|
||||||
module.exports = findLastIndex;
|
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
/**
|
|
||||||
* Gets the first element of `array`.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @alias head
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to query.
|
|
||||||
* @returns {*} Returns the first element of `array`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.first([1, 2, 3]);
|
|
||||||
* // => 1
|
|
||||||
*
|
|
||||||
* _.first([]);
|
|
||||||
* // => undefined
|
|
||||||
*/
|
|
||||||
function first(array) {
|
|
||||||
return array ? array[0] : undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = first;
|
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
var baseFlatten = require('../internal/baseFlatten'),
|
|
||||||
isIterateeCall = require('../internal/isIterateeCall');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flattens a nested array. If `isDeep` is `true` the array is recursively
|
|
||||||
* flattened, otherwise it's only flattened a single level.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to flatten.
|
|
||||||
* @param {boolean} [isDeep] Specify a deep flatten.
|
|
||||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
||||||
* @returns {Array} Returns the new flattened array.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.flatten([1, [2, 3, [4]]]);
|
|
||||||
* // => [1, 2, 3, [4]]
|
|
||||||
*
|
|
||||||
* // using `isDeep`
|
|
||||||
* _.flatten([1, [2, 3, [4]]], true);
|
|
||||||
* // => [1, 2, 3, 4]
|
|
||||||
*/
|
|
||||||
function flatten(array, isDeep, guard) {
|
|
||||||
var length = array ? array.length : 0;
|
|
||||||
if (guard && isIterateeCall(array, isDeep, guard)) {
|
|
||||||
isDeep = false;
|
|
||||||
}
|
|
||||||
return length ? baseFlatten(array, isDeep) : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = flatten;
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
var baseFlatten = require('../internal/baseFlatten');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursively flattens a nested array.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to recursively flatten.
|
|
||||||
* @returns {Array} Returns the new flattened array.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.flattenDeep([1, [2, 3, [4]]]);
|
|
||||||
* // => [1, 2, 3, 4]
|
|
||||||
*/
|
|
||||||
function flattenDeep(array) {
|
|
||||||
var length = array ? array.length : 0;
|
|
||||||
return length ? baseFlatten(array, true) : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = flattenDeep;
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
module.exports = require('./first');
|
|
||||||
-53
@@ -1,53 +0,0 @@
|
|||||||
var baseIndexOf = require('../internal/baseIndexOf'),
|
|
||||||
binaryIndex = require('../internal/binaryIndex');
|
|
||||||
|
|
||||||
/* Native method references for those with the same name as other `lodash` methods. */
|
|
||||||
var nativeMax = Math.max;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the index at which the first occurrence of `value` is found in `array`
|
|
||||||
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
|
||||||
* for equality comparisons. If `fromIndex` is negative, it's used as the offset
|
|
||||||
* from the end of `array`. If `array` is sorted providing `true` for `fromIndex`
|
|
||||||
* performs a faster binary search.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to search.
|
|
||||||
* @param {*} value The value to search for.
|
|
||||||
* @param {boolean|number} [fromIndex=0] The index to search from or `true`
|
|
||||||
* to perform a binary search on a sorted array.
|
|
||||||
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.indexOf([1, 2, 1, 2], 2);
|
|
||||||
* // => 1
|
|
||||||
*
|
|
||||||
* // using `fromIndex`
|
|
||||||
* _.indexOf([1, 2, 1, 2], 2, 2);
|
|
||||||
* // => 3
|
|
||||||
*
|
|
||||||
* // performing a binary search
|
|
||||||
* _.indexOf([1, 1, 2, 2], 2, true);
|
|
||||||
* // => 2
|
|
||||||
*/
|
|
||||||
function indexOf(array, value, fromIndex) {
|
|
||||||
var length = array ? array.length : 0;
|
|
||||||
if (!length) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (typeof fromIndex == 'number') {
|
|
||||||
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
|
|
||||||
} else if (fromIndex) {
|
|
||||||
var index = binaryIndex(array, value);
|
|
||||||
if (index < length &&
|
|
||||||
(value === value ? (value === array[index]) : (array[index] !== array[index]))) {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return baseIndexOf(array, value, fromIndex || 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = indexOf;
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
var dropRight = require('./dropRight');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all but the last element of `array`.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to query.
|
|
||||||
* @returns {Array} Returns the slice of `array`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.initial([1, 2, 3]);
|
|
||||||
* // => [1, 2]
|
|
||||||
*/
|
|
||||||
function initial(array) {
|
|
||||||
return dropRight(array, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = initial;
|
|
||||||
-58
@@ -1,58 +0,0 @@
|
|||||||
var baseIndexOf = require('../internal/baseIndexOf'),
|
|
||||||
cacheIndexOf = require('../internal/cacheIndexOf'),
|
|
||||||
createCache = require('../internal/createCache'),
|
|
||||||
isArrayLike = require('../internal/isArrayLike'),
|
|
||||||
restParam = require('../function/restParam');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an array of unique values that are included in all of the provided
|
|
||||||
* arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
|
||||||
* for equality comparisons.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {...Array} [arrays] The arrays to inspect.
|
|
||||||
* @returns {Array} Returns the new array of shared values.
|
|
||||||
* @example
|
|
||||||
* _.intersection([1, 2], [4, 2], [2, 1]);
|
|
||||||
* // => [2]
|
|
||||||
*/
|
|
||||||
var intersection = restParam(function(arrays) {
|
|
||||||
var othLength = arrays.length,
|
|
||||||
othIndex = othLength,
|
|
||||||
caches = Array(length),
|
|
||||||
indexOf = baseIndexOf,
|
|
||||||
isCommon = true,
|
|
||||||
result = [];
|
|
||||||
|
|
||||||
while (othIndex--) {
|
|
||||||
var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : [];
|
|
||||||
caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : null;
|
|
||||||
}
|
|
||||||
var array = arrays[0],
|
|
||||||
index = -1,
|
|
||||||
length = array ? array.length : 0,
|
|
||||||
seen = caches[0];
|
|
||||||
|
|
||||||
outer:
|
|
||||||
while (++index < length) {
|
|
||||||
value = array[index];
|
|
||||||
if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) {
|
|
||||||
var othIndex = othLength;
|
|
||||||
while (--othIndex) {
|
|
||||||
var cache = caches[othIndex];
|
|
||||||
if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) {
|
|
||||||
continue outer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (seen) {
|
|
||||||
seen.push(value);
|
|
||||||
}
|
|
||||||
result.push(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = intersection;
|
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
/**
|
|
||||||
* Gets the last element of `array`.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to query.
|
|
||||||
* @returns {*} Returns the last element of `array`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.last([1, 2, 3]);
|
|
||||||
* // => 3
|
|
||||||
*/
|
|
||||||
function last(array) {
|
|
||||||
var length = array ? array.length : 0;
|
|
||||||
return length ? array[length - 1] : undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = last;
|
|
||||||
-60
@@ -1,60 +0,0 @@
|
|||||||
var binaryIndex = require('../internal/binaryIndex'),
|
|
||||||
indexOfNaN = require('../internal/indexOfNaN');
|
|
||||||
|
|
||||||
/* Native method references for those with the same name as other `lodash` methods. */
|
|
||||||
var nativeMax = Math.max,
|
|
||||||
nativeMin = Math.min;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is like `_.indexOf` except that it iterates over elements of
|
|
||||||
* `array` from right to left.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to search.
|
|
||||||
* @param {*} value The value to search for.
|
|
||||||
* @param {boolean|number} [fromIndex=array.length-1] The index to search from
|
|
||||||
* or `true` to perform a binary search on a sorted array.
|
|
||||||
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.lastIndexOf([1, 2, 1, 2], 2);
|
|
||||||
* // => 3
|
|
||||||
*
|
|
||||||
* // using `fromIndex`
|
|
||||||
* _.lastIndexOf([1, 2, 1, 2], 2, 2);
|
|
||||||
* // => 1
|
|
||||||
*
|
|
||||||
* // performing a binary search
|
|
||||||
* _.lastIndexOf([1, 1, 2, 2], 2, true);
|
|
||||||
* // => 3
|
|
||||||
*/
|
|
||||||
function lastIndexOf(array, value, fromIndex) {
|
|
||||||
var length = array ? array.length : 0;
|
|
||||||
if (!length) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
var index = length;
|
|
||||||
if (typeof fromIndex == 'number') {
|
|
||||||
index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1;
|
|
||||||
} else if (fromIndex) {
|
|
||||||
index = binaryIndex(array, value, true) - 1;
|
|
||||||
var other = array[index];
|
|
||||||
if (value === value ? (value === other) : (other !== other)) {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (value !== value) {
|
|
||||||
return indexOfNaN(array, index, true);
|
|
||||||
}
|
|
||||||
while (index--) {
|
|
||||||
if (array[index] === value) {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = lastIndexOf;
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
module.exports = require('./zipObject');
|
|
||||||
-52
@@ -1,52 +0,0 @@
|
|||||||
var baseIndexOf = require('../internal/baseIndexOf');
|
|
||||||
|
|
||||||
/** Used for native method references. */
|
|
||||||
var arrayProto = Array.prototype;
|
|
||||||
|
|
||||||
/** Native method references. */
|
|
||||||
var splice = arrayProto.splice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all provided values from `array` using
|
|
||||||
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
|
||||||
* for equality comparisons.
|
|
||||||
*
|
|
||||||
* **Note:** Unlike `_.without`, this method mutates `array`.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to modify.
|
|
||||||
* @param {...*} [values] The values to remove.
|
|
||||||
* @returns {Array} Returns `array`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* var array = [1, 2, 3, 1, 2, 3];
|
|
||||||
*
|
|
||||||
* _.pull(array, 2, 3);
|
|
||||||
* console.log(array);
|
|
||||||
* // => [1, 1]
|
|
||||||
*/
|
|
||||||
function pull() {
|
|
||||||
var args = arguments,
|
|
||||||
array = args[0];
|
|
||||||
|
|
||||||
if (!(array && array.length)) {
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
var index = 0,
|
|
||||||
indexOf = baseIndexOf,
|
|
||||||
length = args.length;
|
|
||||||
|
|
||||||
while (++index < length) {
|
|
||||||
var fromIndex = 0,
|
|
||||||
value = args[index];
|
|
||||||
|
|
||||||
while ((fromIndex = indexOf(array, value, fromIndex)) > -1) {
|
|
||||||
splice.call(array, fromIndex, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = pull;
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
var baseAt = require('../internal/baseAt'),
|
|
||||||
baseCompareAscending = require('../internal/baseCompareAscending'),
|
|
||||||
baseFlatten = require('../internal/baseFlatten'),
|
|
||||||
basePullAt = require('../internal/basePullAt'),
|
|
||||||
restParam = require('../function/restParam');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes elements from `array` corresponding to the given indexes and returns
|
|
||||||
* an array of the removed elements. Indexes may be specified as an array of
|
|
||||||
* indexes or as individual arguments.
|
|
||||||
*
|
|
||||||
* **Note:** Unlike `_.at`, this method mutates `array`.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to modify.
|
|
||||||
* @param {...(number|number[])} [indexes] The indexes of elements to remove,
|
|
||||||
* specified as individual indexes or arrays of indexes.
|
|
||||||
* @returns {Array} Returns the new array of removed elements.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* var array = [5, 10, 15, 20];
|
|
||||||
* var evens = _.pullAt(array, 1, 3);
|
|
||||||
*
|
|
||||||
* console.log(array);
|
|
||||||
* // => [5, 15]
|
|
||||||
*
|
|
||||||
* console.log(evens);
|
|
||||||
* // => [10, 20]
|
|
||||||
*/
|
|
||||||
var pullAt = restParam(function(array, indexes) {
|
|
||||||
indexes = baseFlatten(indexes);
|
|
||||||
|
|
||||||
var result = baseAt(array, indexes);
|
|
||||||
basePullAt(array, indexes.sort(baseCompareAscending));
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = pullAt;
|
|
||||||
-64
@@ -1,64 +0,0 @@
|
|||||||
var baseCallback = require('../internal/baseCallback'),
|
|
||||||
basePullAt = require('../internal/basePullAt');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all elements from `array` that `predicate` returns truthy for
|
|
||||||
* and returns an array of the removed elements. The predicate is bound to
|
|
||||||
* `thisArg` and invoked with three arguments: (value, index, array).
|
|
||||||
*
|
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
|
||||||
* style callback returns the property value of the given element.
|
|
||||||
*
|
|
||||||
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
||||||
* style callback returns `true` for elements that have a matching property
|
|
||||||
* value, else `false`.
|
|
||||||
*
|
|
||||||
* If an object is provided for `predicate` the created `_.matches` style
|
|
||||||
* callback returns `true` for elements that have the properties of the given
|
|
||||||
* object, else `false`.
|
|
||||||
*
|
|
||||||
* **Note:** Unlike `_.filter`, this method mutates `array`.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to modify.
|
|
||||||
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
||||||
* per iteration.
|
|
||||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
||||||
* @returns {Array} Returns the new array of removed elements.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* var array = [1, 2, 3, 4];
|
|
||||||
* var evens = _.remove(array, function(n) {
|
|
||||||
* return n % 2 == 0;
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* console.log(array);
|
|
||||||
* // => [1, 3]
|
|
||||||
*
|
|
||||||
* console.log(evens);
|
|
||||||
* // => [2, 4]
|
|
||||||
*/
|
|
||||||
function remove(array, predicate, thisArg) {
|
|
||||||
var result = [];
|
|
||||||
if (!(array && array.length)) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
var index = -1,
|
|
||||||
indexes = [],
|
|
||||||
length = array.length;
|
|
||||||
|
|
||||||
predicate = baseCallback(predicate, thisArg, 3);
|
|
||||||
while (++index < length) {
|
|
||||||
var value = array[index];
|
|
||||||
if (predicate(value, index, array)) {
|
|
||||||
result.push(value);
|
|
||||||
indexes.push(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
basePullAt(array, indexes);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = remove;
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
var drop = require('./drop');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all but the first element of `array`.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @alias tail
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to query.
|
|
||||||
* @returns {Array} Returns the slice of `array`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.rest([1, 2, 3]);
|
|
||||||
* // => [2, 3]
|
|
||||||
*/
|
|
||||||
function rest(array) {
|
|
||||||
return drop(array, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = rest;
|
|
||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
var baseSlice = require('../internal/baseSlice'),
|
|
||||||
isIterateeCall = require('../internal/isIterateeCall');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a slice of `array` from `start` up to, but not including, `end`.
|
|
||||||
*
|
|
||||||
* **Note:** This method is used instead of `Array#slice` to support node
|
|
||||||
* lists in IE < 9 and to ensure dense arrays are returned.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to slice.
|
|
||||||
* @param {number} [start=0] The start position.
|
|
||||||
* @param {number} [end=array.length] The end position.
|
|
||||||
* @returns {Array} Returns the slice of `array`.
|
|
||||||
*/
|
|
||||||
function slice(array, start, end) {
|
|
||||||
var length = array ? array.length : 0;
|
|
||||||
if (!length) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
|
|
||||||
start = 0;
|
|
||||||
end = length;
|
|
||||||
}
|
|
||||||
return baseSlice(array, start, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = slice;
|
|
||||||
-53
@@ -1,53 +0,0 @@
|
|||||||
var createSortedIndex = require('../internal/createSortedIndex');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uses a binary search to determine the lowest index at which `value` should
|
|
||||||
* be inserted into `array` in order to maintain its sort order. If an iteratee
|
|
||||||
* function is provided it's invoked for `value` and each element of `array`
|
|
||||||
* to compute their sort ranking. The iteratee is bound to `thisArg` and
|
|
||||||
* invoked with one argument; (value).
|
|
||||||
*
|
|
||||||
* If a property name is provided for `iteratee` the created `_.property`
|
|
||||||
* style callback returns the property value of the given element.
|
|
||||||
*
|
|
||||||
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
||||||
* style callback returns `true` for elements that have a matching property
|
|
||||||
* value, else `false`.
|
|
||||||
*
|
|
||||||
* If an object is provided for `iteratee` the created `_.matches` style
|
|
||||||
* callback returns `true` for elements that have the properties of the given
|
|
||||||
* object, else `false`.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The sorted array to inspect.
|
|
||||||
* @param {*} value The value to evaluate.
|
|
||||||
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
|
|
||||||
* per iteration.
|
|
||||||
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
||||||
* @returns {number} Returns the index at which `value` should be inserted
|
|
||||||
* into `array`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.sortedIndex([30, 50], 40);
|
|
||||||
* // => 1
|
|
||||||
*
|
|
||||||
* _.sortedIndex([4, 4, 5, 5], 5);
|
|
||||||
* // => 2
|
|
||||||
*
|
|
||||||
* var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } };
|
|
||||||
*
|
|
||||||
* // using an iteratee function
|
|
||||||
* _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) {
|
|
||||||
* return this.data[word];
|
|
||||||
* }, dict);
|
|
||||||
* // => 1
|
|
||||||
*
|
|
||||||
* // using the `_.property` callback shorthand
|
|
||||||
* _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
|
|
||||||
* // => 1
|
|
||||||
*/
|
|
||||||
var sortedIndex = createSortedIndex();
|
|
||||||
|
|
||||||
module.exports = sortedIndex;
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
var createSortedIndex = require('../internal/createSortedIndex');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is like `_.sortedIndex` except that it returns the highest
|
|
||||||
* index at which `value` should be inserted into `array` in order to
|
|
||||||
* maintain its sort order.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The sorted array to inspect.
|
|
||||||
* @param {*} value The value to evaluate.
|
|
||||||
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
|
|
||||||
* per iteration.
|
|
||||||
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
||||||
* @returns {number} Returns the index at which `value` should be inserted
|
|
||||||
* into `array`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.sortedLastIndex([4, 4, 5, 5], 5);
|
|
||||||
* // => 4
|
|
||||||
*/
|
|
||||||
var sortedLastIndex = createSortedIndex(true);
|
|
||||||
|
|
||||||
module.exports = sortedLastIndex;
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
module.exports = require('./rest');
|
|
||||||
-39
@@ -1,39 +0,0 @@
|
|||||||
var baseSlice = require('../internal/baseSlice'),
|
|
||||||
isIterateeCall = require('../internal/isIterateeCall');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a slice of `array` with `n` elements taken from the beginning.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to query.
|
|
||||||
* @param {number} [n=1] The number of elements to take.
|
|
||||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
||||||
* @returns {Array} Returns the slice of `array`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.take([1, 2, 3]);
|
|
||||||
* // => [1]
|
|
||||||
*
|
|
||||||
* _.take([1, 2, 3], 2);
|
|
||||||
* // => [1, 2]
|
|
||||||
*
|
|
||||||
* _.take([1, 2, 3], 5);
|
|
||||||
* // => [1, 2, 3]
|
|
||||||
*
|
|
||||||
* _.take([1, 2, 3], 0);
|
|
||||||
* // => []
|
|
||||||
*/
|
|
||||||
function take(array, n, guard) {
|
|
||||||
var length = array ? array.length : 0;
|
|
||||||
if (!length) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
if (guard ? isIterateeCall(array, n, guard) : n == null) {
|
|
||||||
n = 1;
|
|
||||||
}
|
|
||||||
return baseSlice(array, 0, n < 0 ? 0 : n);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = take;
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
var baseSlice = require('../internal/baseSlice'),
|
|
||||||
isIterateeCall = require('../internal/isIterateeCall');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a slice of `array` with `n` elements taken from the end.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to query.
|
|
||||||
* @param {number} [n=1] The number of elements to take.
|
|
||||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
||||||
* @returns {Array} Returns the slice of `array`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.takeRight([1, 2, 3]);
|
|
||||||
* // => [3]
|
|
||||||
*
|
|
||||||
* _.takeRight([1, 2, 3], 2);
|
|
||||||
* // => [2, 3]
|
|
||||||
*
|
|
||||||
* _.takeRight([1, 2, 3], 5);
|
|
||||||
* // => [1, 2, 3]
|
|
||||||
*
|
|
||||||
* _.takeRight([1, 2, 3], 0);
|
|
||||||
* // => []
|
|
||||||
*/
|
|
||||||
function takeRight(array, n, guard) {
|
|
||||||
var length = array ? array.length : 0;
|
|
||||||
if (!length) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
if (guard ? isIterateeCall(array, n, guard) : n == null) {
|
|
||||||
n = 1;
|
|
||||||
}
|
|
||||||
n = length - (+n || 0);
|
|
||||||
return baseSlice(array, n < 0 ? 0 : n);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = takeRight;
|
|
||||||
-59
@@ -1,59 +0,0 @@
|
|||||||
var baseCallback = require('../internal/baseCallback'),
|
|
||||||
baseWhile = require('../internal/baseWhile');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a slice of `array` with elements taken from the end. Elements are
|
|
||||||
* taken until `predicate` returns falsey. The predicate is bound to `thisArg`
|
|
||||||
* and invoked with three arguments: (value, index, array).
|
|
||||||
*
|
|
||||||
* If a property name is provided for `predicate` the created `_.property`
|
|
||||||
* style callback returns the property value of the given element.
|
|
||||||
*
|
|
||||||
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
||||||
* style callback returns `true` for elements that have a matching property
|
|
||||||
* value, else `false`.
|
|
||||||
*
|
|
||||||
* If an object is provided for `predicate` the created `_.matches` style
|
|
||||||
* callback returns `true` for elements that have the properties of the given
|
|
||||||
* object, else `false`.
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @memberOf _
|
|
||||||
* @category Array
|
|
||||||
* @param {Array} array The array to query.
|
|
||||||
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
||||||
* per iteration.
|
|
||||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
||||||
* @returns {Array} Returns the slice of `array`.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* _.takeRightWhile([1, 2, 3], function(n) {
|
|
||||||
* return n > 1;
|
|
||||||
* });
|
|
||||||
* // => [2, 3]
|
|
||||||
*
|
|
||||||
* var users = [
|
|
||||||
* { 'user': 'barney', 'active': true },
|
|
||||||
* { 'user': 'fred', 'active': false },
|
|
||||||
* { 'user': 'pebbles', 'active': false }
|
|
||||||
* ];
|
|
||||||
*
|
|
||||||
* // using the `_.matches` callback shorthand
|
|
||||||
* _.pluck(_.takeRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user');
|
|
||||||
* // => ['pebbles']
|
|
||||||
*
|
|
||||||
* // using the `_.matchesProperty` callback shorthand
|
|
||||||
* _.pluck(_.takeRightWhile(users, 'active', false), 'user');
|
|
||||||
* // => ['fred', 'pebbles']
|
|
||||||
*
|
|
||||||
* // using the `_.property` callback shorthand
|
|
||||||
* _.pluck(_.takeRightWhile(users, 'active'), 'user');
|
|
||||||
* // => []
|
|
||||||
*/
|
|
||||||
function takeRightWhile(array, predicate, thisArg) {
|
|
||||||
return (array && array.length)
|
|
||||||
? baseWhile(array, baseCallback(predicate, thisArg, 3), false, true)
|
|
||||||
: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = takeRightWhile;
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user