Commit Graph

53 Commits

Author SHA1 Message Date
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
54dbf1a436 Update Ruby gems and Yarn packages. 2022-01-17 10:49:04 -06:00
evazion
fd2db2ff23 Update Ruby gems and Yarn packages. 2022-01-10 11:32:59 -06:00
evazion
d900e15dcc css: fix stylelint complaints. 2022-01-08 12:30:21 -06:00
evazion
3bf65d1378 css: update browserslist requirement.
Update the minimum browser requirement from browsers released since
2012, to browsers released in the last 5 years.

This means PostCSS won't prefix CSS properties like `flex` or other
properties supported by browsers since 2017. Babel also won't transpile
Javascript syntax that has been supported by browsers since 2017.
2022-01-08 12:09:25 -06:00
evazion
bb60a59001 css: remove postcss-flexbugs-fixes plugin.
Remove a PostCSS plugin used to workaround bugs in the `flex` CSS
property. Most of these bugs are no longer relevant and only affected
ancient browsers like IE 10 or 11.

https://github.com/philipwalton/flexbugs
2022-01-08 11:54:45 -06:00
evazion
0e778f0972 Update Ruby gems and Yarn packages. 2021-12-28 09:47:34 -06:00
evazion
45dbc7582c Update Ruby gems and Yarn packages. 2021-12-08 03:01:54 -06:00
evazion
a58aa8efa7 Update Ruby gems and Yarn packages. 2021-10-21 03:27:59 -05: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
4b15e56909 Update Ruby gems and Yarn packages. 2021-10-12 03:00:24 -05:00
evazion
33f3a12dd1 Update Ruby gems and Yarn packages. 2021-09-30 08:24:51 -05:00
evazion
9552b41c0a Update Ruby gems and Yarn packages. 2021-09-14 05:39:18 -05:00
evazion
38edbb0512 Update Yarn packages. 2021-08-28 04:53:33 -05:00
evazion
c8d7f94d7e Update Ruffle version. 2021-08-21 04:01:24 -05:00
Seedgou
35c9eff5bc fix ruffle-mirror version 2021-08-15 02:16:57 -05:00
evazion
9b0fcec7d0 Update Ruby gems and Yarn packages. 2021-04-06 15:51:01 -05:00
evazion
d58a0bf1e4 Fix #4781: Danbooru Javascript object is broken.
Downgrade Webpack from 5.28.0 to 5.26.3. Breakage was introduced at
5.27.0. It's unclear if this is a regression of issue 12742 in Webpack
or if we're doing something else wrong.

hxxps://github.com-webpack-webpack-issues-12742
hxxps://github.com-webpack-webpack-issues-12851
2021-04-01 03:10:44 -05:00
evazion
55980c6fbf Add Ruffle support for Flash files.
Allow viewing Flash posts with the Ruffle emulator.

Known issues:

* Many flash files aren't fully supported.
* In development it sometimes spazzes out and starts triggering random
  keyboard shortcuts when you press any key. This doesn't happen with
  the browser extension.
* We have to put the .wasm file in the public/packs/js directory because
  Ruffle is hardcoded to search for it there.
* If you're running Nginx, you need to make sure you're serving the
  right MIME type for .wasm files or it won't work.
* We're using Some Random Guy's unofficial NPM package for Ruffle, since the
  Ruffle project doesn't publish an official package themselves. We
  should build our own package.

References:

* https://github.com/ruffle-rs/ruffle
* https://github.com/ruffle-rs/ruffle/wiki/Using-Ruffle#configure-webassembly-mime-type
* https://www.npmjs.com/package/ruffle-mirror
2021-03-31 20:20:22 -05:00
evazion
340eeec023 Update Ruby gems and Yarn packages. 2021-02-28 17:48:30 -06:00
evazion
b2a423af64 Fix #4731: Tag counter in edit boxes should only count unique tags, not repeated.
Just use the `uniq` function from lodash. Adds ~1kb to the build.

Also rename `Utility.regexp_split` to `Utility.splitWords`.
2021-02-23 19:00:58 -06:00
evazion
f42fe5f1f7 Upgrade font packages.
The `typefaces` project has been deprecated in favor of `fontsource`.

https://github.com/KyleAMathews/typefaces
https://github.com/fontsource/fontsource
2021-02-13 18:51:51 -06:00
evazion
db8991babf Update ruby gems and yarn packages. 2021-02-13 18:22:28 -06:00
evazion
3f6e7ff6b5 Fix #4701: Odd behavior on older versions of Chrome.
Regression caused by the upgrade to Webpacker 6.0 in 90cd3293e. This
caused various Javascript errors in old versions of Chrome, which
somehow resulted in the keyboard shortcut for visiting the next page
being triggered when you pressed any key.

Specifically, the mobx library (used by the TagCounter component) called
`Object.entries`, which isn't available in Chrome 49, and for some
unknown reason this triggered the buggy shortcut behavior.

`Object.entries` is supposed to be automatically polyfilled by Babel to
support old browsers, but something changed in Webpacker 6 that broke
this and I couldn't get it working again. The probable cause is that
Webpacker 6 no longer transpiles code inside ./node_modules by default,
which means that any libraries we use that use new Javascript features
won't get transpiled down to support old browsers, but even after fixing
that it still didn't work. The workaround is to just drop mobx and
preact entirely to avoid the issue.
2021-02-07 05:53:32 -06:00
evazion
90cd3293eb Upgrade to Webpacker 6.0. 2021-01-28 00:22:49 -06:00
evazion
2eeee446a5 js: upgrade to MobX 6.0. 2021-01-27 17:46:17 -06:00
evazion
b3a4c7aa43 posts: rewrite tag counter widget in React.
Rewrite the tag counter widget (the one above the tag edit box) to use
React. This is a trial run for using React elsewhere.

We actually use Preact instead of React because it's lighter weight.
We use Mobx for state management because it's cleaner than React's
setState or useState.

This incidentally fixes a couple bugs:

* The tag counter wasn't updated when deleting tags with backspace
* The tag counter wasn't updated when pasting in new tags.
2020-08-02 16:48:45 -05:00
evazion
7bfea5cd19 js: drop stupidtable plugin.
This was only used on the saved search index. It let you click on column
headers to sort the table by that column. This doesn't make sense now
that saved searches are paginated.
2020-07-08 11:31:45 -05:00
evazion
57dcd9ee1a Remove unused gems and yarn packages. 2020-06-30 23:44:03 -05:00
evazion
1760d1fc73 js: upgrade jquery to 3.5.1.
Changelog:

* https://blog.jquery.com/2020/05/04/jquery-3-5-1-released-fixing-a-regression/
* https://blog.jquery.com/2020/04/10/jquery-3-5-0-released/
2020-06-30 23:42:37 -05:00
evazion
efe5111a9e js: bundle jQuery with Webpack.
Include jQuery in our Webpack bundle instead of loading it from CDNJS.
This means we no longer load any Javascript libraries from third party
sites.
2020-06-30 23:41:47 -05:00
evazion
94490eb57f Fix #4492: Switch from qtip2 to tippy.js. 2020-06-30 22:40:40 -05:00
evazion
ae7fc7d1bc Update eslint to 7.0, add babel-eslint plugin.
Add babel-eslint plugin so that eslint can recognize optional chaining
syntax (a?.b).
2020-06-19 02:25:28 -05:00
BrokenEagle
8cab65367c Added mono font 2020-05-25 19:15:35 +00:00
evazion
127bd9866d Update ruby gems and yarn packages. 2020-05-04 02:34:42 -05:00
evazion
27f10d53d6 Update ruby gems and yarn packages. 2020-03-23 01:48:59 -05:00
evazion
1385e60f8c Update ruby gems and yarn packages. 2020-02-16 13:08:23 -06:00
evazion
796efccbf4 Update ruby gems and yarn packages. 2020-01-12 13:13:03 -06:00
evazion
9f4ac4c96a js: replace jquery-ujs with @rails/ujs. 2020-01-09 22:15:18 -06:00
evazion
f73bd03576 Update yarn packages. 2019-12-13 19:06:40 -06:00
evazion
b43008a506 notes: add multiple new fonts (#4212).
Add the following fonts:

* Comic (Comic Relief)
* Slab Sans (Anton)
* Slab Serif (Rokkitt)
* Formal Serif (Lora)
* Formal Cursive (Petit Formal Script)
* Print (Kalam)
* Hand (Indie Flower)
* Narrow (Archivo Narrow)
* Blackletter (Unifraktur Maguntia)

Add the following font aliases:

* Comic Sans MS is aliased to Comic Relief.
* Arial Narrow is aliased to Archivo Narrow.
* Rockwell is aliased to Rokkitt.
* Impact is aliased to Anton.
2019-11-26 01:27:41 -06:00
evazion
fedb525305 notes: add fallback font for comic sans (#4212). 2019-11-16 22:43:16 -06:00
evazion
103742eb6c Fix #4058: FontAwesome CDN is slow/blocking.
Switch to the free self-hosted version of FontAwesome. We're not using
any Pro icons, so the Pro version isn't necessary.
2019-10-22 12:02:26 -05:00
evazion
60eaa99784 css: add stylelint. 2019-10-02 01:52:24 -05:00
evazion
f6d63b6843 Fix broken layouts in old browsers that lack flexbox support.
Very old browsers (in particular, Firefox 16 and iOS 8.4 Safari) don't
support flexbox without prefixes, which breaks sidebar and comment
layouts. Extend the browserlist config so that autoprefixer generates
flexbox prefixes for these browsers.
2019-09-30 16:40:56 -05:00
evazion
f2937e3d27 js: update yarn packages. 2019-08-18 11:24:42 -05:00
evazion
d812020030 js: migrate stupidtable and jquery-hotkeys to yarn. 2019-08-14 01:46:43 -05:00
evazion
fccb6cda27 js: migrate dropzone to yarn.
Also fixes a bug where sometimes the dropzone widget didn't work because
of late loading caused by the `<script async>` tag.
2019-08-14 01:46:43 -05:00
evazion
504f785edc Fix #4115: Upgrade to webpack 4.x.
https://github.com/rails/webpacker/blob/master/docs/v4-upgrade.md
2019-07-31 20:17:14 -05:00
Albert Yi
0c791a1257 upgrade webpack-dev-server 2019-01-30 14:05:33 -08:00