Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: reddit/reddit
base: 149567a797
...
head fork: reddit/reddit
compare: e2ca4f3d03
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 5 files changed
  • 0 commit comments
  • 2 contributors
Commits on Jul 19, 2012
@kemitche kemitche Make each of the JS files individually responsible
Make will still only build once
07af98f
Max Goodman Simplify handling/mangling of should_compile special case.
or: How I Learned to Stop Worrying and Love the Mangling.
bcbba69
Max Goodman Shorten recent clicks cookie to at most 5 elements. e2ca4f3
View
16 r2/Makefile
@@ -105,7 +105,7 @@ STATIC_BUILDSTAMP := $(BUILD_DIR)/static-buildstamp
static: plugin_static pyx css js names
clean_static:
- rm -rf $(STATIC_BUILDSTAMP) $(STATIC_BUILD_DIR) $(PLUGIN_BUILDSTAMPS) $(JS_MODULE_BUILDSTAMPS) $(MANGLE_BUILDSTAMP)
+ rm -rf $(STATIC_BUILDSTAMP) $(STATIC_BUILD_DIR) $(PLUGIN_BUILDSTAMPS) $(MANGLE_BUILDSTAMP)
$(STATIC_BUILDSTAMP): $(STATIC_FILES)
cp -ruTL $(STATIC_ROOT) $(STATIC_BUILD_ROOT)
@@ -171,16 +171,13 @@ clean_css:
rm -f $(CSS_OUTPUTS)
#### JS
-JS_MODULE_BUILDSTAMPS := $(foreach module,$(JS_MODULES),$(BUILD_DIR)/js-$(module)-buildstamp)
.PHONY: clean_js
-js: $(STATIC_BUILDSTAMP) $(JS_MODULE_BUILDSTAMPS)
-
-$(JS_OUTPUTS): $(JS_MODULE_BUILDSTAMPS)
+js: $(STATIC_BUILDSTAMP) $(JS_OUTPUTS)
define JS_MODULE_TEMPLATE
-$(BUILD_DIR)/js-$(1)-buildstamp: $(JS_MODULE_DEPS_$(1))
+$(JS_MODULE_OUTPUTS_$(1)): $(JS_MODULE_DEPS_$(1))
# remove mangled output symlinks, similar to above.
rm -f $(JS_MODULE_OUTPUTS_$(1))
paster run standalone r2/lib/js.py -c "build_module('$(1)')"
@@ -192,7 +189,7 @@ endef
$(foreach module,$(JS_MODULES),$(eval $(call JS_MODULE_TEMPLATE,$(module))))
clean_js:
- rm -f $(JS_MODULE_BUILDSTAMPS) $(STATIC_BUILD_DIR)/*.js
+ rm -f $(STATIC_BUILD_DIR)/*.js
#### name mangling
MANGLEABLE_FILES := $(CSS_OUTPUTS) $(JS_OUTPUTS)
@@ -209,11 +206,10 @@ $(MANGLE_BUILDSTAMP): $(MANGLEABLE_FILES)
touch $@
clean_names:
- rm -f $(MANGLE_BUILDSTAMP) $(NAMES_FILES) $(MANGLEABLE_FILES) $(MANGLED_FILES) $(JS_MODULE_BUILDSTAMPS)
+ rm -f $(MANGLE_BUILDSTAMP) $(NAMES_FILES) $(MANGLEABLE_FILES) $(MANGLED_FILES)
#### gzip!
-JQUERY_JS := $(wildcard $(STATIC_BUILD_DIR)/js/lib/jquery-*.min.js)
-GZIPPABLE := $(filter %.css %.js,$(MANGLED_FILES) $(JQUERY_JS))
+GZIPPABLE := $(filter %.css %.js,$(MANGLED_FILES))
GZIPPED := $(addsuffix .gzip,$(GZIPPABLE))
.PHONY: clean_gzip
View
2  r2/Makefile.py
@@ -32,7 +32,7 @@
print 'PLUGIN_PATH_%s := %s' % (plugin.name, PluginLoader.plugin_path(plugin))
js.load_plugin_modules()
-modules = dict((k, m) for k, m in js.module.iteritems() if m.should_compile)
+modules = dict((k, m) for k, m in js.module.iteritems())
print 'JS_MODULES := ' + ' '.join(modules.iterkeys())
outputs = []
for name, module in modules.iteritems():
View
4 r2/r2/controllers/reddit_base.py
@@ -163,8 +163,8 @@ def set_recent_clicks():
if valid_click_cookie(click_cookie):
names = [ x for x in UniqueIterator(click_cookie.split(',')) if x ]
- if len(click_cookie) > 1000:
- names = names[:20]
+ if len(names) > 5:
+ names = names[:5]
set_user_cookie('recentclicks2', ','.join(names))
#eventually this will look at the user preference
names = names[:5]
View
24 r2/r2/lib/js.py
@@ -134,11 +134,12 @@ def path(self):
return os.path.join(STATIC_ROOT, "static", self.name)
def build(self, closure):
- print >> sys.stderr, "Compiling {0}...".format(self.name),
with open(self.path, "w") as out:
if self.should_compile:
+ print >> sys.stderr, "Compiling {0}...".format(self.name),
closure.compile(self.get_source(), out)
else:
+ print >> sys.stderr, "Concatenating {0}...".format(self.name),
out.write(self.get_source())
print >> sys.stderr, " done."
@@ -158,10 +159,7 @@ def dependencies(self):
@property
def outputs(self):
- if self.should_compile:
- return [self.path]
- else:
- return []
+ return [self.path]
class StringsSource(Source):
"""A virtual source consisting of localized strings from r2.lib.strings."""
@@ -247,18 +245,15 @@ def outputs(self):
class JQuery(Module):
version = "1.7.2"
- def __init__(self, cdn_src=None):
- local_jquery_path = os.path.join("js", "lib", "jquery-%s.min.js" % self.version)
- Module.__init__(self, local_jquery_path, should_compile=False)
- self.cdn_src = cdn_src or "http://ajax.googleapis.com/ajax/libs/jquery/%s/jquery" % self.version
-
- def build(self, closure):
- pass
+ def __init__(self, cdn_url="http://ajax.googleapis.com/ajax/libs/jquery/{version}/jquery"):
+ self.jquery_src = FileSource("lib/jquery-{0}.min.js".format(self.version))
+ Module.__init__(self, "jquery.js", self.jquery_src, should_compile=False)
+ self.cdn_src = cdn_url.format(version=self.version)
def use(self):
from r2.lib.template_helpers import static
if c.secure or c.user.pref_local_js:
- return script_tag.format(src=static(self.name))
+ return Module.use(self)
else:
ext = ".js" if g.uncompressedJS else ".min.js"
return script_tag.format(src=self.cdn_src+ext)
@@ -335,8 +330,7 @@ def wrapped(*args):
@build_command
def enumerate_modules():
for name, m in module.iteritems():
- if m.should_compile:
- print name
+ print name
@build_command
def dependencies(name):
View
6 r2/r2/public/static/js/reddit.js
@@ -496,9 +496,9 @@ function add_thing_id_to_cookie(id, cookie_name) {
cookie.data = id + ',' + cookie.data;
- if(cookie.data.length > 1000) {
- var fullnames = cookie.data.split(',');
- fullnames = $.uniq(fullnames, 20);
+ var fullnames = cookie.data.split(',');
+ if(fullnames.length > 5) {
+ fullnames = $.uniq(fullnames, 5);
cookie.data = fullnames.join(',');
}

No commit comments for this range

Something went wrong with that request. Please try again.