Skip to content

Commit

Permalink
Initial import of adserver code
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfischer committed Aug 29, 2018
1 parent 18e180e commit ec23270
Show file tree
Hide file tree
Showing 48 changed files with 1,102 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.git

# Make absolutely sure production settings never get into Docker
.envs

# Don't put the static sources into the container
assets/src

# Django & Python ignores
**/*.sqlite3
**/*.pyc
**/__pycache__
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# http://editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{py,rst,ini}]
indent_style = space
indent_size = 4

[*.{html,css,scss,vue,json,yml,js}]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
15 changes: 15 additions & 0 deletions .envs/sample.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Django settings
DJANGO_SETTINGS_MODULE=config.settings.production
SECRET_KEY=

# Gunicorn settings
WEB_CONCURRENCY=4

# Ad server settings
ADSERVER_HTTPS=False
ADSERVER_ADMIN_URL=admin

# Using Sqlite is fine for a local test
#DATABASE_URL=sqlite:///db.sqlite3
# PostgreSQL is better for a real production instance
DATABASE_URL=psql://username:[email protected]:5432/database
74 changes: 74 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
### OSX ###
.DS_Store
.AppleDouble
.LSOverride

### SublimeText ###
# cache files for sublime text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache

# workspace files are user-specific
*.sublime-workspace

# project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using SublimeText
# *.sublime-project

# sftp configuration file
sftp-config.json

# Basics
*.py[cod]
__pycache__

# Logs
*.log
pip-log.txt

# Unit test / coverage reports
.coverage
.tox
nosetests.xml
htmlcov

# Translations
*.mo
*.pot

# Pycharm
.idea/*


# Vim
*~
*.swp
*.swo

# npm
node_modules/

# Compass
.sass-cache

# User-uploaded media
techint/media/

# MailHog binary
mailhog


##########################################################################
# Ad Server specific ignores
##########################################################################

# Production settings
.envs/production.env

# Compiled static files
assets/dist
static

# Development database
db.sqlite3
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.PHONY: help test clean dockerbuild dockerserve dockershell

CONTAINER_NAME = ethicaladserver
CONTAINER_ENVS = .envs/production.env

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " test Run the full test suite"
@echo " clean Delete assets processed by webpack"
@echo " dockerbuild Build a docker container of the ad server"
@echo " dockerserve Run the docker container for the ad server on port 5000"
@echo " dockershell Connect to a shell on the docker container"

test:
tox

clean:
rm -rf assets/dist/*

dockerbuild: clean
npm run build-production
docker build -t $(CONTAINER_NAME) -f deploy/Dockerfile .

dockerserve:
docker container run --env-file $(CONTAINER_ENVS) --publish 5000:5000 $(CONTAINER_NAME)

dockershell:
docker container run --env-file $(CONTAINER_ENVS) -it $(CONTAINER_NAME) /bin/bash
40 changes: 40 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
=================
Ethical Ad Server
=================

The Ethical Ad Server is an advertising server without all the tracking.
It is created by Read the Docs to serve the ads on Read the Docs.


Features
--------

* Supports banners, banner+text, and text-only ads
* Extensive and extensible ad fraud prevention
* Reports based on campaign, flight, or individual ad
* DoNotTrack ready
* GDPR ready
* Geographical targeting by country and state/province
* Supports custom targeting parameters

The Ethical Ad Server uses GeoLite2 data created by MaxMind.


Developing
----------

To setup your environment and run a local development server::

$ npm install
$ npm run build
$ pip install -r requirements/development.txt
$ python3 manage.py runserver # This server runs on Python 3.6+

To run the unit tests::

$ make test

To build the production Docker container::

$ make dockerbuild

Empty file added adserver/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions adserver/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin # noqa

# Register your models here.
5 changes: 5 additions & 0 deletions adserver/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class AdserverConfig(AppConfig):
name = 'adserver'
Empty file added adserver/migrations/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions adserver/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models # noqa

# Create your models here.
29 changes: 29 additions & 0 deletions adserver/templates/adserver/dashboard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!doctype html>
<html lang="en">
<head>
{% block start_head %}{% endblock start_head %}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="{% block meta_description %}{% endblock meta_description %}">
{% block metas %}{% endblock metas %}

<title>{% block fulltitle %}{% block shorttitle %}{% endblock shorttitle %} - Ethical Ad Server{% endblock fulltitle %}</title>

{% block css %}{% endblock css %}

{% block end_head %}{% endblock end_head %}
</head>

<body class="{% block classes_body %}{% endblock classes_body %}">

{% block start_body %}{% endblock start_body %}

{% block main_body %}Ethical Ad Server {{ version }}{% endblock main_body %}

{% block end_body %}{% endblock end_body %}

{% block js %}{% endblock js %}

</body>

</html>
3 changes: 3 additions & 0 deletions adserver/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase # noqa

# Create your tests here.
8 changes: 8 additions & 0 deletions adserver/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.conf.urls import url

from .views import dashboard


urlpatterns = [
url('^$', dashboard),
]
10 changes: 10 additions & 0 deletions adserver/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.shortcuts import render


@login_required
def dashboard(request):
return render(request, 'adserver/dashboard.html', {
'version': settings.ADSERVER_VERSION,
})
Empty file added assets/dist/.gitkeep
Empty file.
6 changes: 6 additions & 0 deletions assets/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// JavaScript requirements
import * as jquery from 'jquery';
import * as bootstrap from 'bootstrap';

// CSS includes
import './scss/index.scss';
3 changes: 3 additions & 0 deletions assets/src/scss/_theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background-color: $gray-100;
}
4 changes: 4 additions & 0 deletions assets/src/scss/_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$primary: #17a2b8; /* cyan */
$warning: #ffc107; /* yellow */

$jumbotron-height: 25rem;
7 changes: 7 additions & 0 deletions assets/src/scss/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import "_variables.scss";
@import "~bootstrap/scss/bootstrap.scss";

$fa-font-path: "~font-awesome/fonts";
@import "~font-awesome/scss/font-awesome.scss";

@import "theme.scss";
Empty file added config/__init__.py
Empty file.
Empty file added config/settings/__init__.py
Empty file.
Loading

0 comments on commit ec23270

Please sign in to comment.