<commit_before>ww
##
A virtual host website deployment and management tool for Apache and WordPress
==============================================================================

.. image:: https://www.quantifiedcode.com/api/v1/project/5e43e90cc7344452b49c16c19666789f/badge.svg
    :target: https://www.quantifiedcode.com/app/project/5e43e90cc7344452b49c16c19666789f
    :alt: Code issues

----

This is a work in progress. Use at your own risk.

ww is a collection of modules packaged together to create a program that is
useful for installing and managing a number of virtualhost websites (WordPress
in particular). It helps automate the process of creating appropriate
directories with the correct permissions, creating a virtualhost file for
Apache, and installing WordPress and setting up its MySQL database. This
application solves the problem of having to manually repeat this process. It
further helps with maintenance by verifying that everything is in order and
it helps with removal by undoing everything it originally did. Finally, the
application helps with packing and unpacking entire WordPress websites to move
the site from a development server to a live server.

This software is developed for a very specific `Environment`_, but should be
easy to modify and extend to other use cases. It assumes your server OS is
Ubuntu running Apache (and for installing WordPress, PHP and MySQL). For
information on extending ww see `Package Internals`_.

To run ww, the Python modules `ext_pylib <https://www.github.com/hbradleyiii/ext_pylib>`_,
`MySQL-python <https://pypi.python.org/pypi/MySQL-python>`_ (for wordpress
installations), and `requests <https://github.com/kennethreitz/requests>`_
must be installed. Testing ww requires `pytest <http://pytest.org/>`_.


Installation and Usage
======================

Installing ww
--------------------

.. code:: bash

    $ git clone <EMAIL>:hbradleyiii/ww.git
    $ cd <project directory>
    $ pip install -e .

Running Tests
-------------

.. code:: bash

    $ cd <project directory>
    $ py.test

Usage
-----

.. code:: bash

    $ ww install example.com
    $ ww verify example.com
    $ ww remove example.com

Environment
===========
This application was developed specifically for a Ubuntu server running Apache,
PHP, and MySQL. The default commands for alerting Apache to a new vhost and
restarting Apache are based on this. These can be easily changed if on a
different platform.

This is the default directory structure that is set up by the application:

.. code::

    /etc/apache2/
        ├── sites-available/
        │   ├── example.com.conf { vhost file }

    /var/www/
        ├── .git/ { git repository }
        ├── htdocs/ {root directory of website}
        │   ├── .htaccess
        │   ├── (wp_config.php)
        │   ├── (WordPress Installation)
        ├── assets/ {root directory of website}
        ├── log/
        │   ├── access_log
        │   ├── error_log

Package Internals
=================

Class: WWFile
---------------
``WWFile`` is a class from which all other classes representing files derive.
It provides a basic interface for consistency. It extends ``ext_pylib.file``
File class.  Currently, its only method is ``repair()`` which offers a
convinient wrapper for the ``verify()`` method with the repair flag set to
``True``.

See `ext_pylib https://github.com/hbradleyiii/ext_pylib`_ for more
documentation on the ``ext_pylib`` module.

Module: htaccess
~~~~~~~~~~~~~~~~
The ``ww.htaccess`` module contains the ``Htaccess`` class which represents a
website's htaccess file and provides an interface for creating htaccess files.

Website htaccess files are generally a collection of 'sections' that are
responsible for particular things. For instance, a WordPress website will often
have a section like:

.. code::

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^index\.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d<commit_msg>Fixes an error in markdown.<commit_after>ww
##
A virtual host website deployment and management tool for Apache and WordPress
==============================================================================

.. image:: https://www.quantifiedcode.com/api/v1/project/5e43e90cc7344452b49c16c19666789f/badge.svg
    :target: https://www.quantifiedcode.com/app/project/5e43e90cc7344452b49c16c19666789f
    :alt: Code issues

----

This is a work in progress. Use at your own risk.

ww is a collection of modules packaged together to create a program that is
useful for installing and managing a number of virtualhost websites (WordPress
in particular). It helps automate the process of creating appropriate
directories with the correct permissions, creating a virtualhost file for
Apache, and installing WordPress and setting up its MySQL database. This
application solves the problem of having to manually repeat this process. It
further helps with maintenance by verifying that everything is in order and
it helps with removal by undoing everything it originally did. Finally, the
application helps with packing and unpacking entire WordPress websites to move
the site from a development server to a live server.

This software is developed for a very specific `Environment`_, but should be
easy to modify and extend to other use cases. It assumes your server OS is
Ubuntu running Apache (and for installing WordPress, PHP and MySQL). For
information on extending ww see `Package Internals`_.

To run ww, the Python modules `ext_pylib <https://www.github.com/hbradleyiii/ext_pylib>`_,
`MySQL-python <https://pypi.python.org/pypi/MySQL-python>`_ (for wordpress
installations), and `requests <https://github.com/kennethreitz/requests>`_
must be installed. Testing ww requires `pytest <http://pytest.org/>`_.


Installation and Usage
======================

Installing ww
--------------------

.. code:: bash

    $ git clone <EMAIL>:hbradleyiii/ww.git
    $ cd <project directory>
    $ pip install -e .

Running Tests
-------------

.. code:: bash

    $ cd <project directory>
    $ py.test

Usage
-----

.. code:: bash

    $ ww install example.com
    $ ww verify example.com
    $ ww remove example.com

Environment
===========
This application was developed specifically for a Ubuntu server running Apache,
PHP, and MySQL. The default commands for alerting Apache to a new vhost and
restarting Apache are based on this. These can be easily changed if on a
different platform.

This is the default directory structure that is set up by the application:

.. code::

    /etc/apache2/
        ├── sites-available/
        │   ├── example.com.conf { vhost file }

    /var/www/
        ├── .git/ { git repository }
        ├── htdocs/ {root directory of website}
        │   ├── .htaccess
        │   ├── (wp_config.php)
        │   ├── (WordPress Installation)
        ├── assets/ {root directory of website}
        ├── log/
        │   ├── access_log
        │   ├── error_log

Package Internals
=================

Class: WWFile
---------------
``WWFile`` is a class from which all other classes representing files derive.
It provides a basic interface for consistency. It extends ``ext_pylib.file``
File class.  Currently, its only method is ``repair()`` which offers a
convinient wrapper for the ``verify()`` method with the repair flag set to
``True``.

See `ext_pylib <https://github.com/hbradleyiii/ext_pylib>`_ for more
documentation on the ``ext_pylib`` module.

Module: htaccess
~~~~~~~~~~~~~~~~
The ``ww.htaccess`` module contains the ``Htaccess`` class which represents a
website's htaccess file and provides an interface for creating htaccess files.

Website htaccess files are generally a collection of 'sections' that are
responsible for particular things. For instance, a WordPress website will often
have a section like:

.. code::

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^index\.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
{'fraction_non_alphanumeric': 0.12493845396356475, 'fraction_numerical': 0.012309207287050714, 'mean_word_length': 3.4889502762430937, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 12, 'lorem ipsum': 0, 'www.': 8, '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': '1583446', 'n_tokens_mistral': 2339, 'n_tokens_neox': 2195, 'n_words': 951}