Permalink
Browse files

Change license to plain MIT license

  • Loading branch information...
Ben Hoyt
Ben Hoyt committed Aug 10, 2017
1 parent 0758d26 commit 595921b85b31002e1589ee58dddcce7da683e509
Showing with 114 additions and 108 deletions.
  1. +0 −9 CONTRIBUTING.md
  2. +19 −5 LICENSE.txt
  3. +57 −17 README.rst
  4. +28 −0 TODO.txt
  5. +7 −74 cdnupload.py
  6. BIN images/cdn.png
  7. +3 −3 setup.py
View
@@ -14,12 +14,3 @@ When opening an issue, please:
## Code
Feel free to submit a pull request, but it's usually best to open an issue first, so we can discuss the changes before putting a lot of time into the fix or feature.
## Legal
By submitting a pull request, you disavow any rights or claims to any changes submitted to the cdnupload project, and assign the copyright of those changes to me (Ben Hoyt).
If you can't or don't want to reassign those rights (for example, your employment contract doesn't allow it), you should not submit a pull request. Instead, open an issue and I or someone else can do the work.
This is a legal way of saying "If you submit a pull request to us, that code becomes ours". Generally that's what open source contributors intend anyway! This enables us to continue to offer cdnupload under multiple licenses (free for open source, commercial licenses for businesses).
View
@@ -1,7 +1,21 @@
MIT License
cdnupload is (c) Ben Hoyt 2017 and licensed under multiple licenses: it's
free for open source websites, and there are two well-priced commercial
licenses available for businesses. See the "Multi-licensing" section in
README.rst for details:
Copyright (c) 2017 Ben Hoyt
https://cdnupload.com/docs#multi-licensing
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.
View
@@ -11,26 +11,38 @@ Documentation
Introduction
============
`cdnupload <https://cdnupload.com/>`_ uploads your website’s static files to a CDN with a content-based hash in the filenames, giving great caching while avoiding versioning issues.
cdnupload uploads your website’s static files to a CDN with a content-based hash in the filenames, giving great caching while avoiding versioning issues.
.. container:: read-online
:name: read-online
* Fast and simple to integrate
* Helps you follow web best practices: `use a CDN <#why-should-i-use-a-cdn>`_, good Cache-Control headers, versioned filenames
* Works with web apps written in any language
* Written in Python (runs on Python 2 and 3)
Read this documentation online for best results: https://cdnupload.com/docs
The tool helps you follow performance best practices by including a content-based hash in each asset filename.
Deploying is really fast too: only files that have actually changed will be uploaded (with a new hash).
Multi-licensing
===============
cdnupload is **trivial to install**::
cdnupload is © Ben Hoyt 2017 and licensed under multiple licenses (`read why here <https://cdnupload.com/#licensing>`_). It’s free for open source websites, and there are two well-priced commercial licenses available for businesses. The three license options are:
$ pip install cdnupload
1. **Open:** if the code for your website is open source, you can use cdnupload for free under an AGPL license. `Read the full text of the AGPL v3 license. <https://www.gnu.org/licenses/agpl-3.0.en.html>`_
It's **simple to use**::
2. **Single website:** if your business has a single website, this commercial license tier is for you. `See pricing and more details about the single website tier. <https://cdnupload.com/single>`_
$ cdnupload /site/statics s3://statics-bucket --key-map=statics.json
uploading script.js to script_8f3283c6342816f7.js
uploading style.css to style_abcdef0123456789.css
writing key map JSON to statics.json
And it's **easy to integrate** in most languages, for example Python::
import json, settings
3. **Multi-website:** this license is a commercial license for using cdnupload on up to 10 websites. `See pricing and more details about the multi-website tier. <https://cdnupload.com/multi>`_
def init_server():
with open('statics.json') as f:
settings.statics = json.load(f)
If your company’s requirements don’t fit into any of the above, or you want to discuss a custom license, please contact us at `info@cdnupload.com <mailto:info@cdnupload.com>`_.
def static_url(path):
return '//mycdn.com/' + settings.statics[path]
Installation
@@ -56,7 +68,7 @@ Overview
cdnupload is primarily a **command-line tool** that uploads your site’s static files to a CDN (well, really the CDN’s origin server). It optionally generates a JSON “key mapping” that maps file paths to destination keys. A destination key is a file path with a hash in it based on the file’s contents. This allows you to set up the CDN to cache your static files aggresively, with an essentially infinite expiry time (max age).
(For a brief introduction to what a CDN is and why you might want to use one, `see the CDN section on the cdnupload homepage. <https://cdnupload.com/#cdn>`_)
(For a brief introduction to what a CDN is and why you might want to use one, `see the CDN section of this document. <#why-should-i-use-a-cdn>`_)
When you upload statics, you specify a source directory and a destination directory (or Amazon S3 URL or other origin pseudo-URL). For example, you can upload all the static files from the ``/website/static`` directory to ``static-bucket``, and output the key mapping to the file ``statics.json`` using the following command::
@@ -87,6 +99,30 @@ There are many `command-line options <#command-line-usage>`_ to control what fil
You’ll also need to **integrate with your web server** so that your web application knows the hash mapping and can output the correct static URLs. That can be as simple as a ``static_url`` template function that uses the key map JSON to convert from a file path to the destination key. See details in the `web server integration section below. <#web-server-integration>`_
Why should I use a CDN?
=======================
*If you’re not sure what a CDN is, or if you’re wondering why you should use one, this section is for you.*
.. image:: https://raw.githubusercontent.com/benhoyt/cdnupload/master/images/cdn.png
:alt: From Wikimedia under Creative Commons (NCDN_-_CDN.png)
:align: center
CDN stands for Content Delivery Network, which is a service that serves your static files -- heavily cached, on servers around the world that are close to your users.
So if someone from New Jersey requests ``https://mycdn.com/style.css``, the CDN will almost certainly have a cached version in an East Coast or even a local New Jersey data center, and will serve that up to the user faster than you can say “HTTP/2”.
If the CDN doesn’t have a cached version of the file, it will in turn request it from the origin server (where the files are hosted). If you’re using something like Amazon S3 as your origin server, that request will be quick too, and user will still get the file in good time. From then on, the CDN will serve the cached version.
Because the files are heavily cached (ideally with long expiry ties), you need to include version numbers in the filenames. cdnupload does this by appending to the filename a 16-character hash based on the file’s contents. For example, ``style.css`` might become ``style_abcdef0123456789.css``, and then ``style_a0b1c2d3e4f56789.css`` in the next revision.
On one `website <https://giftyweddings.com/>`_ we run, we saw our **static file load time drop from 1500&nbsp;ms to 220&nbsp;ms** when we starting using cdnupload with the Amazon Cloudfront CDN.
So you should use a CDN if your site gets a good amount of traffic, and you need good performance from various locations around the world. You probably *don’t* need to use a CDN if you have a small personal site.
Using the `Amazon CloudFront <https://aws.amazon.com/cloudfront/>`_ CDN together with `Amazon S3 <https://aws.amazon.com/s3/>`_ as an origin server is a great place to start -- like other AWS products, you only pay for the bytes you use, and there’s no montly fee.
Command-line usage
==================
@@ -368,19 +404,23 @@ For example, to log all errors but turn debug-level logging on only for cdnuploa
Contributing
============
Even though cdnupload is multi-licensed, the source code is open, and contributions are welcomed.
If you find a bug in cdnupload, please open an issue with the following information:
* Full error messages or tracebacks
* The cdnupload version, Python version, and operating system type and version
* Steps or a test case that reproduces the issue (ideally)
If you have a feature request or suggestion, open an issue and we’ll discuss!
If you have a feature request, documentation fix, or other suggestion, open an issue and we’ll discuss!
See also `CONTRIBUTING.md <https://github.com/benhoyt/cdnupload/blob/master/CONTRIBUTING.md>`_ in the cdnupload source tree.
License
=======
You’re welcome to submit a pull request as well, but it’s usually best to open an issue first, so we can discuss the changes before you put a lot of time into the fix or feature.
cdnupload is licensed under a permissive MIT license: see `CONTRIBUTING.md <https://github.com/benhoyt/cdnupload/blob/master/LICENSE.txt>`_ for details.
See `CONTRIBUTING.md <https://github.com/benhoyt/cdnupload/blob/master/CONTRIBUTING.md>`_ in the cdnupload source tree for some legal requirements and more information.
Note that prior to August 2017 it was licensed under an AGPL plus commercial license combination, but now it's completely free.
About the author
View
@@ -0,0 +1,28 @@
cdnupload works fine right now (I used it on a couple of my sites).
But here are some things I'd like to add eventually.
* tests: more unicode filename tests: src, dest, s3?
* tests: real S3 tests against a test bucket
* tests: main() tests
* remove include/exclude dirs in walk_files() more efficiently if they match?
* should we ignore permissions errors on files if --ignore-walk-errors is specified?
* support for parallel s3 uploads (multiprocessing.dummy thread pool?)
START:
if num_threads > 1:
thread_pool = multiprocessing.dummy.Pool(num_threads)
UPLOAD:
if num_threads > 1:
thread_pool.apply_async(destination.upload, (key, source, rel_path))
else:
destination.upload(key, source, rel_path)
END:
if num_threads > 1:
logger.info('waiting for parallel uploads to finish')
thread_pool.join() # or whatever
View
@@ -3,13 +3,11 @@
Run "python cdnupload.py -h" for command line help, or see README.rst for
full documentation.
cdnupload is (c) Ben Hoyt 2017 and licensed under multiple licenses: it's
free for open source websites, and there are two well-priced commercial
licenses available for businesses.
Released under a permissive MIT license (see LICENSE.txt).
Visit the project's website for more details and for licensing information:
Visit the project's website for more details:
https://cdnupload.com/
https://github.com/benhoyt/cdnupload
"""
@@ -36,10 +34,9 @@
__all__ = ['SourceError', 'DestinationError', 'FileSource', 'Destination',
'FileDestination', 'S3Destination', 'upload', 'delete']
__version__ = '1.0.3'
__version__ = '1.0.4'
DEFAULT_HASH_LENGTH = 16
LICENSES = ['open', 'single', 'multi']
LOG_LEVELS = [
('debug', logging.DEBUG),
('verbose', logging.INFO),
@@ -636,64 +633,6 @@ def delete(source, destination, force=False, dry_run=False,
return result
def is_license_valid():
"""Ask user to agree to one of the licenses, return True if they've accepted."""
license_path = '~/.cdnupload/license'
license_full_path = os.path.expanduser(license_path)
try:
with open(license_full_path) as f:
license = f.read().strip().lower()
if license in LICENSES:
return True
except OSError:
pass
prompt = """
cdnupload is licensed under multiple licenses -- for more details, see:
https://cdnupload.com/#licensing
license types:
open free for websites that are open source (AGPLv3 license)
single single website commercial license with support
multi multi-website commercial license with support
If you're using cdnupload for an open source website, type "open". If you've
paid for a single website or multi-website license, type "single" or "multi".
You'll only have to type this once (it's saved to {license_path}).
YES, I AGREE to the terms of the license [{licenses}]:
""".format(license_path=license_path, licenses=', '.join(LICENSES))
prompt = prompt.strip() + ' '
while True:
license = input(prompt).strip().lower()
if license in LICENSES:
break
prompt = 'Please enter a valid license [{licenses}]: '.format(
licenses=', '.join(LICENSES))
try:
license_dir = os.path.dirname(license_full_path)
if not os.path.exists(license_dir):
os.mkdir(license_dir)
with open(license_full_path, 'w') as f:
f.write(license)
except OSError as error:
message = """
ERROR writing license to {license_full_path}:
{error}
You can use the --license={license} command line option to override
""".format(license_full_path=license_full_path, error=error, license=license)
print(message.rstrip(), file=sys.stderr)
return False
return True
def main(args=None):
"""Command line endpoint for uploading/deleting. If args not specified,
the sys.argv command line arguments are used. Run "cdnupload.py -h" for
@@ -703,7 +642,7 @@ def main(args=None):
args = sys.argv[1:]
description = """
cdnupload {version} -- (c) Ben Hoyt 2017 -- https://cdnupload.com/
cdnupload {version} -- (c) Ben Hoyt 2017 -- github.com/benhoyt/cdnupload
Upload static files from given source directory to destination directory or
Amazon S3 bucket, with content-based hash in filenames for versioning.
@@ -764,17 +703,11 @@ def main(args=None):
less_common.add_argument('--ignore-walk-errors', action='store_true',
help='ignore errors when walking source tree, '
'except for error on root directory')
less_common.add_argument('--license', choices=LICENSES,
help="override \"agree to license\" prompt shown "
"on first run; only use if you've paid or agreed "
"to the open license (see "
"https://cdnupload.com/#licensing for more info)")
less_common.add_argument('--license',
help="deprecated (cdnupload now has a simple MIT license)")
args = parser.parse_args()
if args.license is None and not is_license_valid():
return 1
logging.basicConfig(level=logging.WARNING, format='%(message)s')
log_level = next(v for k, v in LOG_LEVELS if k == args.log_level)
logger.setLevel(log_level)
View
Binary file not shown.
View
@@ -34,8 +34,8 @@
version=version,
author='Ben Hoyt',
author_email='benhoyt@gmail.com',
url='https://cdnupload.com/',
license='Multi-licensed: AGPLv3 and Commercial',
url='https://github.com/benhoyt/cdnupload',
license='MIT License',
description='Upload static files from given source directory to '
'destination directory or Amazon S3 bucket, with content-'
'based hash in filenames for versioning.',
@@ -53,7 +53,7 @@
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Operating System :: OS Independent',
'License :: Other/Proprietary License',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python',
'Programming Language :: Python :: 2',

0 comments on commit 595921b

Please sign in to comment.