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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Contains secret keys
*.pyc

credentials.sh
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "reddit"]
path = reddit
url = git@github.com:Reddit-Enhancement-Suite/redditbots
13 changes: 13 additions & 0 deletions aws-cloudflare/aws_s3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os
from tinys3 import Connection
from tinys3.request_factory import S3Request

access_key = os.environ.get('AWS_ACCESS_KEY_ID')
secret = os.environ.get('AWS_ACCESS_KEY_SECRET')
region = os.environ.get('AWS_REGION')
bucket = os.environ.get('AWS_BUCKET')
if access_key is None or secret is None:
raise Exception('Amazon S3 credentials are not available')


conn = Connection(access_key,secret, default_bucket=bucket, tls=True)
11 changes: 11 additions & 0 deletions aws-cloudflare/cloudflare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os
from pyflare import PyflareClient


email = os.environ.get('CLOUDFLARE_EMAIL')
api_key = os.environ.get('CLOUDFLARE_API_KEY')
if email is None or api_key is None:
raise Exception('CloudFlare credentials are not available')


client = PyflareClient(email, api_key)
47 changes: 47 additions & 0 deletions aws-cloudflare/pushtohosting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import argparse
import tinys3
from cloudflare import client as cf_client
from aws_s3 import conn as aws_client
import os
import logging

domain = 'cdn.redditenhancementsuite.com'
base_url = 'https://{domain}/{filename}'

logging.basicConfig(level=logging.DEBUG)

class AmazonS3_Cloudflare_Pusher(object):
def __init__(self, filenames):
super(self.__class__, self).__init__()
if isinstance(filenames, basestring):
self.filenames = [ filenames ]
else:
self.filenames = filenames

def main(self):

for filename in self.filenames:
self.push(filename)

def push(self, filename):
with open(filename,'rb') as f:
logging.debug("{}:\n{}".format(filename, f))
logging.info('Uploading {} to AWS'.format(filename))
aws_client.upload(os.path.basename(filename),f)
url = base_url.format(domain=domain, filename=filename)
logging.info('Purging {} on Cloudflare'.format(filename))
#cf_response = cf_client.zone_file_purge(z=domain, url=url) # Todo: catch ratelimit exception and wait


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("src_path", metavar="path", type=str,
help="Path to file")

args = parser.parse_args()
filename = args.src_path

logging.debug('Pushing to hosting: {}'.format(filename))
bot = AmazonS3_Cloudflare_Pusher(filename)
bot.main()

20 changes: 10 additions & 10 deletions RESUpdates.css → css/RESUpdates.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ body.front-page.res-hide-tagline-frontpage .tagline { display: none; }
.res-nightmode:not(.res-nightMode-coloredLinks) .thing .title {
color: hsl(0,0%,87%);
}
.res-nightmode:not(.res-nightMode-coloredLinks) .thing:not(.stickied) .title:visited,
.res-nightmode:not(.res-nightMode-coloredLinks) .thing.visited:not(.stickied) .title,
.res-nightmode:not(.res-nightMode-coloredLinks).combined-search-page .search-result a:visited,
.res-nightmode:not(.res-nightMode-coloredLinks) .thing:not(.stickied) .title:visited,
.res-nightmode:not(.res-nightMode-coloredLinks) .thing.visited:not(.stickied) .title,
.res-nightmode:not(.res-nightMode-coloredLinks).combined-search-page .search-result a:visited,
.res-nightmode:not(.res-nightMode-coloredLinks).combined-search-page .search-result a:visited > mark {
color: hsl(0,0%,65%);
}

.new-comment .usertext-body { margin: 0; }
.res-v4-6-0 .new-comment .usertext-body { margin: 0; }

.res-neverEndingReddit-hideFloatingPauseButton #NREPause { display: none; }

Expand All @@ -37,7 +37,7 @@ res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke #sr-header-area, .res-nig
background-color: white;
border: 1px solid rgb(160, 160, 160);
border-bottom: 1px solid white;
}
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke div#RESShortcutsEditContainer, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke div#RESShortcutsSort, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke div#RESShortcutsRight, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke div#RESShortcutsLeft, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke div#RESShortcutsAdd, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke div#RESShortcutsTrash {
background: rgb(68, 68, 68) !important;
Expand All @@ -53,7 +53,7 @@ res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke #sr-header-area, .res-nig
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .thing:nth-of-type(4n+1) {
background: rgb(24, 24, 24);
background: rgb(24, 24, 24);
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .midcol .score, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .moduleButton:not(.enabled) {
Expand All @@ -69,8 +69,8 @@ res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke #sr-header-area, .res-nig
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .content {
background: rgb(17, 17, 17);
border-color: rgb(17, 17, 17);
background: rgb(17, 17, 17);
border-color: rgb(17, 17, 17);
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .link .rank {
Expand Down Expand Up @@ -101,9 +101,9 @@ res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke #sr-header-area, .res-nig
background-color: rgb(187, 187, 187);
color: rgb(0, 0, 0);
padding: 1px;
}
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .titlebox form.toggle,
.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .titlebox form.toggle,
.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .leavemoderator {
background: #262626 none no-repeat scroll center left !important;
}
Expand Down
208 changes: 208 additions & 0 deletions css/RESUpdatesTest.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
body.front-page.res-hide-tagline-frontpage .tagline { display: none; }

.res-nightmode:not(.res-nightMode-coloredLinks) .thing .title {
color: hsl(0,0%,87%);
}
.res-nightmode:not(.res-nightMode-coloredLinks) .thing:not(.stickied) .title:visited,
.res-nightmode:not(.res-nightMode-coloredLinks) .thing.visited:not(.stickied) .title,
.res-nightmode:not(.res-nightMode-coloredLinks).combined-search-page .search-result a:visited,
.res-nightmode:not(.res-nightMode-coloredLinks).combined-search-page .search-result a:visited > mark {
color: hsl(0,0%,65%);
}

.new-comment .usertext-body { margin: 0; }

.res-neverEndingReddit-hideFloatingPauseButton #NREPause { display: none; }



/* HEADER */

res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke #sr-header-area, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke #sr-more-link {
background-color: rgb(68, 68, 68) !important;
color: rgb(222, 222, 222) !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke #RESSubredditGroupDropdown a, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .RESNotificationContent, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .RESNotificationFooter, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .sr-bar a {
color: rgb(222, 222, 222) !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke #header, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .liveupdate-home .content {
background-color: rgb(105, 105, 105);
border-bottom: 1px solid rgb(160, 160, 160) !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .tabmenu li.selected a {
color: orangered;
background-color: white;
border: 1px solid rgb(160, 160, 160);
border-bottom: 1px solid white;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke div#RESShortcutsEditContainer, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke div#RESShortcutsSort, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke div#RESShortcutsRight, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke div#RESShortcutsLeft, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke div#RESShortcutsAdd, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke div#RESShortcutsTrash {
background: rgb(68, 68, 68) !important;
color: rgb(140, 179, 217) !important;
}

/* FRONTPAGE */

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .thing {
padding: 7px;
margin: 0;
background-color: #222;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .thing:nth-of-type(4n+1) {
background: rgb(24, 24, 24);
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .midcol .score, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .moduleButton:not(.enabled) {
color: #c6c6c6 !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .rank .star, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .link .score.likes, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .linkcompressed .score.likes {
color: rgb(255, 69, 0) !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .rank .star, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .link .score.dislikes, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .linkcompressed .score.dislikes {
color: rgb(140, 179, 217) !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .content {
background: rgb(17, 17, 17);
border-color: rgb(17, 17, 17);
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .link .rank {
color: #c6c6c6 !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .domain a {
color: rgb(173, 216, 230) !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .subreddit {
color: rgba(20, 150, 220, 0.8) !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .author {
color: rgba(20, 150, 220, 0.8) !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .live-timestamp {
color: #B3B375 !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .RES-keyNav-activeElement > .tagline, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .RES-keyNav-activeElement .md-container > .md, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .RES-keyNav-activeElement .md-container > .md p {
color: rgb(187, 187, 187) !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .flair, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .linkflairlabel {
background-color: rgb(187, 187, 187);
color: rgb(0, 0, 0);
padding: 1px;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .titlebox form.toggle,
.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .leavemoderator {
background: #262626 none no-repeat scroll center left !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke:not(.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke-coloredLinks) .thing:not(.stickied) .title:visited, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke:not(.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke-coloredLinks) .thing.visited:not(.stickied) .title, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke:not(.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke-coloredLinks).combined-search-page .search-result a:visited, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke:not(.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke-coloredLinks).combined-search-page .search-result a:visited>mark {
color: rgb(120, 120, 120);
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .md, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .content .sitetable .thing .md, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .RES-keyNav-activeElement .md-container > .md p {
color: rgb(222, 222, 222) !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .entry .buttons li a {
color: rgb(150, 150, 150) !important;
}

/* BUTTONS */

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .thing .expando-button, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .thing .expando-button:hover {
background-image: url(%%buttons-nightmodeClassic-u-RunTillYouPuke%%);
background-color: transparent;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.video-muted.collapsed {
background-position: 0px -384px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.video-muted.collapsed:hover {
background-position: 0px -408px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.video-muted.expanded {
background-position: 0px -432px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.video-muted.expanded:hover {
background-position: 0px -456px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.selftext.collapsed {
background-position: 0px -96px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.selftext.collapsed:hover{
background-position: 0px -120px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.selftext.expanded {
background-position: 0px -144px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.selftext.expanded:hover {
background-position: 0px -168px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.image.gallery.collapsed {
background-position: 0px -288px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.image.gallery.collapsed:hover {
background-position: 0px -312px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.image.gallery.expanded {
background-position: 0px -336px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.image.gallery.expanded:hover {
background-position: 0px -360px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.video.collapsed {
background-position: 0px -192px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.video.collapsed:hover {
background-position: 0px -216px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.video.expanded {
background-position: 0px -240px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .expando-button.video.expanded:hover {
background-position: 0px -264px !important;
}

/* COMMENTS */

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .flair, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke .linkflairlabel {
padding: 0px !important;
}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke.res-commentBoxes .comment, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke.res-commentBoxes .comment .comment .comment, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke.res-commentBoxes .comment .comment .comment .comment .comment, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke.res-commentBoxes .comment .comment .comment .comment .comment .comment .comment, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke.res-commentBoxes .comment .comment .comment .comment .comment .comment .comment .comment .comment {
background-color: rgb(24, 24, 24) !important;

}

.res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke.res-commentBoxes .comment .comment, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke.res-commentBoxes .comment .comment .comment .comment, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke.res-commentBoxes .comment .comment .comment .comment .comment .comment, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke.res-commentBoxes .comment .comment .comment .comment .comment .comment .comment .comment, .res-nightmode.res-stylesheet-theme-nightModeClassic-u-RunTillYouPuke.res-commentBoxes .comment .comment .comment .comment .comment .comment .comment .comment .comment .comment {
background-color: rgb(34, 34, 34) !important;
}

38 changes: 38 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
CSS_FILE=${1:-'../css/RESUpdatesTest.css'}
echo $CSS_FILE

set -e

source credentials.sh

#git pull

if [ $(basename $(pwd)) == 'reddit' ]; then
pushd ..
else
if [ $(basename $(pwd)) == 'aws-cloudflare' ]; then
pushd ..
fi
fi


pushd aws-cloudflare
source ../setup-virtualenv.sh
source bin/activate
export PYTHONPATH=$(pwd):$PYTHONPATH
FILE=$CSS_FILE
python pushtohosting.py $FILE
popd




pushd reddit
source ../setup-virtualenv.sh
source bin/activate
export PYTHONPATH=$(pwd):$PYTHONPATH
FILE=$CSS_FILE
python updatesubreddit/stylesheets.py $FILE
popd

popd #Back to original folder
1 change: 1 addition & 0 deletions reddit
Submodule reddit added at 90f862
5 changes: 5 additions & 0 deletions setup-virtualenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if [ ! -d bin ]; then
virtualenv .
source bin/activate
pip install -r requirements.txt
fi