mirror of
https://github.com/ajurna/cbwebreader.git
synced 2025-12-06 14:17:19 +00:00
added pdf.js to add pdf support.
This commit is contained in:
2
Pipfile
2
Pipfile
@@ -11,6 +11,8 @@ gunicorn = "*"
|
|||||||
django-recaptcha2 = "*"
|
django-recaptcha2 = "*"
|
||||||
django-bootstrap4 = "*"
|
django-bootstrap4 = "*"
|
||||||
dj-database-url = "*"
|
dj-database-url = "*"
|
||||||
|
pypdf2 = "*"
|
||||||
|
pypdf4 = "*"
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
python_version = "3.8"
|
python_version = "3.8"
|
||||||
|
|||||||
30
Pipfile.lock
generated
30
Pipfile.lock
generated
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "22569e29b4f8bd5fc837707e1c74a7425fadcc26ea7d25bdf000972446ea2f5e"
|
"sha256": "548d0f8003c2238f35176fd522fcca7d6108c2c9146f6cb0320660e6bb0212cc"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
@@ -25,11 +25,11 @@
|
|||||||
},
|
},
|
||||||
"beautifulsoup4": {
|
"beautifulsoup4": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:594ca51a10d2b3443cbac41214e12dbb2a1cd57e1a7344659849e2e20ba6a8d8",
|
"sha256:73cc4d115b96f79c7d77c1c7f7a0a8d4c57860d1041df407dd1aae7f07a77fd7",
|
||||||
"sha256:a4bbe77fd30670455c5296242967a123ec28c37e9702a8a81bd2f20a4baf0368",
|
"sha256:a6237df3c32ccfaee4fd201c8f5f9d9df619b93121d01353a64a73ce8c6ef9a8",
|
||||||
"sha256:d4e96ac9b0c3a6d3f0caae2e4124e6055c5dcafde8e2f831ff194c104f0775a0"
|
"sha256:e718f2342e2e099b640a34ab782407b7b676f47ee272d6739e60b8ea23829f2c"
|
||||||
],
|
],
|
||||||
"version": "==4.9.0"
|
"version": "==4.9.1"
|
||||||
},
|
},
|
||||||
"certifi": {
|
"certifi": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
@@ -92,6 +92,20 @@
|
|||||||
],
|
],
|
||||||
"version": "==2.9"
|
"version": "==2.9"
|
||||||
},
|
},
|
||||||
|
"pypdf2": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:e28f902f2f0a1603ea95ebe21dff311ef09be3d0f0ef29a3e44a932729564385"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==1.26.0"
|
||||||
|
},
|
||||||
|
"pypdf4": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:7c932441146d205572f96254d53c79ea2c30c9e11df55a5cf87e056c7b3d7f89"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==1.27.0"
|
||||||
|
},
|
||||||
"pytz": {
|
"pytz": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:a494d53b6d39c3c6e44c3bec237336e14305e4f29bbf800b599253057fbb79ed",
|
"sha256:a494d53b6d39c3c6e44c3bec237336e14305e4f29bbf800b599253057fbb79ed",
|
||||||
@@ -108,10 +122,10 @@
|
|||||||
},
|
},
|
||||||
"soupsieve": {
|
"soupsieve": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:e914534802d7ffd233242b785229d5ba0766a7f487385e3f714446a07bf540ae",
|
"sha256:1634eea42ab371d3d346309b93df7870a88610f0725d47528be902a0d95ecc55",
|
||||||
"sha256:fcd71e08c0aee99aca1b73f45478549ee7e7fc006d51b37bec9e9def7dc22b69"
|
"sha256:a59dc181727e95d25f781f0eb4fd1825ff45590ec8ff49eadfd7f1a537cc0232"
|
||||||
],
|
],
|
||||||
"version": "==2.0"
|
"version": "==2.0.1"
|
||||||
},
|
},
|
||||||
"sqlparse": {
|
"sqlparse": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from django.contrib.auth.models import User
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.transaction import atomic
|
from django.db.transaction import atomic
|
||||||
from django.utils.http import urlsafe_base64_encode
|
from django.utils.http import urlsafe_base64_encode
|
||||||
|
from PyPDF4 import PdfFileReader
|
||||||
|
|
||||||
from comic import rarfile
|
from comic import rarfile
|
||||||
|
|
||||||
@@ -82,6 +83,10 @@ class ComicBook(models.Model):
|
|||||||
def selector_string(self):
|
def selector_string(self):
|
||||||
return urlsafe_base64_encode(self.selector.bytes)
|
return urlsafe_base64_encode(self.selector.bytes)
|
||||||
|
|
||||||
|
def get_pdf(self):
|
||||||
|
base_dir = Setting.objects.get(name="BASE_DIR").value
|
||||||
|
return path.join(base_dir, self.directory.get_path(), self.file_name)
|
||||||
|
|
||||||
def get_image(self, page):
|
def get_image(self, page):
|
||||||
base_dir = Setting.objects.get(name="BASE_DIR").value
|
base_dir = Setting.objects.get(name="BASE_DIR").value
|
||||||
if self.directory:
|
if self.directory:
|
||||||
@@ -257,7 +262,14 @@ class ComicBook(models.Model):
|
|||||||
try:
|
try:
|
||||||
cbx = zipfile.ZipFile(comic_full_path)
|
cbx = zipfile.ZipFile(comic_full_path)
|
||||||
except zipfile.BadZipFile:
|
except zipfile.BadZipFile:
|
||||||
|
cbx = None
|
||||||
|
if not cbx:
|
||||||
|
pdf_file = PdfFileReader(comic_full_path)
|
||||||
|
else:
|
||||||
|
pdf_file = None
|
||||||
|
if not pdf_file and not cbx:
|
||||||
return comic_file_name
|
return comic_file_name
|
||||||
|
|
||||||
with atomic():
|
with atomic():
|
||||||
if directory:
|
if directory:
|
||||||
book = ComicBook(file_name=comic_file_name, directory=directory)
|
book = ComicBook(file_name=comic_file_name, directory=directory)
|
||||||
@@ -265,6 +277,7 @@ class ComicBook(models.Model):
|
|||||||
book = ComicBook(file_name=comic_file_name)
|
book = ComicBook(file_name=comic_file_name)
|
||||||
book.save()
|
book.save()
|
||||||
page_index = 0
|
page_index = 0
|
||||||
|
if cbx:
|
||||||
for page_file_name in sorted([str(x) for x in cbx.namelist()], key=str.lower):
|
for page_file_name in sorted([str(x) for x in cbx.namelist()], key=str.lower):
|
||||||
try:
|
try:
|
||||||
dot_index = page_file_name.rindex(".") + 1
|
dot_index = page_file_name.rindex(".") + 1
|
||||||
@@ -286,6 +299,12 @@ class ComicBook(models.Model):
|
|||||||
)
|
)
|
||||||
page.save()
|
page.save()
|
||||||
page_index += 1
|
page_index += 1
|
||||||
|
elif pdf_file:
|
||||||
|
for page_index in range(pdf_file.getNumPages()):
|
||||||
|
page = ComicPage(
|
||||||
|
Comic=book, index=page_index, page_file_name=page_index+1, content_type='application/pdf'
|
||||||
|
)
|
||||||
|
page.save()
|
||||||
return book
|
return book
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
173
comic/templates/comic/read_comic_pdf.html
Normal file
173
comic/templates/comic/read_comic_pdf.html
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% load static %}
|
||||||
|
{% block title %}{{ title }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="container m-0">
|
||||||
|
<div class="row justify-content-center w-100">
|
||||||
|
<div class="btn-group" role="group" aria-label="Basic example">
|
||||||
|
|
||||||
|
<button id="prev" class="btn btn-secondary">Previous</button>
|
||||||
|
<button id="pages" class="btn btn-secondary"><span id="page_num"></span> / <span id="page_count"></button>
|
||||||
|
|
||||||
|
<button id="next" class="btn btn-secondary">Next</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row w-100">
|
||||||
|
<canvas id="the-canvas" width="100%"></canvas>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block script %}
|
||||||
|
<script type="text/javascript" src="{% static "pdfjs/build/pdf.js" %}"></script>
|
||||||
|
<script>
|
||||||
|
// If absolute URL from the remote server is provided, configure the CORS
|
||||||
|
// header on that server.
|
||||||
|
var url = '{% url "get_pdf" nav.cur_path %}';
|
||||||
|
|
||||||
|
// Loaded via <script> tag, create shortcut to access PDF.js exports.
|
||||||
|
var pdfjsLib = window['pdfjs-dist/build/pdf'];
|
||||||
|
|
||||||
|
|
||||||
|
// The workerSrc property shall be specified.
|
||||||
|
pdfjsLib.GlobalWorkerOptions.workerSrc = '{% static "pdfjs/build/pdf.worker.js" %}';
|
||||||
|
|
||||||
|
var pdfDoc = null,
|
||||||
|
pageNum = {{ status.last_read_page }},
|
||||||
|
pageRendering = false,
|
||||||
|
pageNumPending = null,
|
||||||
|
scale = 0.8,
|
||||||
|
canvas = document.getElementById('the-canvas'),
|
||||||
|
ctx = canvas.getContext('2d');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get page info from document, resize canvas accordingly, and render page.
|
||||||
|
* @param num Page number.
|
||||||
|
*/
|
||||||
|
function renderPage(num) {
|
||||||
|
pageRendering = true;
|
||||||
|
// Using promise to fetch the page
|
||||||
|
pdfDoc.getPage(num).then(function(page) {
|
||||||
|
let viewport = page.getViewport({scale: (window.innerWidth *.95) / page.getViewport(1.0).width});
|
||||||
|
canvas.height = viewport.height;
|
||||||
|
canvas.width = viewport.width;
|
||||||
|
|
||||||
|
document.getElementById('the-canvas').scrollIntoView({behavior: 'smooth'})
|
||||||
|
$.ajax({url: "/comic/set_page/{{nav.cur_path}}/" + (pageNum - 1) + "/"})
|
||||||
|
|
||||||
|
// Render PDF page into canvas context
|
||||||
|
let renderContext = {
|
||||||
|
canvasContext: ctx,
|
||||||
|
viewport: viewport
|
||||||
|
};
|
||||||
|
let renderTask = page.render(renderContext);
|
||||||
|
|
||||||
|
// Wait for rendering to finish
|
||||||
|
renderTask.promise.then(function() {
|
||||||
|
pageRendering = false;
|
||||||
|
if (pageNumPending !== null) {
|
||||||
|
// New page rendering is pending
|
||||||
|
renderPage(pageNumPending);
|
||||||
|
pageNumPending = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update page counters
|
||||||
|
document.getElementById('page_num').textContent = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If another page rendering in progress, waits until the rendering is
|
||||||
|
* finised. Otherwise, executes rendering immediately.
|
||||||
|
*/
|
||||||
|
function queueRenderPage(num) {
|
||||||
|
if (pageRendering) {
|
||||||
|
pageNumPending = num;
|
||||||
|
} else {
|
||||||
|
renderPage(num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays previous page.
|
||||||
|
*/
|
||||||
|
function onPrevPage() {
|
||||||
|
if (pageNum <= 1) {
|
||||||
|
window.location = "{% url "read_comic" nav.prev_path %}"
|
||||||
|
}
|
||||||
|
pageNum--;
|
||||||
|
queueRenderPage(pageNum);
|
||||||
|
}
|
||||||
|
document.getElementById('prev').addEventListener('click', onPrevPage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays next page.
|
||||||
|
*/
|
||||||
|
function onNextPage() {
|
||||||
|
if (pageNum >= pdfDoc.numPages) {
|
||||||
|
window.location = "{% url "read_comic" nav.next_path %}"
|
||||||
|
}
|
||||||
|
pageNum++;
|
||||||
|
queueRenderPage(pageNum);
|
||||||
|
}
|
||||||
|
document.getElementById('next').addEventListener('click', onNextPage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asynchronously downloads PDF.
|
||||||
|
*/
|
||||||
|
pdfjsLib.getDocument(url).promise.then(function(pdfDoc_) {
|
||||||
|
pdfDoc = pdfDoc_;
|
||||||
|
document.getElementById('page_count').textContent = pdfDoc.numPages;
|
||||||
|
|
||||||
|
// Initial/first page rendering
|
||||||
|
renderPage(pageNum);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).keydown(function(e) { // add arrow key support
|
||||||
|
switch(e.which) {
|
||||||
|
case 37: // left
|
||||||
|
onPrevPage()
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 38: // up
|
||||||
|
window.scrollTo({
|
||||||
|
top: window.scrollY-window.innerHeight*.7,
|
||||||
|
left: 0,
|
||||||
|
behavior: 'smooth'
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 39: // right
|
||||||
|
onNextPage()
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 40: // down
|
||||||
|
window.scrollTo({
|
||||||
|
top: window.scrollY+window.innerHeight*.7,
|
||||||
|
left: 0,
|
||||||
|
behavior: 'smooth'
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: return; // exit this handler for other keys
|
||||||
|
}
|
||||||
|
e.preventDefault(); // prevent the default action (scroll / move caret)
|
||||||
|
});
|
||||||
|
|
||||||
|
var hammertime = new Hammer(document.getElementById('the-canvas'), {});
|
||||||
|
hammertime.on('swipeleft', function (ev) {
|
||||||
|
onNextPage()
|
||||||
|
})
|
||||||
|
hammertime.on('swiperight', function (ev) {
|
||||||
|
onPrevPage()
|
||||||
|
})
|
||||||
|
hammertime.on('tap', function (ev) {
|
||||||
|
onNextPage()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
@@ -13,6 +13,7 @@ urlpatterns = [
|
|||||||
url(r"^read/(?P<comic_selector>[\w-]+)/$", views.read_comic, name="read_comic"),
|
url(r"^read/(?P<comic_selector>[\w-]+)/$", views.read_comic, name="read_comic"),
|
||||||
url(r"^set_page/(?P<comic_selector>[\w-]+)/(?P<page>[0-9]+)/$", views.set_read_page, name="set_read_page"),
|
url(r"^set_page/(?P<comic_selector>[\w-]+)/(?P<page>[0-9]+)/$", views.set_read_page, name="set_read_page"),
|
||||||
url(r"^read/(?P<comic_selector>[\w-]+)/(?P<page>[0-9]+)/img$", views.get_image, name="get_image"),
|
url(r"^read/(?P<comic_selector>[\w-]+)/(?P<page>[0-9]+)/img$", views.get_image, name="get_image"),
|
||||||
|
url(r"^read/(?P<comic_selector>[\w-]+)/pdf$", views.get_pdf, name="get_pdf"),
|
||||||
url(r"^list_json/$", views.comic_list_json, name="comic_list_json1"),
|
url(r"^list_json/$", views.comic_list_json, name="comic_list_json1"),
|
||||||
url(r"^list_json/(?P<directory_selector>[\w-]+)/$", views.comic_list_json, name="comic_list_json2"),
|
url(r"^list_json/(?P<directory_selector>[\w-]+)/$", views.comic_list_json, name="comic_list_json2"),
|
||||||
url(r"^recent/$", views.recent_comics, name="recent_comics"),
|
url(r"^recent/$", views.recent_comics, name="recent_comics"),
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ def generate_directory(user, directory=False):
|
|||||||
df.populate_directory(directory_obj, user)
|
df.populate_directory(directory_obj, user)
|
||||||
files.append(df)
|
files.append(df)
|
||||||
for file_name in file_list:
|
for file_name in file_list:
|
||||||
if file_name.lower()[-4:] in [".rar", ".zip", ".cbr", ".cbz"]:
|
if file_name.lower()[-4:] in [".rar", ".zip", ".cbr", ".cbz", ".pdf"]:
|
||||||
book = ComicBook.process_comic_book(file_name, directory)
|
book = ComicBook.process_comic_book(file_name, directory)
|
||||||
df = DirFile()
|
df = DirFile()
|
||||||
df.populate_comic(book, user)
|
df.populate_comic(book, user)
|
||||||
|
|||||||
@@ -293,6 +293,13 @@ def settings_page(request):
|
|||||||
@login_required
|
@login_required
|
||||||
def read_comic(request, comic_selector):
|
def read_comic(request, comic_selector):
|
||||||
selector = uuid.UUID(bytes=urlsafe_base64_decode(comic_selector))
|
selector = uuid.UUID(bytes=urlsafe_base64_decode(comic_selector))
|
||||||
|
try:
|
||||||
|
book = ComicBook.objects.get(selector=selector)
|
||||||
|
except ComicBook.DoesNotExist:
|
||||||
|
Directory.objects.get(selector=selector)
|
||||||
|
return redirect('comic_list', directory_selector=comic_selector)
|
||||||
|
except Directory.DoesNotExist:
|
||||||
|
return HttpResponse(status=404)
|
||||||
book = get_object_or_404(ComicBook, selector=selector)
|
book = get_object_or_404(ComicBook, selector=selector)
|
||||||
pages = ComicPage.objects.filter(Comic=book)
|
pages = ComicPage.objects.filter(Comic=book)
|
||||||
|
|
||||||
@@ -308,6 +315,10 @@ def read_comic(request, comic_selector):
|
|||||||
"menu": Menu(request.user),
|
"menu": Menu(request.user),
|
||||||
"title": title,
|
"title": title,
|
||||||
}
|
}
|
||||||
|
if book.file_name.lower().endswith('pdf'):
|
||||||
|
context['status'].last_read_page += 1
|
||||||
|
return render(request, "comic/read_comic_pdf.html", context)
|
||||||
|
else:
|
||||||
return render(request, "comic/read_comic.html", context)
|
return render(request, "comic/read_comic.html", context)
|
||||||
|
|
||||||
|
|
||||||
@@ -335,6 +346,13 @@ def get_image(_, comic_selector, page):
|
|||||||
return FileResponse(img, content_type=content)
|
return FileResponse(img, content_type=content)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def get_pdf(_, comic_selector):
|
||||||
|
selector = uuid.UUID(bytes=urlsafe_base64_decode(comic_selector))
|
||||||
|
book = ComicBook.objects.get(selector=selector)
|
||||||
|
return FileResponse(open(book.get_pdf(), 'rb'), content_type='application/pdf')
|
||||||
|
|
||||||
|
|
||||||
def initial_setup(request):
|
def initial_setup(request):
|
||||||
if User.objects.all().exists():
|
if User.objects.all().exists():
|
||||||
return redirect("/comic/")
|
return redirect("/comic/")
|
||||||
|
|||||||
@@ -2132,7 +2132,7 @@ inherit(TapRecognizer, Recognizer, {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple way to create a manager with a default set of recognizers.
|
* Simple way to create a manager with a default set of recognizers.
|
||||||
* @param {Document} element
|
* @param {HTMLElement} element
|
||||||
* @param {Object} [options]
|
* @param {Object} [options]
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
|||||||
177
static/pdfjs/LICENSE
Normal file
177
static/pdfjs/LICENSE
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
|
||||||
|
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
|
||||||
Reference in New Issue
Block a user