This repository has been archived by the owner on Feb 13, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into sc-landing-targeting
- Loading branch information
Showing
51 changed files
with
1,237 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,5 +22,6 @@ venv/ | |
.cache/ | ||
.sass-cache/ | ||
.map | ||
scripts/.state | ||
node_modules | ||
*.sw[nop] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM python:3.5 | ||
MAINTAINER Onion Tech <webtech@theonion.com> | ||
|
||
RUN apt-get update \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get update \ | ||
&& apt-get install -y \ | ||
git-core \ | ||
libmemcached-dev \ | ||
libpq-dev \ | ||
postgresql-client-9.4 \ | ||
vim \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Setup app directory | ||
WORKDIR /webapp | ||
|
||
# Install as much as possible before adding app directory, to take advantage of | ||
# Docker's layer caching. | ||
|
||
# Container includes all requirements (so it works in dev + prod) | ||
# Add app as late as possibly (will always trigger cache miss and rebuild from here) | ||
ADD . /webapp | ||
RUN pip install -e . | ||
RUN pip install -e ".[dev]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "2.8.1" | ||
__version__ = "2.9.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
var _ = require('lodash/lodash'); | ||
var adHtml = '<div class="dfp dfp-slot-inread" data-ad-unit="inread"></div>'; | ||
|
||
|
||
var MobileAdPlacer = { | ||
placeAds: function () { | ||
var body = $('body'); | ||
var paragraphs = body.find('p'); | ||
var wordCount = 0; | ||
var adsPlaced = 0; | ||
|
||
for (var i = 0; i < paragraphs.length; i++) { | ||
var paragraphLength = _.words($(paragraphs[i]).html()).length; | ||
wordCount = wordCount + paragraphLength; | ||
|
||
if(wordCount > 350 && adsPlaced < 4) { | ||
// place ad | ||
$(paragraphs[i]).after(adHtml); | ||
wordCount = 0; | ||
adsPlaced++; | ||
} | ||
} | ||
window.ads.loadAds(); | ||
}, | ||
}; | ||
|
||
module.exports = MobileAdPlacer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
describe('MobileAdPlacer', function () { | ||
var mobileAdPlacer = require('./mobile-ad-placer'); | ||
var faker = require('faker'); | ||
|
||
var article = '<section class="article-text"></section>' | ||
var paragraph351 = '<p>' + faker.lorem.words(351) + '</p>'; | ||
var paragraph20 = '<p>' + faker.lorem.words(20) + '</p>'; | ||
|
||
beforeEach(function () { | ||
$('body').append(article); | ||
window.ads = {loadAds: function() { return }}; | ||
}); | ||
|
||
afterEach(function () { | ||
$('.article-text').remove(); | ||
}); | ||
|
||
it('places ad after 350 words', function () { | ||
$('.article-text').append(paragraph351); | ||
mobileAdPlacer.placeAds(); | ||
var articleContents = $('.article-text').children(); | ||
expect($(articleContents[1]).attr('class')).to.equal("dfp dfp-slot-inread"); | ||
}); | ||
|
||
it('places multiple ads', function () { | ||
$('.article-text').append(paragraph351); | ||
$('.article-text').append(paragraph351); | ||
adElement = document.createElement('ad'); | ||
mobileAdPlacer.placeAds(adElement); | ||
var ads = $('.article-text').find('.dfp-slot-inread'); | ||
expect(ads.length).to.equal(2); | ||
}); | ||
|
||
it('only places ads after paragraph breaks', function () { | ||
adElement = document.createElement('ad'); | ||
var bigAssParagraph = '<p>' + faker.lorem.words(1000) + '</p>'; | ||
$('.article-text').append(bigAssParagraph); | ||
|
||
mobileAdPlacer.placeAds(adElement); | ||
var articleContents = $('.article-text').children(); | ||
// sanity check ad is placed | ||
expect($('.article-text').find('.dfp').length).to.equal(1); | ||
// not placed within p element | ||
expect($('p').find('.dfp').length).to.equal(0); | ||
}); | ||
|
||
it('places no more than 4 ads', function () { | ||
adElement = document.createElement('ad'); | ||
for(var i = 0; i < 5; i++) { | ||
$('.article-text').append(paragraph351); | ||
} | ||
mobileAdPlacer.placeAds(); | ||
var ads = $('.article-text').find('.dfp-slot-inread'); | ||
expect(ads.length).to.equal(4); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from rest_framework.metadata import SimpleMetadata | ||
|
||
from bulbs.infographics.metadata import InfographicMetadata | ||
from bulbs.infographics.serializers import InfographicSerializer | ||
|
||
|
||
class PolymorphicContentMetadata(SimpleMetadata): | ||
|
||
serializer_lookup = { | ||
InfographicSerializer: InfographicMetadata() | ||
} | ||
|
||
def determine_metadata(self, request, view): | ||
if hasattr(view, "get_serializer_class"): | ||
serializer_class = view.get_serializer_class() | ||
metadata = self.serializer_lookup.get(serializer_class, None) | ||
if metadata: | ||
return metadata.determine_metadata(request, view) | ||
# TODO: Spike out why we included this generic (and bad) response. | ||
return {"status": "ok"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('content', '0011_auto_20160613_1116'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='content', | ||
name='template_choice', | ||
field=models.IntegerField(default=0, choices=[(0, None), (1, 'special_coverage/landing.html')]), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.