Coder Social home page Coder Social logo

deecubes's Introduction

deecubes (Damn Simple Static url Shortener)

The name comes from the short form DSSS of Damn Simple Static url Shortener (so, a D and a cube of S's. Idiotic, I know :P). This program allows to maintain a website of short urls, akin to bit.ly/tinyurl etc, that can redirect to longer urls so one has to remember/give shorter ones. The main point of this project is to allow this to be done via a static website instead of a database based solution.

There are several benefits of a static website like they are much cheaper (Free to host on github/gitlab etc), easy to migrate to any host in minutes (if not seconds), etc. On top of this, the project strives to make this process as simple as possible to use.

Input

Long url that you want to shorten

A mnemonic/shorturl you want to assign to it (Optional. If not given, one is generated automatically)

Output

Static website of shorturls redirecting to your long urls

One can also go to shorturl/preview.html to see the long url it points to without getting redirected.

Installation

deecubes is compatible wit python3 only. It's recommended to install deecubes from pypi using pip

pip install deecubes

Deployment methods

You can use/deploy your own shorturl websites using deecubes in various ways given below and more:

  • Host website on github/gitlab etc. Run deecubes cli commands (given in next section) locally to generate shorturls in a git repository. Commit and upload.

  • Host website on github/gitlab etc. Create a 'source' branch in the website repository. Add a link to input directory from PC or directly through web interface and use a CI job (like Travis/CircleCI/Pipeline etc) to automatically generate shorturls using "sync" commands. https://shgl.in/ uses this method.

  • Create your own automation to host the output directory on any host (through APIs or mounted directories etc)

CLI Usage

usage: deecubes [-h] [-v] [-l LOGLEVEL]
                [-a SHORTURL URL | -g URL | -d SHORTURL | -s] -r RAW_DATA_PATH
                -o OUTPUT_PATH

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -l LOGLEVEL, --log LOGLEVEL
                        Set log level. 0=> Warning, 1=>Info, 2=>Debug
  -a SHORTURL URL, --add SHORTURL URL
                        Add given shorturl for given url
  -g URL, --generate URL
                        Generate shorturl for given url
  -d SHORTURL, --delete SHORTURL
                        Delete given shorturl
  -s, --sync            Sync raw data storage and html output

required arguments:
  -r RAW_DATA_PATH, --raw-data-path RAW_DATA_PATH
                        Raw data storage path
  -o OUTPUT_PATH, --output-path OUTPUT_PATH
                        HTML output path

Notes:

  • Raw Path: A directory where deecubes stores raw information about urls. This can be empty directory if you are using add/generate commands for urls. Otherwise, you can add a .txt file here with the content being a long url. Then when, sync command is used, deecubes will add corresponding shorturl html files in output directory using the filename as the shorturl.

  • Output Path: Path where the static website is generated. This directory should be used for deployment.

  • Raw path and output path are mandatory to specify for all commands

Examples

Add a specific shorturl for a long url

deecubes -r ./raw -o ./public -a github https://github.com/shantanugoel/

Add a long url and deecubes will generate a shorturl on its own

deecubes -r ./raw -o ./public -g https://github.com/shantanugoel/

Automatically generate shorturls in output dir for any .txt files that were manually added to raw directory

deecubes -r ./raw -o ./public --sync

TODO

  • Add collision handling

  • Add google analytics

  • Add configurable templates

  • Suggestions?

deecubes's People

Contributors

parvjain avatar shantanugoel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

parvjain

deecubes's Issues

pip install deecubes fails.

System: 14.04.1-Ubuntu
Pip version : pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)
Issue:

  Could not find any downloads that satisfy the requirement deecubes
Cleaning up...
No distributions at all found for deecubes
Storing debug log for failure in /home/argonlaser/.pip/pip.log

Error log:

/usr/bin/pip run on Tue Oct 31 00:01:04 2017
Downloading/unpacking deecubes
  Getting page https://pypi.python.org/simple/deecubes/
  URLs to search for versions for deecubes:
  * https://pypi.python.org/simple/deecubes/
  Analyzing links from page https://pypi.python.org/simple/deecubes/
    Skipping https://pypi.python.org/packages/04/7d/7eb23a51410bd9ef40b200c5843b0db9bb31c1067b27d44a8fded3a51c45/deecubes-0.2.2-py3-none-any.whl#md5=bf20388fbdf8d3661765bd5e49b7b773 (from https://pypi.python.org/simple/deecubes/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/0f/d6/fa004ed1ab5126d031d0d61f1fb0831b4b4517628c5eb52f2b41d00dfa9a/deecubes-0.2.1-py3-none-any.whl#md5=e04f06ef2be57e07f854743f3c2f3e54 (from https://pypi.python.org/simple/deecubes/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/44/bd/6c7f13bcb6bffff75a178eac49f760f8bf5f08992fadda57a3a45dabfbe2/deecubes-0.2.0-py3-none-any.whl#md5=8b470dacbfdefe40223d81dd40b7c038 (from https://pypi.python.org/simple/deecubes/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/75/72/8ac50b7fc5517062e66357b1709c686d2d027f9b366555ce19aafd8df43c/deecubes-0.1.0-py3-none-any.whl#md5=590b9da59000e739a5937ebe7dd3fa0d (from https://pypi.python.org/simple/deecubes/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/a5/22/6ed90526c8bd76c819f0c93b3460801d23284ac5d1b3bed0236e82ba7766/deecubes-0.3.0-py3-none-any.whl#md5=59dee9c635b5399c28a7fbe96e6aa8e7 (from https://pypi.python.org/simple/deecubes/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/be/92/c6531935ba2add8772d3b07aa1225c14f96b8b5b45523b32a5ca06f2a47d/deecubes-0.3.1-py3-none-any.whl#md5=110a3192255b7bc7f9fb7f1a7160245f (from https://pypi.python.org/simple/deecubes/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/db/16/933b5138fffba2c67edf3b70e0addc0ecbc7a2075399c05c78b03b1fc7eb/deecubes-0.2.3-py3-none-any.whl#md5=9544eee59512b55d0fce701d8d8a44e2 (from https://pypi.python.org/simple/deecubes/) because it is not compatible with this Python
  Could not find any downloads that satisfy the requirement deecubes
Cleaning up...
  Removing temporary dir /tmp/pip_build_root...
No distributions at all found for deecubes

Could you please let know why its not downloading?

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.