<commit_before>url-shortener
================

A URL shortener application using Flask_, `Flask-SQLAlchemy`_, `Flask-WTF`_ , `Flask-Migrate`_, `Flask-Script`_ and `spam-lists`_.

.. _Flask: http://flask.pocoo.org/
.. _Flask-SQLAlchemy: http://flask-sqlalchemy.pocoo.org/2.1/
.. _Flask-WTF: http://flask-wtf.readthedocs.io/en/latest/
.. _Flask-Migrate: https://flask-migrate.readthedocs.io/en/latest/
.. _Flask-Script: https://flask-script.readthedocs.io/en/latest/
.. _spam-lists: https://github.com/piotr-rusin/spam-lists

Features
--------

-  reusing alias for a requested short URL if its target has already been registered
-  a preview page for registered short URLs
-  configurable range of character numbers for newly registered aliases
-  logging using :code:`logging.handlers.TimedRotatingFileHandler`
-  preventing registration of URLs recognized as spam or having a blaclisted host
-  always previewing registered URLs that have been later blacklisted or recognized as spam
-  displaying proper warning when previewing spam or blacklisted URLs
-  support for database migration commands:

   .. code:: bash

       $ python manage.py db init
       $ python manage.py db migrate
       $ python manage.py db upgrade
       $ python manage.py db --help

Installation
------------

Clone from GitHub and install using pip:

.. code:: bash

    $ git clone https://github.com/piotr-rusin/url-shortener
    $ cd url-shortener
    $ pip install .

To be able to run tests, install test extras:

.. code:: bash

    $ pip install url-shortener[test]

It is necessary to override default configuration by setting :code:`URL_SHORTENER_CONFIGURATION` environment variable to a name of a custom configuration file. This file must provide its own value of the following options:

-  SQLALCHEMY_DATABASE_URI
-  SECRET_KEY
-  GOOGLE_SAFE_BROWSING_API_KEY
-  RECAPTCHA_PUBLIC_KEY
-  RECAPTCHA_PRIVATE_KEY

For more details, read `docstring in url_shortener.default_config.py`__

.. __: https://github.com/piotr-rusin/url-shortener/blob/master/
   url_shortener/default_config.py

Once the database exists and the application is configured to use it, perform initial migration to prepare all the necessary tables:

.. code:: bash

    $ python manage.py db upgrade

When installing a new version of the project, run the same command to upgrade your database in case the new version introduces changes to its database schema.

License
-------

| MIT
| See LICENSE__

.. __: https://github.com/piotr-rusin/spam-lists/blob/master/LICENSE<commit_msg>Update README.rst<commit_after>url-shortener
================

A URL shortener application using Flask_, `Flask-SQLAlchemy`_, `Flask-WTF`_ , `Flask-Migrate`_, `Flask-Script`_, `Flask-Injector`_ and `spam-lists`_.

.. _Flask: http://flask.pocoo.org/
.. _Flask-SQLAlchemy: http://flask-sqlalchemy.pocoo.org/2.1/
.. _Flask-WTF: http://flask-wtf.readthedocs.io/en/latest/
.. _Flask-Migrate: https://flask-migrate.readthedocs.io/en/latest/
.. _Flask-Script: https://flask-script.readthedocs.io/en/latest/
.. _Flask-Injector: https://github.com/alecthomas/flask_injector
.. _spam-lists: https://github.com/piotr-rusin/spam-lists

Features
--------

-  providing unique short alias for each registered URL
-  a preview page for registered short URLs
-  configurable range of character numbers for newly registered aliases
-  logging using :code:`logging.handlers.TimedRotatingFileHandler`
-  preventing registration of URLs recognized as spam or having a blaclisted host
-  always previewing registered URLs that have been blacklisted or recognized as spam after their registration
-  displaying proper warning when previewing spam or blacklisted URLs
-  customizable whitelist for trusted, non-spam hosts
-  support for database migration commands:

   .. code:: bash

       $ python manage.py db init
       $ python manage.py db migrate
       $ python manage.py db upgrade
       $ python manage.py db --help

Installation
------------

Clone from GitHub and install using pip:

.. code:: bash

    $ git clone https://github.com/piotr-rusin/url-shortener
    $ cd url-shortener
    $ pip install .

To be able to run tests, install test extras:

.. code:: bash

    $ pip install url-shortener[test]

It is necessary to override default configuration by setting :code:`URL_SHORTENER_CONFIGURATION` environment variable to a name of a custom configuration file. This file must provide its own value of the following options:

-  :code:`SQLALCHEMY_DATABASE_URI`
-  :code:`SECRET_KEY`
-  :code:`GOOGLE_SAFE_BROWSING_API_KEY`
-  :code:`RECAPTCHA_PUBLIC_KEY`
-  :code:`RECAPTCHA_PRIVATE_KEY`

For more details, read `docstring in url_shortener.default_config.py`__

.. __: https://github.com/piotr-rusin/url-shortener/blob/master/
   url_shortener/default_config.py

When installing a new version of the project, run the following command to upgrade your database in case the new version introduces changes to its database schema:

.. code:: bash

    $ python manage.py db upgrade

License
-------

| MIT
| See LICENSE__

.. __: https://github.com/piotr-rusin/spam-lists/blob/master/LICENSE
{'fraction_non_alphanumeric': 0.10649502633118783, 'fraction_numerical': 0.0007801833430856252, 'mean_word_length': 3.6660600545950865, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 13, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '554244', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1579, 'n_words': 486}