Code Monkey home page Code Monkey logo

website-environment-generator's Introduction

Website Environment Generator

Python version: 2.7.10

This is a very basic program to build website folder heirarchies automatically, to simplify the process of starting simple projects.

To run this script, navigate to the proper directory, and run python web.py

Certain libraries can be downloaded automatically; the full list is given below. For any library currently not supported, an empty folder will be created in which you may place the files manually. Library files are downloaded from the owners of the libraries.

Currently supported libraries:

  • React JS
  • Bootstrap (CSS and JS)
  • Isotope
  • Angular
Adding more libraries

Adding further support is quite easy. All it takes currently is an addition to the if statement that determines the library. For example:

def check_for_library_match(package):
    if package == "jquery":
        print("Downloading jQuery 1.12.0 from http://code.jquery.com/jquery-1.12.0.js...")
        return 'http://code.jquery.com/jquery-1.12.0.js'
    elif package == "isotope":
        print("Downloading isotopeJS 2.2.2 from cdnjs...")
        return 'http://cdnjs.cloudflare.com/ajax/libs/jquery.isotope/2.2.2/isotope.pkgd.min.js'
    else:
        return None

The argument taken by check_for_library is a forced-lowercase string of whatever package is typed when prompted. Adding an all-lowercase condition as an elif statement in the same format will allow more libraries to be downloaded. The logic will then format the URL for use once the function returns. For example:

    elif package == "mylib":
      print("Downloading mylib 0.1 from far, far away...")
      return 'http://mylib.com/libraryfile/lib.js'

File Generation

Once you are finished entering libraries, simply type none to end. At this point, 3 files will be generated:

  • index.html
  • site.js
  • site.css

index.html will be automatically set up with HTML5 elements, and all the libraries are automatically added, inclduing the automatically generated CSS and JS files.

Current workarounds

Certian packages (i.e. bootstrap and reactJS) require multiple files, and some CSS and JavaScript. For these, I have a second set of conditions that don't return anything and simply download the files and create directories directly.

if package.lower() == "bootstrap":
    os.makedirs(projectname + "/assets/css/" + package)
    print("Downloading Bootstrap from maxcdn...")
    urllib.urlretrieve('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css', projectname + '/assets/css/' + package + '/bootstrap.min.css')
    urllib.urlretrieve('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js', projectname + '/assets/js/packages/' + package + '/bootstrap.min.js')
    css.append('/assets/css/' + package + '/bootstrap.min.css')
    scripts.append('/assets/js/packages/' + package + '/bootstrap.min.js')

Changing the file location: The script will always navigate to your /Documents/ folder. To change this, you can change folderlocation = 'Documents' to something other than Documents, such as Desktop, Downloads, etc. Currently, these are the only directories that can be easily accessed.

Generated Heirarchy

The following is a sample heirarchy that could be generated:

ProjectName
├── assets
│   ├── css
│   │   ├── bootstrap
│   │   │   └── bootstrap.min.css
│   │   └── site.css
│   ├── img
│   └── js
│       ├── packages
│       │   ├── bootstrap
│       │   │   └── bootstrap.min.js
│       │   └── jquery
│       │       └── jquery-1.12.0.js
│       └── site.js
└── index.html

Deletion Script

Running web-delete.py will allow you to enter the names of directories in the /Documents/ folder to delete. Note: this will, of course, allow you to delete any folder in the directory, not only ones created using web.py.

website-environment-generator's People

Contributors

keegandonley avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.