Review changes for user avatars

- Fix confusion between quoted strings and symbols in attributes.
- Explicitly export deferred posts to the window object.
- Remove useless exports of already imported JS classes.
This commit is contained in:
Kira 2019-05-01 07:09:28 -07:00
parent d04463ab00
commit f7e5eee844
4 changed files with 19 additions and 32 deletions

View File

@ -245,7 +245,9 @@ module ApplicationHelper
post_id = user.avatar_id
return "" unless post_id
DeferredPosts.add(post_id)
tag.div (tag.img class: 'thumb-img placeholder', src: '/images/thumb-preview.png', height: 100, width: 100), class: 'post-thumb placeholder', id: "tp-#{post_id}", 'data-id': post_id
tag.div class: 'post-thumb placeholder', id: "tp-#{post_id}", 'data-id': post_id do
tag.img class: 'thumb-img placeholder', src: '/images/thumb-preview.png', height: 100, width: 100
end
end
protected

View File

@ -30,21 +30,6 @@ importAll(require.context('../src/javascripts', true, /\.js(\.erb)?$/));
importAll(require.context('../src/styles/common', true, /\.scss(?:\.erb)?$/));
importAll(require.context('../src/styles/specific', true, /\.scss(?:\.erb)?$/));
export { default as Autocomplete } from '../src/javascripts/autocomplete.js.erb';
export { default as Blacklist } from '../src/javascripts/blacklists.js';
export { default as Comment } from '../src/javascripts/comments.js';
export { default as Dtext } from '../src/javascripts/dtext.js';
export { default as Note } from '../src/javascripts/notes.js';
export { default as Post } from '../src/javascripts/posts.js.erb';
export { default as PostModeMenu } from '../src/javascripts/post_mode_menu.js';
export { default as PostTooltip } from '../src/javascripts/post_tooltips.js';
export { default as RelatedTag } from '../src/javascripts/related_tag.js';
export { default as Shortcuts } from '../src/javascripts/shortcuts.js';
export { default as Upload } from '../src/javascripts/uploads.js';
export { default as Utility } from '../src/javascripts/utility.js';
export { default as Ugoira } from '../src/javascripts/ugoira.js';
export { default as Thumbnails } from '../src/javascripts/thumbnails.js';
import Takedown from '../src/javascripts/takedowns.js';
window.Takedown = Takedown;

View File

@ -1556,24 +1556,24 @@ class Post < ApplicationRecord
def minimal_attributes
preview_dims = preview_dimensions
hash = {
'status': status,
'flags': status_flags,
'file_ext': file_ext,
'id': id,
'rating': rating,
'preview_width': preview_dims[1],
'width': image_width,
'preview_height': preview_dims[0],
'height': image_height,
'tags': tag_string,
'score': score,
'uploader_id': uploader_id
status: status,
flags: status_flags,
file_ext: file_ext,
id: id,
rating: rating,
preview_width: preview_dims[1],
width: image_width,
preview_height: preview_dims[0],
height: image_height,
tags: tag_string,
score: score,
uploader_id: uploader_id
}
if visible?
hash['md5'] = md5
hash['preview_url'] = preview_file_url
hash['cropped_url'] = crop_file_url
hash[:md5] = md5
hash[:preview_url] = preview_file_url
hash[:cropped_url] = crop_file_url
end
hash
end

View File

@ -1,3 +1,3 @@
<script>
var ___deferred_posts = <%= raw DeferredPosts.dump.to_json %>;
window.___deferred_posts = <%= raw DeferredPosts.dump.to_json %>;
</script>