Commit Graph
100 Commits
Author SHA1 Message Date
evazion e8b9361226 notes: display error message when note saving fails. 2017-04-28 21:37:14 -05:00
evazion a3ecfdb79d notes: disallow blank note bodies. 2017-04-28 19:34:27 -05:00
evazion ec895d6412 /artists: add URL/Creator/Active/Banned/Has Tag fields to search form. 2017-04-26 14:08:18 -05:00
evazion b61fdc2c6b /artists: convert search form to simple form. 2017-04-26 14:08:18 -05:00
evazion d1188d8184 /artists: add search params: has_tag, name/other_names/group_name/any_name/url_matches. 2017-04-26 14:08:18 -05:00
evazion 59a179fa15 /posts: add shift+F to unfavorite hotkey. 2017-04-25 01:50:14 -05:00
evazion 9a0bc6802b /post_appeals: add blank option to Resolved dropdown. 2017-04-24 22:45:02 -05:00
evazion 146dc116d6 /posts: remove tag subscriptions from navbar. 2017-04-24 21:44:40 -05:00
evazion 54db229094 comment_test.rb: add quote-stripping test. 2017-04-24 21:15:47 -05:00
evazion c586a66e1f dtext: recognize [QUOTE] tags when quoting comments, forum_posts.
Fixes a bug with capitalized [QUOTE] tags not being handled properly
when quoting comments or forum posts.
2017-04-24 21:15:47 -05:00
evazion 869f1610fc comments: use server-side quote-stripping instead of reimplementing in js. 2017-04-24 21:15:47 -05:00
evazion 18424531fa Merge mentions quote-stripping code into DText quote-stripping code. 2017-04-24 21:15:42 -05:00
evazion 8404064854 related_tag_calculator.rb: fix memcache lookup in inner loop.
Remove the category constraint option from RelatedTagCalculator.calculate_from_posts.
It slows things down and isn't used.

This method is used to calculate the related tags sidebar during
searches for single metatags. Using Tag.category_for in the inner loop
caused a memcache call on every iteration. At 100 posts per page and
20-30 tags per post, this led to up to 2000-3000 total memcache calls,
which significantly slowed pageloads.
2017-04-23 17:10:20 -05:00
evazion 30872ebb41 Fix #2990: Wiki Autocomplete Misses On Certain Meta-wikis
/wiki_pages?search[order]=post_count didn't include wiki pages that
didn't belong to a tag. This was due to doing an inner join on the tags
table instead of a left outer join.
2017-04-23 16:55:15 -05:00
evazion 808fe0411a /notes, /note_versions: fix N+1 queries on note creators, updaters. 2017-04-23 14:59:36 -05:00
evazion 989917cb07 /notes, /note_versions: use numbered paginator. 2017-04-23 14:59:36 -05:00
evazion e6d1842545 /notes: default to listing notes, not posts. Remove group_by=post.
The posts listing is replaced by a link to order:note.
2017-04-23 14:59:36 -05:00
evazion 4631262374 Fix broken tag autocomplete on multiple pages.
Mark all tag <input>s with a `data-autocomplete` attribute, instead of
hardcoding a list of html IDs to autocomplete in javascript.

This way should be less error prone. It fixes autocomplete in several places:

* Autocomplete for the search box on /posts didn't work in the
  responsive layout. This was because /posts has two search boxes that
  both have the id `tags`: one in the normal sidebar, and one in the
  responsive tag list. $("#tags") only initialized autocomplete on the
  first one.

* Autocomplete didn't work on the aliases or implications pages. This
  was due to selecting the wrong html ids.
2017-04-22 15:24:03 -05:00
evazion f403763d8b /tag_implications: convert to simple form. 2017-04-22 15:23:14 -05:00
evazion 738c14a8a3 /tag_aliases: convert to simple form. 2017-04-22 15:23:14 -05:00
evazion 2db3af56dd /tags: convert search form to simple form. 2017-04-22 15:23:14 -05:00
evazion 0ed0fb095b /notes/search: convert to simple form. 2017-04-22 13:04:04 -05:00
evazion d8fb4399cf /artist_commentaries/search: convert to simple form. 2017-04-22 13:04:04 -05:00
evazion 0b2493b2dd tag subscriptions: fix broken saved search migrations. 2017-04-21 22:48:52 -05:00
evazion f1552539f7 notes: allow <ruby> tags for marking up furigana. 2017-04-21 14:31:05 -05:00
evazion 5f9c423542 upload.rb: detect mp4s with an ftyp of avc1. 2017-04-20 23:08:34 -05:00
evazion fce8dcc97d /users: fix self-xss in favorite tags. 2017-04-20 20:33:56 -05:00
evazion 5303d1052f /posts: fix saved search dropdown for post show page. 2017-04-20 19:05:54 -05:00
evazion 94e548cfe1 /bans: add test for searching bans. 2017-04-19 17:56:26 -05:00
evazion f6fff16e75 /bans: avoid N+1 queries for user, banner.
Avoids an N+1 issue when rendering users with link_to_user.
2017-04-19 17:56:26 -05:00
evazion 9bf1c89357 /bans: add search form. 2017-04-19 17:56:25 -05:00
evazion 06f2ed685e /bans: add reason_matches, expired, order search params. 2017-04-19 17:56:25 -05:00
evazion 84c075e4bf /bans: add "»" links for narrowing search by user. 2017-04-19 17:56:25 -05:00
evazion 198b6db507 /bans: replace Expires column with Duration. 2017-04-19 17:56:25 -05:00
evazion 1bc4eda12b /bans: add Banner, Banned at columns. 2017-04-19 17:56:25 -05:00
evazion 715dcc491b /bans: size columns to avoid unnecessary wrapping.
Sizes columns such that they automatically shrink to fit. This fixes
problems with usernames and dates wrapping in the middle.
2017-04-19 17:56:25 -05:00
evazion 40fe0f595f /bans: color code expired/unexpired bans. 2017-04-19 17:56:24 -05:00
evazion 9816676bfd structure.sql: remove bank_balances, bank_transactions. 2017-04-19 17:08:28 -05:00
evazion fb0a8e8600 db: add reason index on post_flags, post_appeals. 2017-04-16 21:15:23 -05:00
evazion cf9b67efb7 db/structure.sql: add index_pools_on_name_trgm migration. 2017-04-16 21:15:23 -05:00
evazion 54b4a2e0c5 /post_{flags,appeals}: default to fulltext search for reason field. 2017-04-16 21:15:23 -05:00
evazion c0e5c400a7 tests: fix tests for Rails.cache. 2017-04-16 16:48:36 -05:00
evazion 192190a313 initializers/z_dalli.rb: initialize Rails.cache. 2017-04-16 16:48:36 -05:00
evazion 904abc2787 cache.rb: implement Cache in terms of Rails.cache. 2017-04-16 16:48:35 -05:00
evazion 941bcff743 cache.rb: remove unused incr, decr methods. 2017-04-16 16:48:35 -05:00
evazion 87b295b632 Fix exception on /post_flags/new, /post_appeals/new. 2017-04-15 23:15:17 -05:00
evazion b68cb174f5 tests: fix pixiv tests to use https://i.pixiv.net. 2017-04-15 23:14:41 -05:00
evazion 9b53d32b4c post_archive_test.rb: exercise pool metatag not saving bug (#2972). 2017-04-14 13:49:54 -05:00
evazion 18a2b2a221 dtext_field: use the field name as the label, not "Body".
For flags and appeals, the reason field should be labeled Reason, not Body.
2017-04-13 15:17:55 -05:00
evazion c90614272a /posts/:id - add dtext preview to flag/appeal dialogs. 2017-04-13 15:17:55 -05:00
evazion 1b572c592c wikis: disallow renaming unless tag is empty (fix #2964). 2017-04-10 16:40:42 -05:00
evazion 8d45bb6d52 /post_{flags,appeals}: allow searching by tags. 2017-04-07 19:37:26 -05:00
evazion f5e22ea235 /post_{flags,appeals}: convert search forms to simple form. 2017-04-07 19:37:26 -05:00
evazion 652e251040 /post_{flags,appeals}: add uploader, approver, flag/appeal count columns.
Also include '»' links next to uploader/approver names for drilling down
the search by a given user.
2017-04-07 19:37:26 -05:00
evazion 3ae8cc5586 post_flags.rb: add 'rejected' and 'deleted' categories.
Includes a category field in /post_flags.json.

Adds 'rejected' and 'deleted' search categories. Categories:

* unapproved - deleted after going unapproved in first three days
* rejected   - deleted after being manually flagged
* deleted    - either of the above
* banned     - artist requested removal
* normal     - none of the above (a "normal" manual flag)
2017-04-07 19:37:26 -05:00
evazion b9693827c3 /wiki_pages: sort autocomplete by post count.
* Add search[order]=post_count param to /wiki_pages.
* Make autocomplete do a prefix match ordered by post count, so that it
  works the same way that tag autocomplete does elsewhere.
2017-04-07 18:25:31 -05:00
evazion 6b462c865e /artists: sort autocomplete by post count.
* Add search[order]=post_count param to /artists.
* Make autocomplete do a prefix match ordered by post count, so that it
  works the same way that tag autocomplete does elsewhere.
2017-04-07 18:25:31 -05:00
evazion fbba167f0c artist.rb: fix ambiguous column references.
Using `search[empty_only]=true` caused certain queries to throw an
exception due to ambiguous column references after joining on the tags
table.

Example:

    https://danbooru.donmai.us/artists?search[empty_only]=true&search[name]=hammer*

    PG::AmbiguousColumn exception raised
    ERROR: column reference "name" is ambiguous LINE 1: ...ags"."name" = "artists"."name" WHERE (true) AND ((name LIKE ... ^
    lib/danbooru/paginator/active_record_extension.rb:108:in `total_count'
    lib/danbooru/paginator/active_record_extension.rb:63:in `block in paginate_numbered'
    lib/danbooru/paginator/active_record_extension.rb:60:in `tap'
    lib/danbooru/paginator/active_record_extension.rb:60:in `paginate_numbered'
    lib/danbooru/paginator/active_record_extension.rb:15:in `paginate'
    app/controllers/artists_controller.rb:41:in `index'
2017-04-07 18:25:31 -05:00
evazion 674028588c /artists: avoid COUNT(*), avoid N+1 queries on artist urls.
* The /artists page issued a `SELECT count(*) FROM artists` because
  .paginate was missing search_count.

* /artists.json had an N+1 problem on artist urls. This slowed down
  autocomplete.
2017-04-07 18:25:30 -05:00
evazion 1a63fd6ac7 /artists: filter deleted artists from autocomplete. 2017-04-07 18:25:30 -05:00
evazion 7f2859eb00 /pools: don't filter inactive pools from autocomplete.
The inactive flag marks series pools that are finished (no more posts
will be added), not pools that are deleted. Finished series should still
be autocompleted.
2017-04-07 18:25:30 -05:00
evazion bb2f0ff795 /pools: make autocomplete use index.
`name ilike ?` doesn't use the index. Use `lower(name) like ?` instead.
2017-04-07 18:25:21 -05:00
evazion 85a39cadf0 /wiki_pages: avoid unnecessary COUNT(*).
@wiki_pages.count issues a COUNT(*), which is unnecessary when we're
just counting the ~20 @wiki_pages we've already loaded.
2017-04-07 18:10:26 -05:00
evazion fcc5521f63 db: add updated_at index on wiki pages.
The wiki pages sidebar is ordered by updated_at. The sidebar is present
on all wiki pages, so this improves load times for all wikis.
2017-04-07 18:10:26 -05:00
evazion 5f6506cbb4 /posts/1234: add confirm dialog to sidebar approve/undelete links. 2017-04-06 22:33:34 -05:00
evazion 2d2efbddfe /iqdb_queries: add api test. 2017-04-05 18:48:57 -05:00
evazion 423dd0b848 /iqdb_queries: include full data for each post in api response. 2017-04-05 18:01:16 -05:00
evazion e15f955677 /iqdb_queries: support json/xml api responses. 2017-04-05 18:01:16 -05:00
evazion c402e15cca /iqdb_queries: support both GET and POST; add GET /posts/1/similar. 2017-04-05 18:01:16 -05:00
evazion 0974ef8bd4 iqdbs: raise exception if not configured. 2017-04-05 01:17:04 -05:00
evazion d66d19f328 big query: raise exception if not configured. 2017-04-05 01:17:04 -05:00
evazion f57561118c reportbooru: raise exception if not configured. 2017-04-05 01:17:04 -05:00
evazion 08867fa84d listbooru: raise exception if not configured. 2017-04-05 01:17:04 -05:00
evazion 086b520dcc archives: raise exception if not configured. 2017-04-05 01:17:03 -05:00
evazion 3f35a9ab64 Handle failure gracefully for unconfigured services. 2017-04-05 01:17:03 -05:00
evazion c03aa79ece Post#give_favorites_to_parent: wrap in transaction.
Ensure that if anything fails then the entire favorites move will be
rolled back.
2017-04-04 20:44:05 -05:00
evazion 40feeb2411 Post#give_favorites_to_parent: fix exception (fixup 77793759)
Forgot the `belong_to :user` association in 77793759.
2017-04-04 20:42:31 -05:00
evazion 777937591e Post#give_favorites_to_parent: move hidden favs. 2017-04-03 22:36:20 -05:00
evazion 5db39f308a tests: fix post approval tests. 2017-04-03 17:18:32 -05:00
evazion 7c8135609b post_approval_test.rb: tabs to spaces. 2017-04-03 17:18:32 -05:00
evazion e6328b8d30 post_approval_test.rb: move to test/unit. 2017-04-03 17:18:32 -05:00
evazion 70a7f77a48 Post#approve!: signal errors with invalid object instead of exception. 2017-04-03 17:18:32 -05:00
evazion db0bcf08b9 Post#approve!: move approving logic to post_approval.rb. 2017-04-03 17:18:31 -05:00
evazion 258fc37bfe Post#approve!: move validation to post_approval.rb 2017-04-03 17:18:31 -05:00
evazion 4b138be6b9 Rewrite i.pximg.net manga gallery samples. 2017-04-03 17:17:22 -05:00
evazion af4708dde9 Fix typo in i.pximg.net download strategy. 2017-04-03 17:17:22 -05:00
evazion 3c89ee3199 tests: add more post/pool version creation tests.
Adds the `test_after_commit` gem too because after_commit callbacks
don't fire inside tests in rails <5.0.
2017-04-03 15:03:59 -07:00
evazion 8fff3315f2 fix #2950: don't send versions to archives if save fails. 2017-04-03 15:03:58 -07:00
evazion 1ae5b7ba2f post archives: fix N+1 problem when fetching previous version. 2017-04-03 15:03:26 -07:00
evazion 964197d403 upload tags report: fix N+1 queries issues. 2017-04-03 15:03:26 -07:00
evazion 765fbac11d /reports/upload_tags: show thumbnails instead of post ids. 2017-04-03 15:03:26 -07:00
evazion fdd8ebb1b8 /users/1234: link to upload tag changes report. 2017-04-03 15:03:26 -07:00
evazion 25b2b399cc saved searches: fix exception when searching for search:adfijoioi.
Fixes this exception:

    NoMethodError exception raised

    undefined method `empty?' for nil:NilClass
    app/logical/post_query_builder.rb:113:in `block in add_saved_search_relation'
    app/logical/post_query_builder.rb:106:in `each'
    app/logical/post_query_builder.rb:106:in `add_saved_search_relation'
    app/logical/post_query_builder.rb:237:in `build'
    app/models/post.rb:1624:in `tag_match'
    app/models/post.rb:1172:in `block in fast_count_search'
    config/initializers/active_record_extensions.rb:16:in `with_timeout'
    app/models/post.rb:1171:in `fast_count_search'
    app/models/post.rb:1162:in `fast_count'
    app/logical/post_sets/post.rb:106:in `get_post_count'
    app/logical/post_sets/post.rb:122:in `posts'
    app/controllers/posts_controller.rb:15:in `index'

caused by this failure in listbooru when you send it an empty array as the list of queries:

    Redis::CommandError - ERR wrong number of arguments for 'zunionstore' command:

    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:121:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis.rb:1932:in `block in zunionstore'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis.rb:58:in `block in synchronize'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis.rb:58:in `synchronize'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis.rb:1931:in `zunionstore'
    web/listbooru.rb:85:in `aggregate_searches'
    web/listbooru.rb:104:in `block in <main>'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1611:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1611:in `block incompile!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:975:in `block (3 levels) in route!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:994:in `route_eval'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:975:in `block (2 levels) in route!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1015:in `block inprocess_route'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1013:in `catch'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1013:in `process_route'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:973:in `block in route!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:972:in `each'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:972:in `route!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1085:in `block indispatch!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `block ininvoke'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `catch'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `invoke'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1082:in `dispatch!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:907:in `block in call!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `block ininvoke'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `catch'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `invoke'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:907:in `call!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:895:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-1.6.5/lib/rack/logger.rb:15:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-1.6.5/lib/rack/commonlogger.rb:33:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:219:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:212:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-1.6.5/lib/rack/head.rb:13:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-1.6.5/lib/rack/methodoverride.rb:22:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/show_exceptions.rb:25:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:182:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:2013:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1487:in `block incall'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1787:in `synchronize'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1487:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-1.6.5/lib/rack/handler/webrick.rb:88:in `service'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/2.4.0/webrick/httpserver.rb:140:in `service'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/2.4.0/webrick/httpserver.rb:96:in `run'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/2.4.0/webrick/server.rb:290:in `block in start_thread'
2017-04-03 15:03:26 -07:00
evazion 5f1b7f48f7 Fix exception when autotagging animated_gifs.
Fixes this exception caused by the animated_gif autotagger trying to access the
image file, which fails if the image is not hosted on the webserver.

Magick::ImageMagickError exception raised

    unable to open image `/var/www/danbooru2/releases/20170322212609/public/data/f0e32c0e2d906c4932858866346f98b5.gif': No such file or directory @ error/blob.c/OpenBlob/2712
    app/models/post.rb:177:in `ping'
    app/models/post.rb:177:in `is_animated_gif?'
    app/models/post.rb:684:in `add_automatic_tags'
    app/models/post.rb:638:in `normalize_tags'
    app/controllers/posts_controller.rb:49:in `update'
2017-03-26 18:12:13 -05:00
evazion 26e8b7144a Fix exception in h(post.source) when source is nil (fixes #2940).
Fixes this exception:

    TypeError exception raised

    no implicit conversion of nil into String
    app/presenters/presenter.rb:3:in `escapeHTML'
    app/presenters/presenter.rb:3:in `h'
    app/presenters/post_presenter.rb:91:in `data_attributes'
    app/presenters/post_presenter.rb:24:in `preview'
    app/presenters/post_set_presenters/base.rb:15:in `block in post_previews_html'
    app/presenters/post_set_presenters/base.rb:14:in `post_previews_html'
    app/views/posts/partials/index/_posts.html.erb:3:in `_app_views_posts_partials_index__posts_html_erb___2716396856929289512_70158315986180'
    app/views/posts/index.html.erb:39:in `_app_views_posts_index_html_erb__1345252938355811220_70158296799280'
    app/controllers/posts_controller.rb:16:in `index'
2017-03-25 23:43:20 -05:00
evazion 163d338874 post_vote_test.rb: add more voting tests. 2017-03-24 15:43:55 -05:00
evazion 4470828a3d post_test.rb: add tests for moving favorites. 2017-03-24 15:43:55 -05:00
evazion a5ecda2f0e post_test.rb: fix voting tests. 2017-03-24 15:43:55 -05:00
evazion 3dc854c0c8 post_vote.rb: determine vote magnitude from voter, not CurrentUser.
Bug: when moving favorites, the parent is given an upvote for each gold+
favoriter, but the magnitude of these upvotes was based on the
CurrentUser, rather than the upvoter. This meant that upvotes for
supervoter favorites weren't given correctly.

To fix this, `magnitude` is changed to use the voting `user` instead of
CurrentUser.

New problem: when setting the score, `score=` calls `magnitude`, but
`user` isn't initialized yet. So we also refactor so that

    1. `initialize_attributes` initializes `user` before setting `score`
    2. the vote direction is given by `vote`, so it's separate from `score`
    3. updating the score on the post happens in a callback instead of
       directly in `score=`.
2017-03-24 15:43:55 -05:00
evazion 07707b257a post.rb: make non-gold supervoters upvote when fav'ing a post. 2017-03-24 15:43:55 -05:00