我参与了一个使用白噪声来提供静态文件的应用程序。它被配置为使用CompressedManifestStaticFilesStoragewhich 依次使用ManifestStaticFilesStorage.
我所说的静态文件是指我们提供的静态文件,以及第三方的传单等库。
该类ManifestStaticFilesStorage由 Django 提供,将重命名文件名以包含哈希值。用于缓存清除。它过滤资源并更改对文件的未散列引用以包含散列。
这又破坏了传单中的一个功能:
_detectIconPath: function () {
var el = DomUtil.create('div', 'leaflet-default-icon-path', document.body);
var path = DomUtil.getStyle(el, 'background-image') ||
DomUtil.getStyle(el, 'backgroundImage'); // IE8
document.body.removeChild(el);
return path.indexOf('url') === 0 ?
path.replace(/^url\([\"\']?/, '').replace(/marker-icon\.png[\"\']?\)$/, '') : '';
}
Run Code Online (Sandbox Code Playgroud)
问题是 的值path看起来像:
url("https://example.org/static/path/leaflet/dist/images/marker-icon.2273e3d8ad92.png")
Run Code Online (Sandbox Code Playgroud)
由于文件名不匹配,第二次替换不会执行任何操作。这又将返回:
https://example.org/static/path/leaflet/dist/images/marker-icon.2273e3d8ad92.png")
Run Code Online (Sandbox Code Playgroud)
当传单尝试将文件名附加到这个“目录”时,我们得到:
https://example.org/static/path/leaflet/dist/images/marker-icon.2273e3d8ad92.png")marker-icon.png
Run Code Online (Sandbox Code Playgroud)
这显然是错误的。
那么解决办法是什么呢?我被告知我们不应该尝试对第三方包的文件名进行哈希处理,否则可能会出现其他损坏。但是,我没有看到任何选项来ManifestStaticFilesStorage排除某些目录被散列。
我创建了以下课程来尝试解决此问题。我在设置中引用此类而不是CompressedManifestStaticFilesStorage.
class MyStorage(CompressedManifestStaticFilesStorage):
""" This class overrides the built in class and turns off file name hashing …Run Code Online (Sandbox Code Playgroud) 我有一个刚刚更新为使用 setuptools_scm 的包,发现 readthedocs 中的版本号是错误的。
http://sshuttle.readthedocs.org/en/v0.77/显示:
Version: 0.78.dev0+ng083293e.d20160304
Run Code Online (Sandbox Code Playgroud)
然而,由于版本 083293e 具有 0.77 标签,因此版本字符串应该只是 0.77
看起来 readthedocs 可能会在构建之前对我的源代码进行更改。
我查看了 readthedocs 构建日志,似乎在某个阶段具有正确的版本(0.77),但这是在构建文档之前。
Processing dependencies for sshuttle==0.77
Finished processing dependencies for sshuttle==0.77
Run Code Online (Sandbox Code Playgroud)
构建文档时构建日志不会提及版本。
有可能解决这个问题吗?
谢谢