diff options
| author | czaks <marcin@6irc.net> | 2014-08-08 22:18:06 +0200 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2014-08-08 22:18:06 +0200 |
| commit | b8381b31db9360c2e66d93e78b5b48d78a2a9002 (patch) | |
| tree | 508862a4e746feba6649a7f62c41b2cfead0dc0e | |
| parent | 84c8e74ffa5744e0558a9eee04debe086448df31 (diff) | |
Revert "Use a different way to show the original filename"
This reverts commit d81a6c49e28133c65d237fc648be7fe323bfd54d.
Conflicts:
js/download-original.js
templates/post/fileinfo.html
| -rw-r--r-- | inc/config.php | 2 | ||||
| -rw-r--r-- | js/download-original.js | 43 | ||||
| -rw-r--r-- | templates/post/fileinfo.html | 24 |
3 files changed, 49 insertions, 20 deletions
diff --git a/inc/config.php b/inc/config.php index 741846e9..91e53a6d 100644 --- a/inc/config.php +++ b/inc/config.php @@ -743,8 +743,6 @@ $config['show_ratio'] = false; // Display the file's original filename. $config['show_filename'] = true; - // Download the file with its original filename upon clicking on it. Only works when $config['show_filename'] is true. - $config['download_filename'] = false; // Display image identification links for ImgOps, regex.info/exif, Google Images and iqdb. $config['image_identification'] = false; diff --git a/js/download-original.js b/js/download-original.js index 9ef77c74..cf9635ac 100644 --- a/js/download-original.js +++ b/js/download-original.js @@ -1,5 +1,42 @@ -/* Remove this file from your inc/instance-config.php +/* + * download-original.js + * https://github.com/savetheinternet/Tinyboard/blob/master/js/download-original.js + * + * Makes image filenames clickable, allowing users to download and save files as their original filename. + * Only works in newer browsers. http://caniuse.com/#feat=download + * + * Released under the MIT license + * Copyright (c) 2012-2013 Michael Save <savetheinternet@tinyboard.org> + * Copyright (c) 2013-2014 Marcin Ćabanowski <marcin@6irc.net> + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/download-original.js'; + * + */ - Consult this: https://github.com/dubcheck/Alokal/commit/a7c710ebcd39fef1430aa4cab2508a9e5ea60fcf +onready(function(){ + var do_original_filename = function() { + var filename, truncated; + if ($(this).attr('title')) { + filename = $(this).attr('title'); + truncated = true; + } else { + filename = $(this).text(); + } + + $(this).replaceWith( + $('<a></a>') + .attr('download', filename) + .append($(this).contents()) + .attr('href', $(this).parent().parent().find('a').attr('href')) + .attr('title', _('Save as original filename') + (truncated ? ' (' + filename + ')' : '')) + ); + }; - This file is preserved here for compatibility; will be removed on the next major version */ + $('.postfilename').each(do_original_filename); + + $(document).on('new_post', function(e, post) { + $(post).find('.postfilename').each(do_original_filename); + }); +}); diff --git a/templates/post/fileinfo.html b/templates/post/fileinfo.html index ad398d60..73bdf2d2 100644 --- a/templates/post/fileinfo.html +++ b/templates/post/fileinfo.html @@ -7,21 +7,7 @@ {% if file.file == 'deleted' %} <img class="post-image deleted" src="{{ config.image_deleted }}" alt="" /> {% else %} - <p class="fileinfo">{% trans %}File:{% endtrans %} <a href="{{ config.uri_img }}{{ file.file }}" - {% if config.show_filename and file.filename %} - {% if config.download_filename %} - download="{{ file.filename|e|bidi_cleanup }}" - {% endif %} - {% if file.filename|length > config.max_filename_display %} - title="{{ file.filename|e|bidi_cleanup }}" - >{{ file.filename|truncate_filename(config.max_filename_display)|e|bidi_cleanup }} - {% else %} - >{{ file.filename|e|bidi_cleanup }} - {% endif %} - {% else %} - >{{ file.file }} - {% endif %} - </a><br><span class="unimportant"><em> + <p class="fileinfo">File: <a href="{{ config.uri_img }}{{ file.file }}">{{ file.file }}</a> <span class="unimportant"> ( {% if file.thumb == 'spoiler' %} {% trans %}Spoiler Image{% endtrans %}, @@ -33,6 +19,14 @@ , {{ ratio(file.width, file.height) }} {% endif %} {% endif %} + {% if config.show_filename and file.filename %} + , + {% if file.filename|length > config.max_filename_display %} + <span class="postfilename" title="{{ file.filename|e|bidi_cleanup }}">{{ file.filename|truncate_filename(config.max_filename_display)|e|bidi_cleanup }}</span> + {% else %} + <span class="postfilename">{{ file.filename|e|bidi_cleanup }}</span> + {% endif %} + {% endif %} ) {% include "post/image_identification.html" %} </em></span> {% include "post/file_controls.html" %}</p> |
