Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*~*
*local*
static_files*
static*
static_*
*.pyc
meta*
data*
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn --pythonpath=./anonymous_me anonymous_me.wsgi_production:application
2 changes: 1 addition & 1 deletion anonymous_me/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down
38 changes: 37 additions & 1 deletion anonymous_me/settings/production.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
from base import *
import os
import dj_database_url

SECRET_KEY = os.getenv('SECRET_KEY')

DEBUG = False
TEMPLATE_DEBUG = False
ALLOWED_HOSTS = ['*']

WSGI_APPLICATION = 'anonymous_me.wsgi_production.application'
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,
},
}
}
11 changes: 9 additions & 2 deletions anonymous_me/urls.py
Original file line number Diff line number Diff line change
@@ -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

)
4 changes: 3 additions & 1 deletion anonymous_me/wsgi_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
31 changes: 30 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -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

8 changes: 7 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
19 changes: 0 additions & 19 deletions static/img/Anonymous.svg

This file was deleted.

Binary file removed static/img/abc.jpg
Binary file not shown.
File renamed without changes
Binary file added static/img/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions templates/google4962e1a518060429.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
google-site-verification:
google4962e1a518060429.html
11 changes: 6 additions & 5 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
<head>
<title> Anonymous_Me </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="A domain shortener that will make you anonymous on the web.">
<meta name="description" content="A url shortener that will make you anonymous on the web.">
<meta name="keywords" content="url-shortener,anonymous-me">
<meta name="author" content="Ankush Sharma,IIT BHU,black-perl">
<meta name="viewport" content="width=device-width">


<link rel="shortcut icon" type="image/png" href = {% static 'img/favicon.png' %} >
<link rel="stylesheet" href={% static "css/preloader.css" %} type="text/css">
<link rel="stylesheet" href={% static "css/main.css" %} type="text/css">
<link rel="stylesheet" href={% static "vendor/font-awesome/css/font-awesome.min.css" %} type="text/css">
Expand All @@ -30,9 +31,9 @@
<img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork anonymous me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png">
</a>
<div class="headerContent">
<img id="logo" src={% static "img/anony.jpg" %} alt="SVG"> </img>
<img id="logo" src={% static "img/anonymous.jpg" %} alt="SVG"> </img>
<h1><a href="/"> Anonymous_Me </a> <i class="fa fa-spinner fa-spin" style="color:white"></i> </h1>
<h2> A domain shortener that will make you anonymous on the web </h2>
<h2> A URL shortener that will make you anonymous on the web </h2>
</div> <!-- End headerContent -->
</header> <!-- End Header -->

Expand All @@ -57,7 +58,7 @@ <h2> A domain shortener that will make you anonymous on the web </h2>

<footer>
<p> Made with Django and lots of &nbsp; <i class="fa fa-heart" style="color:red"></i> &nbsp;
by Ankush Sharma (&nbsp; <a href="https://github.com/black-perl">black-perl </a> &nbsp;)
by Ankush Sharma. (&nbsp; <a href="https://github.com/black-perl">black-perl </a> &nbsp;)
</p>
</footer> <!-- End Footer -->
</div>
Expand Down
3 changes: 3 additions & 0 deletions templates/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
User-agent: *
Allow: /
Sitemap: http://anme.herokuapp.com/sitemap.xml
9 changes: 9 additions & 0 deletions templates/sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://anme.herokuapp.com/</loc>
<lastmod>2014-11-03</lastmod>
<changefreq>Weekly</changefreq>
</url>
</urlset>
4 changes: 0 additions & 4 deletions url_shortener/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down