Skip to content

Commit

Permalink
Avoid implicit ordering between style.html template and python code. …
Browse files Browse the repository at this point in the history
…Just inject the ICONS_URL.
  • Loading branch information
jaraco committed Aug 21, 2024
1 parent 05107a9 commit 062ce63
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 48 deletions.
31 changes: 2 additions & 29 deletions dropbox_index/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,7 @@

FILES_URL = 'http://dl.dropbox.com/u/69843/dropbox-index'


def _make_icon(name):
return f'{FILES_URL}/icons/{name}.png'


_icon_names = (
'back',
'folder',
'file',
'image',
'video',
'music',
'archive',
'package',
'pdf',
'txt',
'markup',
'code',
'font',
'document',
'spreadsheet',
'presentation',
'application',
'plugin',
'iso',
)

ICONS = tuple(map(_make_icon, _icon_names))
ICONS_URL = f'{FILES_URL}/icons'


def _load_file_types():
Expand All @@ -75,7 +48,7 @@ def _load_file_types():
FILE_TYPES = dict(_load_file_types())

HTML_STYLE = (
resources.files().joinpath('style.html').read_text(encoding='utf-8') % ICONS
resources.files().joinpath('style.html').read_text(encoding='utf-8') % globals()
)


Expand Down
38 changes: 19 additions & 19 deletions dropbox_index/style.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@
/* Icons */
.dir, .back, .file {
background-repeat: no-repeat; background-position: 2px 4px;}
.back { background-image: url('%s'); }
.dir { background-image: url('%s'); }
.file { background-image: url('%s'); }
.image { background-image: url('%s'); }
.video { background-image: url('%s'); }
.music { background-image: url('%s'); }
.archive { background-image: url('%s'); }
.package { background-image: url('%s'); }
.pdf { background-image: url('%s'); }
.txt { background-image: url('%s'); }
.markup { background-image: url('%s'); }
.code { background-image: url('%s'); }
.font { background-image: url('%s'); }
.document { background-image: url('%s'); }
.spreadsheet { background-image: url('%s'); }
.presentation { background-image: url('%s'); }
.application { background-image: url('%s'); }
.plugin { background-image: url('%s'); }
.iso { background-image: url('%s'); }
.back { background-image: url('%(ICONS_URL)s/back.png'); }
.dir { background-image: url('%(ICONS_URL)s/dir.png'); }
.file { background-image: url('%(ICONS_URL)s/file.png'); }
.image { background-image: url('%(ICONS_URL)s/image.png'); }
.video { background-image: url('%(ICONS_URL)s/video.png'); }
.music { background-image: url('%(ICONS_URL)s/music.png'); }
.archive { background-image: url('%(ICONS_URL)s/archive.png'); }
.package { background-image: url('%(ICONS_URL)s/package.png'); }
.pdf { background-image: url('%(ICONS_URL)s/pdf.png'); }
.txt { background-image: url('%(ICONS_URL)s/txt.png'); }
.markup { background-image: url('%(ICONS_URL)s/markup.png'); }
.code { background-image: url('%(ICONS_URL)s/code.png'); }
.font { background-image: url('%(ICONS_URL)s/font.png'); }
.document { background-image: url('%(ICONS_URL)s/document.png'); }
.spreadsheet { background-image: url('%(ICONS_URL)s/spreadsheet.png'); }
.presentation { background-image: url('%(ICONS_URL)s/presentation.png'); }
.application { background-image: url('%(ICONS_URL)s/application.png'); }
.plugin { background-image: url('%(ICONS_URL)s/plugin.png'); }
.iso { background-image: url('%(ICONS_URL)s/iso.png'); }
</style>

0 comments on commit 062ce63

Please sign in to comment.