Skip to content

Commit 16afe85

Browse files
committed
current site
1 parent 0979012 commit 16afe85

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+3837
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.env
2+
dump.rdb

Gemfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
source :rubygems
2+
gem 'sinatra', '~>1.3.0'
3+
gem 'redis', '~> 3.0.0.rc2'
4+
gem 'unicorn'
5+
gem 'ohm'
6+
gem 'mail'
7+
gem 'tzinfo'
8+
gem 'differ'
9+
group :production do
10+
gem 'newrelic_rpm'
11+
end
12+
gem 'rack-cache'
13+
gem 'dalli'
14+
group :development do
15+
gem 'better_errors'
16+
gem 'binding_of_caller'
17+
end

Gemfile.lock

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
GEM
2+
remote: http://rubygems.org/
3+
specs:
4+
better_errors (0.0.7)
5+
coderay
6+
erubis
7+
binding_of_caller (0.6.8)
8+
coderay (1.0.8)
9+
dalli (2.1.0)
10+
differ (0.1.2)
11+
erubis (2.7.0)
12+
i18n (0.6.0)
13+
kgio (2.7.4)
14+
mail (2.4.4)
15+
i18n (>= 0.4.0)
16+
mime-types (~> 1.16)
17+
treetop (~> 1.4.8)
18+
mime-types (1.19)
19+
nest (1.1.2)
20+
redis
21+
newrelic_rpm (3.4.1)
22+
ohm (1.2.0)
23+
nest (~> 1.0)
24+
redis
25+
scrivener (~> 0.0.3)
26+
polyglot (0.3.3)
27+
rack (1.4.1)
28+
rack-cache (1.2)
29+
rack (>= 0.4)
30+
rack-protection (1.2.0)
31+
rack
32+
raindrops (0.10.0)
33+
redis (3.0.1)
34+
scrivener (0.0.3)
35+
sinatra (1.3.3)
36+
rack (~> 1.3, >= 1.3.6)
37+
rack-protection (~> 1.2)
38+
tilt (~> 1.3, >= 1.3.3)
39+
tilt (1.3.3)
40+
treetop (1.4.10)
41+
polyglot
42+
polyglot (>= 0.3.1)
43+
tzinfo (0.3.33)
44+
unicorn (4.3.1)
45+
kgio (~> 2.6)
46+
rack
47+
raindrops (~> 0.7)
48+
49+
PLATFORMS
50+
ruby
51+
52+
DEPENDENCIES
53+
better_errors
54+
binding_of_caller
55+
dalli
56+
differ
57+
mail
58+
newrelic_rpm
59+
ohm
60+
rack-cache
61+
redis (~> 3.0.0.rc2)
62+
sinatra (~> 1.3.0)
63+
tzinfo
64+
unicorn

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb

app.rb

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
require 'sinatra/base'
2+
require 'erb'
3+
require 'ohm'
4+
require 'mail'
5+
require 'cgi'
6+
require 'uri'
7+
require 'differ'
8+
require 'base64'
9+
require 'json'
10+
require 'dalli'
11+
require 'rack-cache'
12+
13+
require_relative 'helpers/tzinfo_timezone'
14+
15+
class ItymsApp < Sinatra::Application
16+
set :sessions, true
17+
set :protection, :except => [:remote_token, :json_csrf]
18+
APP_CONFIG = YAML.load_file("config/environment.yml")['production']
19+
configure :production do
20+
$testing = false
21+
set :raise_errors, false
22+
set :show_exceptions, false
23+
require 'newrelic_rpm'
24+
set :cache, Dalli::Client.new
25+
Mail.defaults do
26+
delivery_method :smtp, {
27+
:address => 'smtp.sendgrid.net',
28+
:port => 587,
29+
:domain => 'heroku.com',
30+
:user_name => ENV['SENDGRID_USERNAME'],
31+
:password => ENV['SENDGRID_PASSWORD'],
32+
:authentication => 'plain',
33+
:enable_starttls_auto => true }
34+
end
35+
end
36+
configure :development do
37+
require 'better_errors'
38+
use BetterErrors::Middleware
39+
BetterErrors.application_root = File.expand_path("..", __FILE__)
40+
$testing = true
41+
Mail.defaults do
42+
delivery_method :smtp, {
43+
:address => 'smtp.gmail.com',
44+
:port => 587,
45+
:domain => 'gmail.com',
46+
:user_name => ENV['SENDGRID_USERNAME'],
47+
:password => ENV['SENDGRID_PASSWORD'],
48+
:authentication => 'plain',
49+
:enable_starttls_auto => true }
50+
end
51+
end
52+
53+
$mail_username = ENV['SENDGRID_USERNAME']
54+
$top_domain = APP_CONFIG['top_domain']
55+
56+
$timezone_set = false
57+
$timezoneoffset = TzinfoTimezone.new("Eastern Time (US & Canada)").dst_utc_offset
58+
Differ.format = :html
59+
60+
$plugin_link = "https://chrome.google.com/webstore/detail/ityms/dmfehapjdpdelmpikcbdicfmolflpckg"
61+
62+
before do
63+
#cache_control :public, max_age: 60
64+
if (@logged_in_user = User[session["user_id"]] and @logged_in_user.activated == "true")
65+
unless $timezone_set
66+
$timezone_set = true
67+
$timezoneoffset = TzinfoTimezone.new(@logged_in_user.timezone).dst_utc_offset
68+
end
69+
if %w(/admin).include?(request.path_info) and
70+
@logged_in_user.permission_level != "admin"
71+
goto_login "You don't have the permission to access that page."
72+
end
73+
else
74+
unless %w(/login /signup /resetpassword /getactivationlink /unactivated /about /terms /privacy /contact /changedpassword).include?(request.path_info) or
75+
request.path_info =~ /\.(css|js|png|ico)$/ or request.path_info =~ /(activate|api|changepassword)/ or request.path_info == '/'
76+
redirect '/login', 303
77+
end
78+
end
79+
end
80+
helpers do
81+
end
82+
end
83+
84+
require_relative 'helpers/init'
85+
require_relative 'routes/init'
86+
require_relative 'models/init'

chrome_extension/.DS_Store

6 KB
Binary file not shown.

chrome_extension/eventPage.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
var enabled = false;
2+
var badgeBGColor = [40,190,190,60];
3+
//tellCurrentTab();
4+
setBadgeText("");
5+
chrome.extension.onMessage.addListener(handleMessage);
6+
chrome.tabs.onHighlighted.addListener(function(highlightInfo) {
7+
//tellCurrentTab();
8+
setBadgeText("");
9+
});
10+
chrome.windows.onFocusChanged.addListener(function(windowId) {
11+
//tellCurrentTab();
12+
setBadgeText("");
13+
});
14+
function tellCurrentTab() {
15+
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
16+
var enabledTab = tabs[0].url.match(/http:\/\/|https:\/\//ig) ? true : false;
17+
if(enabledTab) {
18+
setEnabled(true);
19+
if(tabs.length > 0 && enabledTab) {
20+
chrome.tabs.sendMessage(tabs[0].id, {
21+
meta: { method: "GET", command: "get_postcount"}, params: {} }, function() {});
22+
} else setBadgeText("0");
23+
} else {
24+
setEnabled(false);
25+
setBadgeText("");
26+
}
27+
});
28+
}
29+
function handleMessage(request, sender, sendResponse) {
30+
command = request.meta.command;
31+
if (command == "setBadgeText") {
32+
setBadgeText(request.params.text);
33+
sendResponse({success: true});
34+
}
35+
return true;
36+
}
37+
function setEnabled(onoff) {
38+
if(enabled != onoff) {
39+
enabled = onoff;
40+
chrome.browserAction.setPopup({popup: enabled ? "popup.html" : ""});
41+
chrome.browserAction.setIcon({path: enabled ? "icon.png" : "icon-disabled.png"});
42+
}
43+
}
44+
function setBadgeText(badgeText) {
45+
chrome.browserAction.setBadgeText({text: badgeText});
46+
chrome.browserAction.setBadgeBackgroundColor({color: badgeBGColor});
47+
}

0 commit comments

Comments
 (0)