mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-25 23:08:22 -05:00
Switch to symlinks for unique static filenames.
Disable static hash middleware, since it is no longer necessary.
This commit is contained in:
@@ -59,6 +59,7 @@ PYX_FILES := $(shell find . -name \*.pyx)
|
||||
PYXSO_FILES := $(PYX_FILES:.pyx=.so)
|
||||
|
||||
NAMED = $(JSOUTPUTS) $(CSSTARGETS) $(MAINCSS) $(RTLCSS)
|
||||
NAMELINKS = $(patsubst %.css,%.*.css,$(patsubst %.js,%.*.js,$(NAMED)))
|
||||
|
||||
INIUPDATE = $(wildcard *.update)
|
||||
INIS = $(INIUPDATE:.update=.ini)
|
||||
@@ -118,4 +119,4 @@ clean: clean_static
|
||||
rm -f $(PYXSO_FILES)
|
||||
|
||||
clean_static:
|
||||
rm -f $(JSOUTPUTS) $(CSSTARGETS) $(SPRITES) $(MAINCSS) $(MD5S) $(INIS)
|
||||
rm -f $(JSOUTPUTS) $(CSSTARGETS) $(SPRITES) $(MAINCSS) $(NAMES) $(NAMELINKS) $(INIS)
|
||||
|
||||
@@ -617,7 +617,7 @@ def make_app(global_conf, full_stack=True, **app_conf):
|
||||
# Static files
|
||||
javascripts_app = StaticJavascripts()
|
||||
static_app = StaticURLParser(config['pylons.paths']['static_files'])
|
||||
static_app = StaticURLHashMiddleware(static_app)
|
||||
#static_app = StaticURLHashMiddleware(static_app)
|
||||
app = Cascade([static_app, javascripts_app, app])
|
||||
|
||||
app = make_gzip_middleware(app, app_conf)
|
||||
|
||||
@@ -17,7 +17,7 @@ def generate_static_name(name, base=None, shorthash=None):
|
||||
name, ext = os.path.splitext(name)
|
||||
return name + '.' + shorthash + ext
|
||||
|
||||
def update_static_names(names_file, files):
|
||||
def update_static_names(names_file, files, make_links=False):
|
||||
"""Generate a unique file name mapping for ``files`` and write it to a
|
||||
JSON file at ``names_file``."""
|
||||
if os.path.exists(names_file):
|
||||
@@ -33,5 +33,11 @@ def update_static_names(names_file, files):
|
||||
json_enc = json.JSONEncoder(indent=2, sort_keys=True)
|
||||
open(names_file, "w").write(json_enc.encode(names))
|
||||
|
||||
if make_links:
|
||||
for name, staticname in names.iteritems():
|
||||
os.symlink(name, os.path.join(base, staticname))
|
||||
|
||||
return names
|
||||
|
||||
if __name__ == "__main__":
|
||||
update_static_names(sys.argv[1], sys.argv[2:])
|
||||
update_static_names(sys.argv[1], sys.argv[2:], make_links=True)
|
||||
|
||||
Reference in New Issue
Block a user