diff --git a/.gitignore b/.gitignore index ea0ba4f..c8cedef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *~* *local* static_files* -static* +static_* *.pyc meta* +data* \ No newline at end of file diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..b64b575 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn --pythonpath=./anonymous_me anonymous_me.wsgi_production:application \ No newline at end of file diff --git a/anonymous_me/settings/base.py b/anonymous_me/settings/base.py index 37c592a..d128dd1 100644 --- a/anonymous_me/settings/base.py +++ b/anonymous_me/settings/base.py @@ -70,7 +70,7 @@ if HOSTNAME.startswith('127'): # for my local work HOSTNAME = '127.0.0.1:8080' else : - HOSTNAME = socket.gethostname() + HOSTNAME = 'anme.herokuapp.com' # production url diff --git a/anonymous_me/settings/production.py b/anonymous_me/settings/production.py index 3a4de36..91bfa65 100644 --- a/anonymous_me/settings/production.py +++ b/anonymous_me/settings/production.py @@ -1,5 +1,6 @@ from base import * import os +import dj_database_url SECRET_KEY = os.getenv('SECRET_KEY') @@ -7,4 +8,39 @@ TEMPLATE_DEBUG = False ALLOWED_HOSTS = ['*'] -WSGI_APPLICATION = 'anonymous_me.wsgi_production.application' \ No newline at end of file +WSGI_APPLICATION = 'anonymous_me.wsgi_production.application' + +# Database settings +# Parse database configuration from $DATABASE_URL + +DATABASE_URL = os.getenv('DATABASE_URL') +DATABASES = {} + +DATABASES['default'] = dj_database_url.config(default=DATABASE_URL) + +# Honor the 'X-Forwarded-Proto' header for request.is_secure() +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'filters': { + 'require_debug_false': { + '()': 'django.utils.log.RequireDebugFalse' + } + }, + 'handlers': { + 'mail_admins': { + 'level': 'ERROR', + 'filters': ['require_debug_false'], + 'class': 'django.utils.log.AdminEmailHandler' + } + }, + 'loggers': { + 'django.request': { + 'handlers': ['mail_admins'], + 'level': 'ERROR', + 'propagate': True, + }, + } +} \ No newline at end of file diff --git a/anonymous_me/urls.py b/anonymous_me/urls.py index 33fc259..69e2fc4 100644 --- a/anonymous_me/urls.py +++ b/anonymous_me/urls.py @@ -1,12 +1,19 @@ from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() -from url_shortener import views + +from django.http import HttpResponse +from url_shortener import views +from django.views.generic import TemplateView urlpatterns = patterns('', url(r'^$',views.home), url(r'^shortify_url$',views.shortify_url), - url(r'^admin/', include(admin.site.urls)), + url(r'^imankush', include(admin.site.urls)), # do not use $ as it will make the url end + url(r'^google4962e1a518060429\.html$', lambda r: HttpResponse("google-site-verification: google4962e1a518060429.html", mimetype="text/plain")), #added google site ownership verification file + url(r'^robots\.txt$', TemplateView.as_view(template_name='robots.txt')), #added ronots.txt file + url(r'^sitemap.xml$',TemplateView.as_view(template_name='sitemap.xml')), #serving sitemap url(r'^(.*)$',views.redirect), # one more than one characters # .* matches everything + ) diff --git a/anonymous_me/wsgi_production.py b/anonymous_me/wsgi_production.py index 967bb1f..b4ffc5a 100644 --- a/anonymous_me/wsgi_production.py +++ b/anonymous_me/wsgi_production.py @@ -2,4 +2,6 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "anonymous_me.settings.production") from django.core.wsgi import get_wsgi_application -application = get_wsgi_application() + +from dj_static import Cling +application = Cling(get_wsgi_application()) diff --git a/manage.py b/manage.py index 7fafa33..c816a2f 100755 --- a/manage.py +++ b/manage.py @@ -3,7 +3,7 @@ import sys if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "anonymous_me.settings.local") + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "anonymous_me.settings.production") from django.core.management import execute_from_command_line diff --git a/readme.md b/readme.md index c0e2e52..d20d037 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,33 @@ Anonymous_Me ------------ -A url shortener that will make you anonymous on the web. +A **Url Shortener** that will make you anonymous on the web. Generates anonymous shortened urls from a supplied url. And it's **here**: http://anme.herokuapp.com + +Features +-------- + +- Saves the **state** of urls to cut down resources used. +- Easily **extendible** ! + +Built Using +----------- + +- Django 1.6.5 +- PostgreSql + +**Usage** + +Locally, create a database and configure `settings.local` and then : + + + + $ virtualenv --no-site-packages anonymous_me + $ cd anonymous_me/ + $ git clone https://github.com/black-perl/Anonymous_Me.git + $ cd Anonymous_Me/ + $ foreman start + +Fork it if you like +------------------- +Any queries at ankprashar@gmail.com + diff --git a/requirements.txt b/requirements.txt index 287cfa2..fcdfdd4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,9 @@ Django==1.6.5 +MySQL-python==1.2.5 +argparse==1.2.1 +dj-database-url==0.3.0 +dj-static==0.0.6 gunicorn==19.1.0 -dj_static==0.0.6 +psycopg2==2.5.4 +static3==0.5.1 +wsgiref==0.1.2 diff --git a/static/img/Anonymous.svg b/static/img/Anonymous.svg deleted file mode 100644 index 434d5e7..0000000 --- a/static/img/Anonymous.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - image/svg+xml - - Wir sind anonym - - - - - - \ No newline at end of file diff --git a/static/img/abc.jpg b/static/img/abc.jpg deleted file mode 100644 index 44f07e9..0000000 Binary files a/static/img/abc.jpg and /dev/null differ diff --git a/static/img/anony.jpg b/static/img/anonymous.jpg similarity index 100% rename from static/img/anony.jpg rename to static/img/anonymous.jpg diff --git a/static/img/favicon.png b/static/img/favicon.png new file mode 100644 index 0000000..0ec99c1 Binary files /dev/null and b/static/img/favicon.png differ diff --git a/templates/google4962e1a518060429.html b/templates/google4962e1a518060429.html new file mode 100644 index 0000000..b85f7c9 --- /dev/null +++ b/templates/google4962e1a518060429.html @@ -0,0 +1,2 @@ +google-site-verification: +google4962e1a518060429.html \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index d79735c..7d0560b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -8,11 +8,12 @@ Anonymous_Me - + - + + @@ -30,9 +31,9 @@ Fork anonymous me on GitHub
- +

Anonymous_Me

-

A domain shortener that will make you anonymous on the web

+

A URL shortener that will make you anonymous on the web

@@ -57,7 +58,7 @@

A domain shortener that will make you anonymous on the web

diff --git a/templates/robots.txt b/templates/robots.txt new file mode 100644 index 0000000..1d9ca2a --- /dev/null +++ b/templates/robots.txt @@ -0,0 +1,3 @@ +User-agent: * +Allow: / +Sitemap: http://anme.herokuapp.com/sitemap.xml \ No newline at end of file diff --git a/templates/sitemap.xml b/templates/sitemap.xml new file mode 100644 index 0000000..f49b27e --- /dev/null +++ b/templates/sitemap.xml @@ -0,0 +1,9 @@ + + + + + http://anme.herokuapp.com/ + 2014-11-03 + Weekly + + \ No newline at end of file diff --git a/url_shortener/views.py b/url_shortener/views.py index cb3bbda..07ffa2e 100644 --- a/url_shortener/views.py +++ b/url_shortener/views.py @@ -21,25 +21,21 @@ def shortify_url(request): context = Context({}) url = request.POST.get('url','') - print "URL",url if not url: context['errors'] = 'No URL was supplied' # checking for the supplied url if js is off else: # the url has been supplied try: check_obj = URLtoHASH.objects.get(url=url) # checking if the url is already shoretened or not - print "URL ALREADY EXISTS" hash_val = check_obj.hash_value except: # means the user entered a new url url_obj = URLtoHASH(url=url) # creating a new URL obj url_obj.save() # save to DB url_id = url_obj.id # getting the ID of the stored DB object - print 'URL_ID',url_id hash_val = hashed_string(url_id) url_obj.hash_value = hash_val# saving the hashed value to the DB url_obj.save() # saving the changes to the DB - print 'HASH_VALUE',hash_val shortened_url = urlparse.urlunparse(('http',HOSTNAME,hash_val,'','','')) context["success"] = shortened_url print shortened_url