Commit Graph

20 Commits

Author SHA1 Message Date
evazion
4ad554e28b uploads: show videos and ugoiras on upload page.
* On the upload page, show the video when uploading a video or ugoira.
* On the upload page, show the filesize and resolution beneath the
  image, instead of above it.
* On the media asset show page, show the full video or ugoira instead of
  just the thumbnail.
2022-01-30 22:39:54 -06:00
evazion
21dcf53dcb uploads: show similar images for disk uploads.
Fix the upload page so that it shows similar images (IQDB matches) for
files uploaded from your computer. Before this only worked for files
uploaded from a source.
2022-01-28 21:07:06 -06:00
evazion
abdab7a0a8 uploads: rework upload process.
Rework the upload process so that files are saved to Danbooru first
before the user starts tagging the upload.

The main user-visible change is that you have to select the file first
before you can start tagging it. Saving the file first lets us fix a
number of problems:

* We can check for dupes before the user tags the upload.
* We can perform dupe checks and show preview images for users not using the bookmarklet.
* We can show preview images without having to proxy images through Danbooru.
* We can show previews of videos and ugoira files.
* We can reliably show the filesize and resolution of the image.
* We can let the user save files to upload later.
* We can get rid of a lot of spaghetti code related to preprocessing
  uploads. This was the cause of most weird "md5 confirmation doesn't
  match md5" errors.

(Not all of these are implemented yet.)

Internally, uploading is now a two-step process: first we create an upload
object, then we create a post from the upload. This is how it works:

* The user goes to /uploads/new and chooses a file or pastes an URL into
  the file upload component.
* The file upload component calls `POST /uploads` to create an upload.
* `POST /uploads` immediately returns a new upload object in the `pending` state.
* Danbooru starts processing the upload in a background job (downloading,
  resizing, and transferring the image to the image servers).
* The file upload component polls `/uploads/$id.json`, checking the
  upload `status` until it returns `completed` or `error`.
* When the upload status is `completed`, the user is redirected to /uploads/$id.
* On the /uploads/$id page, the user can tag the upload and submit it.
* The upload form calls `POST /posts` to create a new post from the upload.
* The user is redirected to the new post.

This is the data model:

* An upload represents a set of files uploaded to Danbooru by a user.
  Uploaded files don't have to belong to a post. An upload has an
  uploader, a status (pending, processing, completed, or error), a
  source (unless uploading from a file), and a list of media assets
  (image or video files).

* There is a has-and-belongs-to-many relationship between uploads and
  media assets. An upload can have many media assets, and a media asset
  can belong to multiple uploads. Uploads are joined to media assets
  through a upload_media_assets table.

  An upload could potentially have multiple media assets if it's a Pixiv
  or Twitter gallery. This is not yet implemented (at the moment all
  uploads have one media asset).

  A media asset can belong to multiple uploads if multiple people try
  to upload the same file, or if the same user tries to upload the same
  file more than once.

New features:

* On the upload page, you can press Ctrl+V to paste an URL and immediately upload it.
* You can save files for upload later. Your saved files are at /uploads.

Fixes:

* Improved error messages when uploading invalid files, bad URLs, and
  when forgetting the rating.
2022-01-28 04:13:22 -06:00
evazion
206a4b5de5 docker: avoid rebuilding CSS/JS assets on every commit.
Restructure the Dockerfile and the CSS/JS files so that we only rebuild
the CSS and JS when they change, not on every commit.

Before it took several minutes to rebuild the Docker image after every
commit, even when the JS/CSS files didn't change. This also made pulling
images slower.

This requires refactoring the CSS and JS to not use embedded Ruby (ERB)
templates, since this made the CSS and JS dependent on the Ruby
codebase, which is why we had to rebuild the assets after every Ruby
change.
2021-10-13 02:48:30 -05:00
evazion
94d2bc72f2 uploads: move dropzone code to uploads.js. 2019-09-22 22:59:33 -05:00
Albert Yi
a57d4a9558 fixes #2680 2018-11-12 16:29:44 -08:00
evazion
a20eba9ef7 Fix #3983: Uploads: NoMethodError - undefined method `>=' for nil:NilClass
* Rename Upload#download_for_upload to #get_file_for_upload.

* Fix #get_file_for_upload to raise error if no file or source url was given.

* Fix javascript upload validation to disallow submitting form if file is
  not present and the source is not an url.
2018-11-11 17:12:39 -06:00
evazion
33ca028927 related tags: fix initialization logic for recent/frequent/translated/artist columns.
Initialize the recent tags, frequent tags, translated tags, and artist
tags columns only once, when the related tags section is first shown.

The related tags section is shown automatically when the 'Edit' tab is
opened, or by default on the uploads page.

This fixes the /related_tags.js and /source.js calls being triggered
every time the tag edit dialog box or the 'Edit' tab was opened.
2018-10-15 18:42:04 -05:00
evazion
091c4c97a8 Fix #3895: 'Related tags' not appearing automatically on uploads page. 2018-09-12 19:26:59 -05:00
evazion
056fe365f2 Render "Fetch source data" box html server-side.
Instead of calling /sources.json and rendering the "Fetch source data"
box client-side in Javascript, call /sources.js so we can render the
html server-side.
2018-09-08 15:42:16 -05:00
evazion
3bed5f3cf9 Fix #3867: Add namespaces to all Javascript events. 2018-09-04 12:26:18 -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
692c3ddac8 ignore #post_source when autorunning the iqdb search (#3851) 2018-08-29 16:20:36 -07:00
Albert Yi
ed050e74b9 update iqdb source in uploads js (#3851) 2018-08-29 15:15:03 -07:00
evazion
cd11ae6008 upload page: fix fetch source data when not using bookmarklet.
* #upload_referer_url no longer exists, just using #ref works.
* #upload_source defaults to params[:url], so using it instead of #url still works.

ref: https://github.com/r888888888/danbooru/issues/3850#issuecomment-417116385
2018-08-29 16:54:03 -05:00
Albert Yi
ab220f295c search for source/referer in additional elements 2018-08-29 14:04:10 -07:00
evazion
bbaadda1e3 Convert keyboard shortcuts to use data-shortcut. 2018-08-12 12:09:58 -05:00
evazion
f72b32b27b Fix eslint warnings. 2018-08-05 18:30:25 -05:00
evazion
8589d514dc Fix #3799: Fetch source data link is broken 2018-08-04 10:28:14 -05:00
Albert Yi
6fa0ae2cf1 Migrate assets to use Webpacker 2018-07-27 15:24:05 -07:00