Commit Graph

82 Commits

Author SHA1 Message Date
evazion
07e23204b6 rubocop: fix various Rubocop warnings. 2021-06-17 04:17:53 -05:00
evazion
29a5f7dfc8 image proxy: replace HTTParty with Danbooru::Http. 2020-06-21 15:11:56 -05:00
evazion
1e0f6f730a uploads: only let users see their own uploads on /uploads listing. 2020-04-06 14:13:22 -05:00
evazion
7f742242e4 pundit: convert uploads to pundit. 2020-03-20 18:03:01 -05:00
evazion
2564e885c8 controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
2020-02-15 06:17:22 -06:00
evazion
8649ff6dbe API: remove various associated fields included by default.
Remove various associated fields that were included by default on
certain endpoints. API users can use the only param to include the
full association if they need these fields.

* /artists.json: urls.
* /artist_urls.json: artist.
* /comments.json: creator_name and updater_name.
* /notes.json: creator_name.
* /pools.json: creator_name.
* /posts.json: uploader_name, children_ids, pixiv_ugoira_frame_data.
* /post_appeals.json: is_resolved.
* /post_versions.json: updater_name.
* /uploads.json: uploader_name.
2020-02-15 06:17:11 -06:00
BrokenEagle
63b3503bfc Add ability to use nested only parameter
- The only string works much the same as before with its comma separation
-- Nested includes are indicated with square brackets "[ ]"
-- The nested include is the value immediately preceding the square brackets
-- The only string is the comma separated string inside those brackets
- Default includes are split between format types when necessary
-- This prevents unnecessary includes from being added on page load
- Available includes are those items which are allowed to be accessible to the user
-- Some aren't because they are sensitive, such as the creator of a flag
-- Some aren't because the number of associated items is too large
- The amount of times the same model can be included to prevent recursions
-- One exception is the root model may include the same model once
--- e.g. the user model can include the inviter which is also the user model
-- Another exception is if the include is a has_many association
--- e.g. artist urls can include the artist, and then artist urls again
2020-02-12 23:58:53 +00:00
evazion
c7185724d5 controllers: set @current_item globally in respond_with. 2020-01-31 02:43:08 -06:00
evazion
588280c8cc views: add embed_wiki helper.
Also remove options to configure names of wiki notice pages. These names
generally don't need to be changed and we already hardcode links to wiki
pages in other places anyway.
2020-01-27 17:14:38 -06:00
BrokenEagle
3a422b26df Removed unneeded commentary tag checkboxes
As per the discussion on GitHub, these will be handled instead
by the existing mechanisms of related and frequent tags.
2020-01-16 21:40:14 +00:00
BrokenEagle
82b621d87d Added upload commentary enhancements
- Can now translate commentary from the upload page
- Can now add commentary tags with a checkbox
2020-01-14 23:59:27 +00:00
BrokenEagle
223a6df5d8 Add API data to show/index views 2020-01-04 22:02:44 +00:00
evazion
6424a4de74 Do full page counts on small index pages.
Normally we skip doing page counts on index pages when there aren't any
search filters. This is on the assumption that most index pages have
more than 1000 pages (20,000 results), so it's not worth counting them
exactly. This isn't always true, so here we turn on full counts on
certain index pages known to be small.
2019-10-28 15:18:54 -05:00
evazion
a5ab25d0ba pagination: avoid counting pages outside searches.
Replace this common pattern in controllers:

    @tags = Tag.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search])

with this:

    @tags = Tag.paginated_search(params)

`search_count` is used to skip doing a full page count when we're not
doing a search (on the assumption that the number of results will be
high when not constrained by a search). We didn't do this consistently
though. Refactor to do this in every controller.
2019-10-07 22:02:03 -05:00
evazion
3f7e05316d api: refactor default options for xml responses.
In xml responses, if the result is an empty array we want the response
to look like this:

   <posts type="array"/>

not like this (the default):

   <nil-classes type="array"/>

This refactors controllers so that this is done automatically instead of
having to manually call `@things.to_xml(root: "things")` everywhere. We
do this by overriding the behavior of `respond_with` in `ApplicationResponder`
to set the `root` option by default in xml responses.
2019-09-08 15:32:31 -05:00
evazion
d536f75505 related tags: eliminate recent_tags cookie (#3955). 2018-10-12 21:20:06 -05:00
evazion
950fcdb7b2 uploads: add new source:<url> dupe check (fix #3873)
* On the /uploads/new page, instead of just showing a "This post has
probably already been uploaded" message, show the actual thumbnails of
posts having the same source as what the user is trying to upload.

* Move the iqdb results section up top, beside the related posts section.
2018-09-06 20:43:20 -05:00
evazion
07c0695ac1 uploads: remove "this post was probably already uploaded" dupe check.
Also makes it so that using the bookmarklet always triggers async upload
preprocessing. Before it was only triggered when the source passed a
dupe check, but that check was inaccurate (#3873).
2018-09-06 20:43:04 -05:00
Albert Yi
64c3bc18a7 rename ref and url fields to upload_source and upload_referer_url 2018-08-29 16:46:04 -07:00
Albert Yi
762dc3da24 Refactor sources 2018-08-24 12:10:51 -07:00
Albert Yi
0e6c358701 add drag and drop file uploads w/async processing
[skip ci]
2018-06-14 17:52:41 -07:00
Albert Yi
fdd7582fb0 add support for upload preprocessing 2018-06-14 17:52:41 -07:00
evazion
c9acbbdf9e uploads: revamp /uploads listing UI (#3657).
* Add thumbnails.
* Colorize tags.
* Rearrange columns.
* Add rating/source/size/dimensions info.
* Add "»" search drilldown links.
2018-04-20 15:52:09 -05:00
evazion
8083c7daae uploads: fix batch upload page to work without bookmarklet.
* Add a form to the /uploads/batch page so that it can be used without
  the bookmarklet.

* Fix an exception when no url is given.
2018-04-20 15:51:56 -05:00
evazion
bca483cefd Fix #3628: Retry button is displayed for failed uploads that cannot succeed even if retried 2018-04-12 22:14:06 -05:00
r888888888
abce4d2551 Raise error on unpermitted params.
Fail loudly if we forget to whitelist a param instead of silently
ignoring it.

misc models: convert to strong params.

artist commentaries: convert to strong params.

* Disallow changing or setting post_id to a nonexistent post.

artists: convert to strong params.

* Disallow setting `is_banned` in create/update actions. Changing it
  this way instead of with the ban/unban actions would leave the artist in
  a partially banned state.

bans: convert to strong params.

* Disallow changing the user_id after the ban has been created.

comments: convert to strong params.

favorite groups: convert to strong params.

news updates: convert to strong params.

post appeals: convert to strong params.

post flags: convert to strong params.

* Disallow users from setting the `is_deleted` / `is_resolved` flags.

ip bans: convert to strong params.

user feedbacks: convert to strong params.

* Disallow users from setting `disable_dmail_notification` when creating feedbacks.
* Disallow changing the user_id after the feedback has been created.

notes: convert to strong params.

wiki pages: convert to strong params.

* Also fix non-Builders being able to delete wiki pages.

saved searches: convert to strong params.

pools: convert to strong params.

* Disallow setting `post_count` or `is_deleted` in create/update actions.

janitor trials: convert to strong params.

post disapprovals: convert to strong params.

* Factor out quick-mod bar to shared partial.
* Fix quick-mod bar to use `Post#is_approvable?` to determine visibility
  of Approve button.

dmail filters: convert to strong params.

password resets: convert to strong params.

user name change requests: convert to strong params.

posts: convert to strong params.

users: convert to strong params.

* Disallow setting password_hash, last_logged_in_at, last_forum_read_at,
  has_mail, and dmail_filter_attributes[user_id].

* Remove initialize_default_image_size (dead code).

uploads: convert to strong params.

* Remove `initialize_status` because status already defaults to pending
  in the database.

tag aliases/implications: convert to strong params.

tags: convert to strong params.

forum posts: convert to strong params.

* Disallow changing the topic_id after creating the post.
* Disallow setting is_deleted (destroy/undelete actions should be used instead).
* Remove is_sticky / is_locked (nonexistent attributes).

forum topics: convert to strong params.

* merges https://github.com/evazion/danbooru/tree/wip-rails-5.1
* lock pg gem to 0.21 (1.0.0 is incompatible with rails 5.1.4)
* switch to factorybot and change all references

Co-authored-by: r888888888 <r888888888@gmail.com>
Co-authored-by: evazion <noizave@gmail.com>

add diffs
2018-04-06 18:09:57 -07:00
evazion
c76463f34d uploads: use storage manager to distribute files.
Refactors the upload process to pass around temp files, rather than
passing around file paths and directly writing output to the local
filesystem. This way we can pass the storage manager the preview /
sample / original temp files, so it can deal with storage itself.

* Change Download::File#download! to return a temp file.

* Change DanbooruImageResizer and PixivUgoiraConverter to accept/return
  temp files instead of file paths.

* Change Upload#generate_resizes to return temp files for previews and samples.

* Change Upload#generate_resizes to generate ugoira .webm samples
  synchronously instead of asynchronously.
2018-03-20 19:49:06 -05:00
evazion
d4298ea493 Fix #3527: Bookmarklet timeouts for Members. 2018-02-01 17:35:20 -06:00
BrokenEagle
d829ab3a00 Move all order logic to models
- Have a default order for each model
-- The overall default is ID DESC
- Allow for custom orderings
-- When comma-separated IDs are used
2018-01-29 11:42:53 -08:00
evazion
857fa24697 Fix #3473: Validation warnings for no artist/copyright are still shown on upload failure. 2017-12-28 18:19:28 -06:00
evazion
07a4bdcb21 posts: display validation warnings in flash notice. 2017-11-25 17:03:32 -06:00
evazion
8125d8e796 Set the default User-Agent sent for outgoing http requests.
* Add a `Danbooru.config.http_headers` config option.

* Refactor various places to use this option instead of setting the user
  agent manually.
2017-07-19 20:25:27 -05:00
evazion
ecf5040160 /uploads: make available to anonymous users. 2017-07-06 19:14:17 -05:00
evazion
b2f62482a1 Remove artist commentary handling from download rewrite strategies. 2017-05-10 18:01:51 -05:00
evazion
40092f21ba Remove redundant rescue_from calls.
These are redundant because ApplicationController rescues these exceptions already.
2017-02-25 02:18:16 -06:00
evazion
5909e8501c Pull upload notice, bookmarklet notice from help:upload_notice wiki page. 2016-11-21 01:17:15 -06:00
Toks
8473cfa109 Remove nils from recent tags 2015-11-20 19:55:21 -05:00
Toks
7c7f92d1b2 Fix errors saving recent tags not displaying correctly 2015-11-08 15:07:01 -05:00
r888888888
d7b0d2a7e5 fixes #2509: &#13; in artist commentary 2015-09-03 13:41:21 -07:00
r888888888
d5cadebd88 fixes #2507: uninitialized constant UploadsController::HTML 2015-08-24 17:35:46 -07:00
r888888888
a10f30077b fixes #2433: Automatic commentary copier doesn't account for html 2015-07-15 13:30:42 -07:00
Toks
0a5f1b53ba #2426 refactor to use predetermined referer 2015-07-05 11:02:01 -04:00
Toks
b1b31d7387 fixes #2426 2015-07-04 16:31:34 -04:00
r888888888
fd74f860ee potential fix for #2404 2015-06-10 17:28:51 -07:00
r888888888
2ddc93723c fixes #2327 2015-06-02 19:20:09 -07:00
Toks
069648556b #2366 double check that normalized_url is not nil 2015-04-06 18:39:24 -04:00
r888888888
2d266fc0b6 uploads/batch now supports pixiv 2015-03-15 13:56:16 -07:00
r888888888
f12fb40e3e implements #2350 2015-02-20 20:04:23 -08:00
r888888888
e57cad7b0a add new uploads/batch endpoint for handling twitter galleries 2015-02-09 16:29:00 -08:00
r888888888
48b4d027f6 #2328 fix source lookup on twitter uploads 2014-12-17 14:21:00 -08:00