mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Compare commits
99 Commits
Author | SHA1 | Date | |
---|---|---|---|
39973386c6 | |||
141c9fcdc9 | |||
995cd4610d | |||
f1445b9c24 | |||
8c0fa7f49e | |||
9aa59a228e | |||
e71718c50d | |||
9d6a0e0173 | |||
85d6934ae9 | |||
2b34d395eb | |||
419deca894 | |||
b853caf6f5 | |||
b0c5031001 | |||
8f275206af | |||
977cc47966 | |||
7648f479a9 | |||
7862fecbc9 | |||
049a0dc351 | |||
f44f2335da | |||
67cb12e9d9 | |||
a69bdba63f | |||
0df3ceb439 | |||
3436bc3ef8 | |||
3d122441a2 | |||
e8c93cd735 | |||
0c61e85340 | |||
d31acc5952 | |||
560a7d6839 | |||
1e65622daf | |||
1bd8af47b0 | |||
0e31e1fd14 | |||
71a4ce8764 | |||
4f497d311a | |||
01fadd8f8c | |||
d1cad99e87 | |||
c7d0ffb212 | |||
5f4674f22f | |||
119c2449cd | |||
600db78a45 | |||
5eb130b02a | |||
91decaf9fe | |||
cf1e1670c4 | |||
b68f833ce9 | |||
2be21a7213 | |||
42b7a9b94f | |||
f31f67bfec | |||
0f0e6c4e24 | |||
19eea226a6 | |||
ad87506044 | |||
3149c43b7e | |||
293b28117b | |||
5b565e3b00 | |||
e05e0e5fd2 | |||
16d04adde0 | |||
8674c8b50e | |||
0a19e7bbd0 | |||
c516030c66 | |||
2c283f3058 | |||
b829f89f1b | |||
a905410b84 | |||
724bfe5a98 | |||
84a414c779 | |||
7fa8593b0a | |||
a22fe306d1 | |||
eff0e002f2 | |||
988664117a | |||
acd989cabb | |||
997eb3de63 | |||
4bfdd4c5cb | |||
dfc65e5a7c | |||
5a152dbc0c | |||
e4f9c26776 | |||
cf1d15354d | |||
e83e1b06a1 | |||
79d7b83e39 | |||
6b042504b0 | |||
6d0bf90b47 | |||
243ab15b85 | |||
c366b608da | |||
22342a29ad | |||
9dc438c391 | |||
63ec28ddb3 | |||
02d631a65d | |||
f63d024777 | |||
514c4349e0 | |||
702ec3e6fe | |||
473f2a4ddc | |||
3c5878cb16 | |||
c21309aa35 | |||
63e8683fb8 | |||
ef0f74297f | |||
06ab98fa70 | |||
f8e91a10e8 | |||
8f230f5701 | |||
6d26b5c37a | |||
fa60b42f65 | |||
422b99ac8d | |||
ffb87f1650 | |||
bb369efa99 |
186
API.md
186
API.md
@ -36,6 +36,7 @@
|
||||
- [Updating post](#updating-post)
|
||||
- [Getting post](#getting-post)
|
||||
- [Deleting post](#deleting-post)
|
||||
- [Merging posts](#merging-posts)
|
||||
- [Rating post](#rating-post)
|
||||
- [Adding post to favorites](#adding-post-to-favorites)
|
||||
- [Removing post from favorites](#removing-post-from-favorites)
|
||||
@ -120,11 +121,59 @@ code together with JSON of following structure:
|
||||
|
||||
```json5
|
||||
{
|
||||
"name": "Name of the error, e.g. 'PostNotFoundError'",
|
||||
"title": "Generic title of error message, e.g. 'Not found'",
|
||||
"description": "Detailed description of what went wrong, e.g. 'User `rr-` not found."
|
||||
}
|
||||
```
|
||||
|
||||
List of possible error names:
|
||||
|
||||
- `MissingRequiredFileError`
|
||||
- `MissingRequiredParameterError`
|
||||
- `InvalidParameterError` (when trying to pass text when integer is expected etc.)
|
||||
- `IntegrityError` (race conditions when editing the same resource)
|
||||
- `SearchError`
|
||||
- `AuthError`
|
||||
- `PostNotFoundError`
|
||||
- `PostAlreadyFeaturedError`
|
||||
- `PostAlreadyUploadedError`
|
||||
- `InvalidPostIdError`
|
||||
- `InvalidPostSafetyError`
|
||||
- `InvalidPostSourceError`
|
||||
- `InvalidPostContentError`
|
||||
- `InvalidPostRelationError`
|
||||
- `InvalidPostNoteError`
|
||||
- `InvalidPostFlagError`
|
||||
- `InvalidFavoriteTargetError`
|
||||
- `InvalidCommentIdError`
|
||||
- `CommentNotFoundError`
|
||||
- `EmptyCommentTextError`
|
||||
- `InvalidScoreTargetError`
|
||||
- `InvalidScoreValueError`
|
||||
- `TagCategoryNotFoundError`
|
||||
- `TagCategoryAlreadyExistsError`
|
||||
- `TagCategoryIsInUseError`
|
||||
- `InvalidTagCategoryNameError`
|
||||
- `InvalidTagCategoryColorError`
|
||||
- `TagNotFoundError`
|
||||
- `TagAlreadyExistsError`
|
||||
- `TagIsInUseError`
|
||||
- `InvalidTagNameError`
|
||||
- `InvalidTagRelationError`
|
||||
- `InvalidTagCategoryError`
|
||||
- `InvalidTagDescriptionError`
|
||||
- `UserNotFoundError`
|
||||
- `UserAlreadyExistsError`
|
||||
- `InvalidUserNameError`
|
||||
- `InvalidEmailError`
|
||||
- `InvalidPasswordError`
|
||||
- `InvalidRankError`
|
||||
- `InvalidAvatarError`
|
||||
- `ProcessingError` (failed to generate thumbnail or download remote file)
|
||||
- `ValidationError` (catch all for odd validation errors)
|
||||
|
||||
|
||||
## Field selecting
|
||||
|
||||
For performance considerations, sometimes the client might want to choose the
|
||||
@ -569,10 +618,9 @@ data.
|
||||
|
||||
- **Description**
|
||||
|
||||
Removes source tag and merges all of its usages to the target tag. Source
|
||||
tag properties such as category, tag relations etc. do not get transferred
|
||||
and are discarded. The target tag effectively remains unchanged with the
|
||||
exception of the set of posts it's used in.
|
||||
Removes source tag and merges all of its usages, suggestions and
|
||||
implications to the target tag. Other tag properties such as category and
|
||||
aliases do not get transferred and are discarded.
|
||||
|
||||
## Listing tag siblings
|
||||
- **Request**
|
||||
@ -632,46 +680,47 @@ data.
|
||||
|
||||
**Named tokens**
|
||||
|
||||
| `<key>` | Description |
|
||||
| ---------------- | ---------------------------------------------------------- |
|
||||
| `id` | having given post number |
|
||||
| `tag` | having given tag |
|
||||
| `score` | having given score |
|
||||
| `uploader` | uploaded by given user |
|
||||
| `upload` | alias of upload |
|
||||
| `submit` | alias of upload |
|
||||
| `comment` | commented by given user |
|
||||
| `fav` | favorited by given user |
|
||||
| `tag-count` | having given number of tags |
|
||||
| `comment-count` | having given number of comments |
|
||||
| `fav-count` | favorited by given number of users |
|
||||
| `note-count` | having given number of annotations |
|
||||
| `relation-count` | having given number of relations |
|
||||
| `feature-count` | having been featured given number of times |
|
||||
| `type` | given type of posts. `<value>` can be either `image`, `animation` (or `animated` or `anim`), `flash` (or `swf`) or `video` (or `webm`). |
|
||||
| `file-size` | having given file size (in bytes) |
|
||||
| `image-width` | having given image width (where applicable) |
|
||||
| `image-height` | having given image height (where applicable) |
|
||||
| `image-area` | having given number of pixels (image width * image height) |
|
||||
| `width` | alias of `image-width` |
|
||||
| `height` | alias of `image-height` |
|
||||
| `area` | alias of `image-area` |
|
||||
| `creation-date` | posted at given date |
|
||||
| `creation-time` | alias of `creation-date` |
|
||||
| `date` | alias of `creation-date` |
|
||||
| `time` | alias of `creation-date` |
|
||||
| `last-edit-date` | edited at given date |
|
||||
| `last-edit-time` | alias of `last-edit-date` |
|
||||
| `edit-date` | alias of `last-edit-date` |
|
||||
| `edit-time` | alias of `last-edit-date` |
|
||||
| `comment-date` | commented at given date |
|
||||
| `comment-time` | alias of `comment-date` |
|
||||
| `fav-date` | last favorited at given date |
|
||||
| `fav-time` | alias of `fav-date` |
|
||||
| `feature-date` | featured at given date |
|
||||
| `feature-time` | alias of `feature-time` |
|
||||
| `safety` | having given safety. `<value>` can be either `safe`, `sketchy` (or `questionable`) or `unsafe`. |
|
||||
| `rating` | alias of `safety` |
|
||||
| `<key>` | Description |
|
||||
| ------------------ | ---------------------------------------------------------- |
|
||||
| `id` | having given post number |
|
||||
| `tag` | having given tag |
|
||||
| `score` | having given score |
|
||||
| `uploader` | uploaded by given user |
|
||||
| `upload` | alias of upload |
|
||||
| `submit` | alias of upload |
|
||||
| `comment` | commented by given user |
|
||||
| `fav` | favorited by given user |
|
||||
| `tag-count` | having given number of tags |
|
||||
| `comment-count` | having given number of comments |
|
||||
| `fav-count` | favorited by given number of users |
|
||||
| `note-count` | having given number of annotations |
|
||||
| `relation-count` | having given number of relations |
|
||||
| `feature-count` | having been featured given number of times |
|
||||
| `type` | given type of posts. `<value>` can be either `image`, `animation` (or `animated` or `anim`), `flash` (or `swf`) or `video` (or `webm`). |
|
||||
| `content-checksum` | having given SHA1 checksum |
|
||||
| `file-size` | having given file size (in bytes) |
|
||||
| `image-width` | having given image width (where applicable) |
|
||||
| `image-height` | having given image height (where applicable) |
|
||||
| `image-area` | having given number of pixels (image width * image height) |
|
||||
| `width` | alias of `image-width` |
|
||||
| `height` | alias of `image-height` |
|
||||
| `area` | alias of `image-area` |
|
||||
| `creation-date` | posted at given date |
|
||||
| `creation-time` | alias of `creation-date` |
|
||||
| `date` | alias of `creation-date` |
|
||||
| `time` | alias of `creation-date` |
|
||||
| `last-edit-date` | edited at given date |
|
||||
| `last-edit-time` | alias of `last-edit-date` |
|
||||
| `edit-date` | alias of `last-edit-date` |
|
||||
| `edit-time` | alias of `last-edit-date` |
|
||||
| `comment-date` | commented at given date |
|
||||
| `comment-time` | alias of `comment-date` |
|
||||
| `fav-date` | last favorited at given date |
|
||||
| `fav-time` | alias of `fav-date` |
|
||||
| `feature-date` | featured at given date |
|
||||
| `feature-time` | alias of `feature-time` |
|
||||
| `safety` | having given safety. `<value>` can be either `safe`, `sketchy` (or `questionable`) or `unsafe`. |
|
||||
| `rating` | alias of `safety` |
|
||||
|
||||
**Sort style tokens**
|
||||
|
||||
@ -762,10 +811,8 @@ data.
|
||||
enable looping for video posts. Sending empty `thumbnail` will cause the
|
||||
post to use default thumbnail. If `anonymous` is set to truthy value, the
|
||||
uploader name won't be recorded (privilege verification still applies; it's
|
||||
possible to disallow anonymous uploads completely from config.) All fields
|
||||
except the [`version`](#versioning) are optional - update concerns only
|
||||
provided fields. For details how to pass `content` and `thumbnail`, see
|
||||
[file uploads](#file-uploads) for details.
|
||||
possible to disallow anonymous uploads completely from config.) For details
|
||||
how to pass `content` and `thumbnail`, see [file uploads](#file-uploads).
|
||||
|
||||
## Updating post
|
||||
- **Request**
|
||||
@ -812,9 +859,9 @@ data.
|
||||
must contain valid post IDs. `<flag>` currently can be only `"loop"` to
|
||||
enable looping for video posts. Sending empty `thumbnail` will reset the
|
||||
post thumbnail to default. For details how to pass `content` and
|
||||
`thumbnail`, see [file uploads](#file-uploads) for details. All fields
|
||||
except the [`version`](#versioning) are optional - update concerns only
|
||||
provided fields.
|
||||
`thumbnail`, see [file uploads](#file-uploads). All fields except the
|
||||
[`version`](#versioning) are optional - update concerns only provided
|
||||
fields.
|
||||
|
||||
## Getting post
|
||||
- **Request**
|
||||
@ -863,6 +910,43 @@ data.
|
||||
|
||||
Deletes existing post. Related posts and tags are kept.
|
||||
|
||||
## Merging posts
|
||||
- **Request**
|
||||
|
||||
`POST /post-merge/`
|
||||
|
||||
- **Input**
|
||||
|
||||
```json5
|
||||
{
|
||||
"removeVersion": <source-post-version>,
|
||||
"remove": <source-post-id>,
|
||||
"mergeToVersion": <target-post-version>,
|
||||
"mergeTo": <target-post-id>,
|
||||
"replaceContent": <true-or-false>
|
||||
}
|
||||
```
|
||||
|
||||
- **Output**
|
||||
|
||||
A [post resource](#post) containing the merged post.
|
||||
|
||||
- **Errors**
|
||||
|
||||
- the version of either post is outdated
|
||||
- the source or target post does not exist
|
||||
- the source post is the same as the target post
|
||||
- privileges are too low
|
||||
|
||||
- **Description**
|
||||
|
||||
Removes source post and merges all of its tags, relations, scores,
|
||||
favorites and comments to the target post. If `replaceContent` is set to
|
||||
true, content of the target post is replaced using the content of the
|
||||
source post; otherwise it remains unchanged. Source post properties such as
|
||||
its safety, source, whether to loop the video and other scalar values do
|
||||
not get transferred and are discarded.
|
||||
|
||||
## Rating post
|
||||
- **Request**
|
||||
|
||||
|
@ -151,6 +151,7 @@ the one in the `config.yaml`, so that client knows how to access the backend!
|
||||
server {
|
||||
listen 80;
|
||||
server_name great.dude;
|
||||
merge_slashes off; # to support post tags such as ///
|
||||
|
||||
location ~ ^/api$ {
|
||||
return 302 /api/;
|
||||
|
676
LICENSE.md
Normal file
676
LICENSE.md
Normal file
@ -0,0 +1,676 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
==========================
|
||||
Version 3, 29 June 2007
|
||||
==========================
|
||||
|
||||
> Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
# Preamble
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
# TERMS AND CONDITIONS
|
||||
|
||||
## 0. Definitions.
|
||||
|
||||
_"This License"_ refers to version 3 of the GNU General Public License.
|
||||
|
||||
_"Copyright"_ also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
_"The Program"_ refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as _"you"_. _"Licensees"_ and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To _"modify"_ a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a _"modified version"_ of the
|
||||
earlier work or a work _"based on"_ the earlier work.
|
||||
|
||||
A _"covered work"_ means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To _"propagate"_ a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To _"convey"_ a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
## 1. Source Code.
|
||||
|
||||
The _"source code"_ for a work means the preferred form of the work
|
||||
for making modifications to it. _"Object code"_ means any non-source
|
||||
form of a work.
|
||||
|
||||
A _"Standard Interface"_ means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The _"System Libraries"_ of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The _"Corresponding Source"_ for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
## 2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
## 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
## 4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
## 5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
## 6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A _"User Product"_ is either (1) a _"consumer product"_, which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
_"Installation Information"_ for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
## 7. Additional Terms.
|
||||
|
||||
_"Additional permissions"_ are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
## 8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
## 9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
## 10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An _"entity transaction"_ is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
## 11. Patents.
|
||||
|
||||
A _"contributor"_ is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's _"essential patent claims"_ are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
## 12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
## 13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
## 14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
## 15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
## 16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
## 17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
# END OF TERMS AND CONDITIONS
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
|
||||
# How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type 'show c' for details.
|
||||
|
||||
The hypothetical commands _'show w'_ and _'show c'_ should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
63
README.md
63
README.md
@ -1,19 +1,48 @@
|
||||
This repository is under the process of being rewritten. Stay tuned! You can
|
||||
check the current progress on client
|
||||
[here](https://github.com/rr-/szurubooru/issues/84) and server
|
||||
[here](https://github.com/rr-/szurubooru/issues/83).
|
||||
# szurubooru
|
||||
|
||||
The reasons behind this rewrite include:
|
||||
Szurubooru is an image board engine inspired by services such as Danbooru,
|
||||
Gelbooru and Moebooru dedicated for small and medium communities. Its name [has
|
||||
its roots in Polish language and has onomatopeic meaning of scraping or
|
||||
scrubbing](http://sjp.pwn.pl/sjp/;2527372). It is pronounced as *shoorubooru*.
|
||||
|
||||
- Improving user experience: better upload form, larger thumbnails, making top
|
||||
navigation stay out of user way. Maybe other goodies!
|
||||
- Finally having good, well-documented REST API.
|
||||
- Simplifying user registration.
|
||||
- Replacing PHP with Python 3.5.
|
||||
- Replacing prior JS mess with proper MVC.
|
||||
- Replacing MySQL (MariaDB) with Postgres.
|
||||
- Replacing `composer`, `npm`, `mod_rewrite` (=Apache), `imagick`, `ffmpeg` or
|
||||
`gnash` and `pdo_mysql` with just `pip`, `npm` and `ffmpeg`.
|
||||
- Replacing `grunt` with `npm` scripts.
|
||||
- Making hosting more flexible: offer simple self hosted application that can
|
||||
be combined with any reverse proxy.
|
||||
## Features
|
||||
|
||||
- Post content: images (JPG, PNG, GIF, animated GIF), videos (MP4, WEBM), Flash animations
|
||||
- Post comments
|
||||
- Post notes / annotations, including arbitrary polygons
|
||||
- Rich JSON REST API ([see documentation](https://github.com/rr-/szurubooru/blob/master/API.md))
|
||||
- Rich search system
|
||||
- Rich privilege system
|
||||
- Autocomplete in search and while editing tags
|
||||
- Tag categories
|
||||
- Tag suggestions
|
||||
- Tag implications (adding a tag automatically adds another)
|
||||
- Tag aliases
|
||||
- Duplicate detection
|
||||
- Post rating and favoriting; comment rating
|
||||
- Polished UI
|
||||
- Browser configurable endless paging
|
||||
- Browser configurable backdrop grid for transparent images
|
||||
|
||||
## Requirements
|
||||
|
||||
- Python
|
||||
- Postgres
|
||||
- FFmpeg
|
||||
- node.js
|
||||
|
||||
[See installation instructions.](https://github.com/rr-/szurubooru/blob/master/INSTALL.md)
|
||||
|
||||
## Screenshots
|
||||
|
||||
Post list:
|
||||
|
||||

|
||||
|
||||
Post view:
|
||||
|
||||

|
||||
|
||||
## License
|
||||
|
||||
[GPLv3](https://github.com/rr-/szurubooru/blob/master/LICENSE.md).
|
||||
|
@ -29,7 +29,9 @@ function writeFile(path, content) {
|
||||
}
|
||||
|
||||
function getVersion() {
|
||||
return execSync('git describe --always --dirty --long --tags').toString();
|
||||
return execSync('git describe --always --dirty --long --tags')
|
||||
.toString()
|
||||
.trim();
|
||||
}
|
||||
|
||||
function getConfig() {
|
||||
@ -68,7 +70,7 @@ function copyFile(source, target) {
|
||||
}
|
||||
|
||||
function minifyJs(path) {
|
||||
return require('uglify-js').minify(path).code;
|
||||
return require('uglify-js').minify(path, {compress: {unused: false}}).code;
|
||||
}
|
||||
|
||||
function minifyCss(css) {
|
||||
@ -211,6 +213,13 @@ function bundleBinaryAssets() {
|
||||
});
|
||||
}
|
||||
|
||||
process.on('uncaughtException', (error) => {
|
||||
const stack = error.stack;
|
||||
delete error.stack;
|
||||
console.log(error);
|
||||
console.log(stack);
|
||||
});
|
||||
|
||||
const config = getConfig();
|
||||
bundleConfig(config);
|
||||
bundleBinaryAssets();
|
||||
|
@ -28,6 +28,8 @@ $button-enabled-text-color = white
|
||||
$button-enabled-background-color = $main-color
|
||||
$button-disabled-text-color = #666
|
||||
$button-disabled-background-color = #CCC
|
||||
$post-thumbnail-border-color = $main-color
|
||||
$post-thumbnail-no-tags-border-color = #F44
|
||||
$default-tag-category-background-color = $active-tab-background-color
|
||||
$new-tag-background-color = #DFC
|
||||
$new-tag-text-color = black
|
||||
@ -50,3 +52,6 @@ $note-text-text-color = black
|
||||
$first-note-point-color = orangered
|
||||
$hovered-note-point-color = red
|
||||
$hovered-first-note-point-color = red
|
||||
$safety-safe = #88D488
|
||||
$safety-sketchy = #F3D75F
|
||||
$safety-unsafe = #F3985F
|
||||
|
@ -1,12 +1,5 @@
|
||||
@import colors
|
||||
|
||||
.comments>ul
|
||||
list-style-type: none
|
||||
margin: 0 0 2em 0
|
||||
padding: 0
|
||||
|
||||
|
||||
|
||||
.comment-form-container
|
||||
&:not(.editing)
|
||||
.tabs nav
|
||||
@ -20,13 +13,12 @@
|
||||
display: none
|
||||
.tabs-wrapper
|
||||
background: $active-tab-background-color
|
||||
.tab
|
||||
padding: 0.3em
|
||||
.comment-content-wrapper
|
||||
background: $window-color
|
||||
overflow: hidden
|
||||
.comment-content
|
||||
margin: 1em
|
||||
.tab-wrapper[data-tab='preview']
|
||||
background: $window-color
|
||||
.tab.preview
|
||||
padding: 1em
|
||||
.tab.edit
|
||||
textarea
|
||||
resize: vertical
|
||||
width: 100%
|
||||
@ -45,12 +37,12 @@
|
||||
|
||||
nav
|
||||
vertical-align: middle !important
|
||||
margin: 0 0.3em 0.5em 0 !important
|
||||
&.buttons
|
||||
margin: 0 0.3em 0.5em 0 !important
|
||||
float: left
|
||||
&.actions
|
||||
float: left
|
||||
margin-top: 0.3em !important
|
||||
margin: 0.3em 0 0.5em 0 !important
|
||||
|
||||
|
||||
.comment
|
||||
@ -72,17 +64,18 @@
|
||||
display: inline-block
|
||||
|
||||
.body
|
||||
width: 100%
|
||||
|
||||
flex-grow: 1
|
||||
header
|
||||
white-space: nowrap
|
||||
line-height: 16pt
|
||||
vertical-align: middle
|
||||
margin-bottom: 0.5em
|
||||
background: $top-navigation-color
|
||||
padding: 0.2em 0.5em
|
||||
|
||||
.nickname, .date, .score-container, .edit
|
||||
margin-right: 2em
|
||||
.date, .score-container, .edit, .delete
|
||||
margin-left: 2em
|
||||
font-size: 95%
|
||||
.edit, .delete, .score-container a, .nickname a
|
||||
&:not(.inactive)
|
||||
@ -107,7 +100,6 @@
|
||||
margin: 1em 0
|
||||
|
||||
|
||||
|
||||
.comment-content
|
||||
ul
|
||||
list-style-position: inside
|
||||
@ -150,30 +142,3 @@
|
||||
|
||||
blockquote :last-child
|
||||
margin-bottom: 0
|
||||
|
||||
|
||||
|
||||
.global-comment-list
|
||||
text-align: left
|
||||
|
||||
&>ul
|
||||
list-style-type: none
|
||||
margin: 1em 0
|
||||
padding: 0
|
||||
|
||||
&>li
|
||||
display: flex
|
||||
margin-bottom: 2em
|
||||
|
||||
.post-thumbnail
|
||||
float: left
|
||||
vertical-align: top
|
||||
margin-right: 1em
|
||||
.thumbnail
|
||||
width: 12em
|
||||
height: 8em
|
||||
a
|
||||
display: inline-block
|
||||
|
||||
.comments-container
|
||||
width: 100%
|
4
client/css/comment-list-control.styl
Normal file
4
client/css/comment-list-control.styl
Normal file
@ -0,0 +1,4 @@
|
||||
.comments>ul
|
||||
list-style-type: none
|
||||
margin: 0 0 2em 0
|
||||
padding: 0
|
36
client/css/comment-list-view.styl
Normal file
36
client/css/comment-list-view.styl
Normal file
@ -0,0 +1,36 @@
|
||||
.global-comment-list
|
||||
text-align: left
|
||||
|
||||
&>ul
|
||||
list-style-type: none
|
||||
margin: 1em 0
|
||||
padding: 0
|
||||
|
||||
@media (max-width: 700px)
|
||||
&>li
|
||||
margin-bottom: 5em
|
||||
padding: 1vw
|
||||
.post-thumbnail
|
||||
margin-bottom: 1em
|
||||
.thumbnail
|
||||
width: 50vw
|
||||
height: 33vw
|
||||
|
||||
@media (min-width: 700px)
|
||||
&>li
|
||||
display: flex
|
||||
margin-bottom: 2em
|
||||
.post-thumbnail
|
||||
float: left
|
||||
.thumbnail
|
||||
width: 12em
|
||||
height: 8em
|
||||
|
||||
.post-thumbnail
|
||||
vertical-align: top
|
||||
margin-right: 1em
|
||||
a
|
||||
display: inline-block
|
||||
|
||||
.comments-container
|
||||
width: 100%
|
@ -65,10 +65,9 @@ input[type=radio], input[type=checkbox]
|
||||
.radio:before, .checkbox:before
|
||||
transition: border-color 0.1s linear
|
||||
position: absolute
|
||||
top: 50%
|
||||
left: 0
|
||||
top: 0.15em
|
||||
display: block
|
||||
margin-top: -10px
|
||||
width: 16px
|
||||
height: 16px
|
||||
background: $input-enabled-background-color
|
||||
@ -79,10 +78,10 @@ input[type=radio], input[type=checkbox]
|
||||
background: $main-color
|
||||
transition: opacity 0.1s linear
|
||||
position: absolute
|
||||
top: 50%
|
||||
left: 5px
|
||||
top: 0.15em
|
||||
margin-top: 5px
|
||||
display: block
|
||||
margin-top: -5px
|
||||
width: 10px
|
||||
height: 10px
|
||||
border-radius: 50%
|
||||
@ -92,10 +91,10 @@ input[type=radio], input[type=checkbox]
|
||||
.checkbox:after
|
||||
transition: opacity 0.1s linear
|
||||
position: absolute
|
||||
top: 50%
|
||||
top: 0.15em
|
||||
left: 6px
|
||||
display: block
|
||||
margin-top: -7px
|
||||
margin-top: 3px
|
||||
width: 5px
|
||||
height: 9px
|
||||
border-right: 3px solid $main-color
|
@ -147,22 +147,24 @@ a .access-key
|
||||
|
||||
.messages
|
||||
margin: 0 auto
|
||||
width: 30em
|
||||
max-width: 100%
|
||||
text-align: left
|
||||
.message
|
||||
box-sizing: border-box
|
||||
width: 100%
|
||||
max-width: 40em
|
||||
margin: 0 0 1em 0
|
||||
display: inline-block
|
||||
text-align: left
|
||||
padding: 0.5em 1em
|
||||
.message.info
|
||||
border: 1px solid $message-info-border-color
|
||||
background: $message-info-background-color
|
||||
.message.error
|
||||
border: 1px solid $message-error-border-color
|
||||
background: $message-error-background-color
|
||||
.message.success
|
||||
border: 1px solid $message-success-border-color
|
||||
background: $message-success-background-color
|
||||
&.info
|
||||
border: 1px solid $message-info-border-color
|
||||
background: $message-info-background-color
|
||||
&.error
|
||||
border: 1px solid $message-error-border-color
|
||||
background: $message-error-background-color
|
||||
&.success
|
||||
border: 1px solid $message-success-border-color
|
||||
background: $message-success-background-color
|
||||
|
||||
.thumbnail
|
||||
/*background-image: attr(data-src url)*/ /* not available yet */
|
||||
@ -192,62 +194,7 @@ a .access-key
|
||||
margin-top: 0 !important
|
||||
margin-bottom: 0 !important
|
||||
|
||||
.pager
|
||||
nav
|
||||
.disabled
|
||||
opacity: .5
|
||||
.prev span,
|
||||
.next span
|
||||
opacity: 0
|
||||
position: absolute
|
||||
display: block
|
||||
width: 0
|
||||
height: 0
|
||||
.page
|
||||
position: relative
|
||||
.page-header
|
||||
margin: 0.5em 0.5em 0.5em 0
|
||||
position: relative
|
||||
&:before
|
||||
display: block
|
||||
content: ''
|
||||
position: absolute
|
||||
left: 0
|
||||
top: 50%
|
||||
right: 0
|
||||
height: 3px
|
||||
background: $top-navigation-color
|
||||
z-index: 1
|
||||
span
|
||||
position: relative
|
||||
background: white
|
||||
padding: 0 1em
|
||||
z-index: 2
|
||||
|
||||
/* hack to prevent text from being copied */
|
||||
[data-pseudo-content]:before {
|
||||
content: attr(data-pseudo-content)
|
||||
}
|
||||
|
||||
.expander
|
||||
&.collapsed
|
||||
margin-bottom: 1em
|
||||
&>*
|
||||
display: none
|
||||
&>header
|
||||
display: block
|
||||
header
|
||||
background: $active-tab-background-color
|
||||
line-height: 2em
|
||||
a
|
||||
padding: 0 0.5em
|
||||
display: block
|
||||
color: mix($text-color, $inactive-link-color)
|
||||
font-size: 120%
|
||||
i
|
||||
font-size: 12pt
|
||||
color: $inactive-link-color
|
||||
float: right
|
||||
line-height: 2em
|
||||
.expander-content
|
||||
padding: 0.5em 0.5em 2em 0.5em
|
24
client/css/expander-control.styl
Normal file
24
client/css/expander-control.styl
Normal file
@ -0,0 +1,24 @@
|
||||
@import colors
|
||||
|
||||
.expander
|
||||
&.collapsed
|
||||
margin-bottom: 1em
|
||||
&>*
|
||||
display: none
|
||||
&>header
|
||||
display: block
|
||||
header
|
||||
background: $active-tab-background-color
|
||||
line-height: 2em
|
||||
a
|
||||
padding: 0 0.5em
|
||||
display: block
|
||||
color: mix($text-color, $inactive-link-color)
|
||||
font-size: 120%
|
||||
i
|
||||
font-size: 12pt
|
||||
color: $inactive-link-color
|
||||
float: right
|
||||
line-height: 2em
|
||||
.expander-content
|
||||
padding: 0.5em 0.5em 2em 0.5em
|
@ -1,5 +1,6 @@
|
||||
#home
|
||||
text-align: center !important
|
||||
max-width: 100%
|
||||
|
||||
header
|
||||
margin-bottom: 1em
|
||||
@ -21,6 +22,9 @@
|
||||
width: auto
|
||||
.sep
|
||||
margin: 0 0.75em
|
||||
@media (max-width: 500px)
|
||||
.sep, a
|
||||
display: none
|
||||
|
||||
.post-container
|
||||
margin-bottom: 2em
|
||||
@ -35,11 +39,22 @@
|
||||
aside
|
||||
margin-bottom: 0.3em
|
||||
font-size: 90%
|
||||
white-space: nowrap
|
||||
|
||||
footer
|
||||
line-height: 100%
|
||||
line-height: 150%
|
||||
font-size: 80%
|
||||
.sep
|
||||
margin: 0 0.25em
|
||||
ul
|
||||
padding: 0
|
||||
text-align: center
|
||||
li
|
||||
display: inline
|
||||
white-space: nowrap
|
||||
.sep
|
||||
word-spacing: 1.1em
|
||||
background-repeat: no-repeat
|
||||
background-position: 50% 50%
|
||||
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12'><circle cx='6' cy='6' r='2' fill='%23000000'/></svg>")
|
||||
|
||||
.thumbnail
|
||||
margin-right: 0.4em
|
27
client/css/pager.styl
Normal file
27
client/css/pager.styl
Normal file
@ -0,0 +1,27 @@
|
||||
@import colors
|
||||
|
||||
.pager
|
||||
nav
|
||||
.disabled
|
||||
opacity: .5
|
||||
|
||||
.page
|
||||
position: relative
|
||||
.page-header
|
||||
margin: 0.5em 0.5em 0.5em 0
|
||||
position: relative
|
||||
&:before
|
||||
display: block
|
||||
content: ''
|
||||
position: absolute
|
||||
left: 0
|
||||
top: 50%
|
||||
right: 0
|
||||
height: 3px
|
||||
background: $top-navigation-color
|
||||
z-index: 1
|
||||
span
|
||||
position: relative
|
||||
background: white
|
||||
padding: 0 1em
|
||||
z-index: 2
|
27
client/css/post-content-control.styl
Normal file
27
client/css/post-content-control.styl
Normal file
@ -0,0 +1,27 @@
|
||||
.post-container
|
||||
.post-content.transparency-grid img
|
||||
background: url('/img/transparency_grid.png')
|
||||
|
||||
text-align: center
|
||||
.post-content
|
||||
text-align: left
|
||||
margin: 0 auto
|
||||
position: relative
|
||||
|
||||
img, object, video, .post-overlay
|
||||
position: absolute
|
||||
height: 100%
|
||||
width: 100%
|
||||
left: 0
|
||||
right: 0
|
||||
top: 0
|
||||
bottom: 0
|
||||
|
||||
.post-overlay>*
|
||||
position: absolute
|
||||
left: 0
|
||||
right: 0
|
||||
top: 0
|
||||
bottom: 0
|
||||
width: 100%
|
||||
height: 100%
|
33
client/css/post-detail-view.styl
Normal file
33
client/css/post-detail-view.styl
Normal file
@ -0,0 +1,33 @@
|
||||
#post
|
||||
width: 100%
|
||||
max-width: 40em
|
||||
h1
|
||||
margin-top: 0
|
||||
form
|
||||
width: 100%
|
||||
.buttons i
|
||||
margin-right: 0.5em
|
||||
.post-merge
|
||||
.left-post-container
|
||||
width: 47%
|
||||
float: left
|
||||
.right-post-container
|
||||
width: 47%
|
||||
float: right
|
||||
input[type=text]
|
||||
width: 8em
|
||||
margin-top: -2px
|
||||
.post-mirror
|
||||
margin-bottom: 1em
|
||||
&:after
|
||||
display: block
|
||||
height: 1px
|
||||
content: ' '
|
||||
clear: both
|
||||
.post-thumbnail .thumbnail
|
||||
width: 100%
|
||||
height: 9em
|
||||
.target-post .thumbnail
|
||||
margin-right: 0.35em
|
||||
.target-post, .target-post-content
|
||||
margin: 1em 0
|
155
client/css/post-list-view.styl
Normal file
155
client/css/post-list-view.styl
Normal file
@ -0,0 +1,155 @@
|
||||
@import colors
|
||||
|
||||
.post-list
|
||||
ul
|
||||
list-style-type: none
|
||||
margin: 0
|
||||
padding: 0
|
||||
display: flex
|
||||
align-content: flex-end
|
||||
flex-wrap: wrap
|
||||
margin: 0 -0.25em
|
||||
|
||||
li
|
||||
position: relative
|
||||
flex-grow: 1
|
||||
margin: 0 0.25em 0.5em 0.25em
|
||||
display: inline-block
|
||||
text-align: left
|
||||
min-width: 10em
|
||||
width: 12vw
|
||||
&:not(.flexbox-dummy)
|
||||
min-height: 7.5em
|
||||
height: 9vw
|
||||
|
||||
.thumbnail-wrapper
|
||||
display: inline-block
|
||||
width: 100%
|
||||
height: 100%
|
||||
line-height: 80%
|
||||
font-size: 80%
|
||||
color: white
|
||||
outline-offset: -3px
|
||||
box-shadow: 0 0 0 1px rgba(0,0,0,0.2)
|
||||
|
||||
.type, .stats
|
||||
position: absolute
|
||||
bottom: 0.5em
|
||||
padding: 0.33em 0.5em
|
||||
background: rgba(0,0,0,0.5)
|
||||
height: 1em
|
||||
|
||||
.type
|
||||
float: left
|
||||
left: 0.5em
|
||||
&[data-type=image]
|
||||
display: none
|
||||
|
||||
.stats
|
||||
float: right
|
||||
right: 0.5em
|
||||
text-align: right
|
||||
i
|
||||
margin-right: 0.25em
|
||||
.icon:not(:first-of-type)
|
||||
margin-left: 1em
|
||||
|
||||
.masstag
|
||||
position: absolute
|
||||
top: 0.5em
|
||||
left: 0.5em
|
||||
display: inline-block
|
||||
padding: 0.5em
|
||||
box-sizing: border-box
|
||||
border: 0
|
||||
&:after
|
||||
display: inline-block
|
||||
width: 1em
|
||||
height: 1em
|
||||
text-align: center
|
||||
line-height: 1em
|
||||
font-size: 20pt
|
||||
&.tagged
|
||||
background: rgba(0, 230, 0, 0.7)
|
||||
&:after
|
||||
color: white
|
||||
content: '-'
|
||||
&:not(.tagged)
|
||||
background: rgba(255, 0, 0, 0.7)
|
||||
&:after
|
||||
color: white
|
||||
content: '+'
|
||||
&[data-disabled]
|
||||
background: rgba(200, 200, 200, 0.7)
|
||||
|
||||
.thumbnail
|
||||
background-position: 50% 30%
|
||||
width: 100%
|
||||
height: 100%
|
||||
outline-offset: -3px
|
||||
|
||||
.thumbnail-wrapper.no-tags
|
||||
.thumbnail
|
||||
outline: 4px solid $post-thumbnail-no-tags-border-color
|
||||
|
||||
&:hover
|
||||
background: $post-thumbnail-border-color
|
||||
.thumbnail
|
||||
opacity: .9
|
||||
|
||||
&:hover a, a:active, a:focus
|
||||
.thumbnail
|
||||
outline: 4px solid $main-color !important
|
||||
|
||||
.post-list-header
|
||||
white-space: nowrap
|
||||
text-align: left
|
||||
|
||||
label
|
||||
display: none
|
||||
form
|
||||
width: auto
|
||||
margin-bottom: 0.75em
|
||||
*
|
||||
vertical-align: top
|
||||
input
|
||||
margin-bottom: 0.25em
|
||||
margin-right: 0.25em
|
||||
input[name=search-text]
|
||||
width: 25em
|
||||
input[name=masstag]
|
||||
width: 12em
|
||||
.masstag-hint, .open-masstag
|
||||
margin-right: 1em
|
||||
.append
|
||||
font-size: 0.95em
|
||||
color: $inactive-link-color
|
||||
.masstag
|
||||
&:not(.active)
|
||||
[type=text],
|
||||
.start-tagging,
|
||||
.stop-tagging
|
||||
display: none
|
||||
.masstag-hint
|
||||
display: none
|
||||
&.active
|
||||
.open-masstag
|
||||
display: none
|
||||
|
||||
.safety
|
||||
margin-right: 0.25em
|
||||
&.safety-safe
|
||||
background-color: $safety-safe
|
||||
border-color: @background-color
|
||||
&.disabled
|
||||
background-color: alpha(@background-color, 0.15)
|
||||
&.safety-sketchy
|
||||
background-color: $safety-sketchy
|
||||
border-color: @background-color
|
||||
&.disabled
|
||||
background-color: alpha(@background-color, 0.15)
|
||||
&.safety-unsafe
|
||||
background-color: $safety-unsafe
|
||||
border-color: @background-color
|
||||
&.disabled
|
||||
background-color: alpha(@background-color, 0.15)
|
148
client/css/post-main-view.styl
Normal file
148
client/css/post-main-view.styl
Normal file
@ -0,0 +1,148 @@
|
||||
@import colors
|
||||
|
||||
.post-view
|
||||
width: 100%
|
||||
display: flex !important
|
||||
flex-direction: row
|
||||
|
||||
>.sidebar
|
||||
margin-right: 1em
|
||||
min-width: 20em
|
||||
max-width: 20em
|
||||
line-height: 160%
|
||||
|
||||
a:active
|
||||
border: 0
|
||||
outline: 0
|
||||
|
||||
nav.buttons
|
||||
margin-top: 0
|
||||
display: flex
|
||||
flex-wrap: wrap
|
||||
article
|
||||
flex: 1 0 33%
|
||||
a
|
||||
display: inline-block
|
||||
width: 100%
|
||||
padding: 0.3em 0
|
||||
text-align: center
|
||||
vertical-align: middle
|
||||
transition: background 0.2s linear
|
||||
&:not(.inactive):hover
|
||||
background: lighten($main-color, 90%)
|
||||
i
|
||||
font-size: 140%
|
||||
text-align: center
|
||||
|
||||
>.content
|
||||
width: 100%
|
||||
|
||||
.post-container
|
||||
margin-bottom: 2em
|
||||
|
||||
.post-content
|
||||
margin: 0
|
||||
|
||||
@media (max-width: 800px)
|
||||
.post-view
|
||||
flex-wrap: wrap
|
||||
>.sidebar
|
||||
order: 2
|
||||
min-width: 100%
|
||||
max-width: 0
|
||||
>.content
|
||||
order: 1
|
||||
|
||||
|
||||
.post-view .readonly-sidebar
|
||||
.details
|
||||
i
|
||||
margin-right: 0.6em
|
||||
display: inline-block
|
||||
width: 1em
|
||||
text-align: center
|
||||
|
||||
.safety-safe
|
||||
color: $safety-safe
|
||||
.safety-sketchy
|
||||
color: $safety-sketchy
|
||||
.safety-unsafe
|
||||
color: $safety-unsafe
|
||||
|
||||
.upload-info
|
||||
.thumbnail
|
||||
width: 1em
|
||||
height: 1em
|
||||
margin: -0.1em 0.6em 0 0
|
||||
|
||||
.zoom
|
||||
margin-top: 1em
|
||||
a
|
||||
display: inline-block
|
||||
.active
|
||||
text-decoration: underline
|
||||
|
||||
.social
|
||||
margin-top: 1em
|
||||
.score-container
|
||||
float: left
|
||||
margin-right: 3em
|
||||
.downvote i
|
||||
text-align: right
|
||||
i
|
||||
text-align: left
|
||||
margin: 0
|
||||
.value
|
||||
text-align: center
|
||||
display: inline-block
|
||||
width: 2em
|
||||
|
||||
.relations
|
||||
margin-top: 2em
|
||||
h1
|
||||
margin-bottom: 0.5em
|
||||
.thumbnail
|
||||
background-position: 50% 30%
|
||||
width: 4em
|
||||
height: 3em
|
||||
li
|
||||
margin: 0 0.3em 0.3em 0
|
||||
display: inline-block
|
||||
|
||||
.tags
|
||||
margin-top: 2em
|
||||
h1
|
||||
margin-bottom: 0.5em
|
||||
|
||||
.post-view .edit-sidebar
|
||||
.expander-content
|
||||
section:not(:last-child)
|
||||
margin-bottom: 1em
|
||||
|
||||
.safety
|
||||
&>label
|
||||
width: 100%
|
||||
.radio-wrapper
|
||||
display: flex
|
||||
flex-wrap: wrap
|
||||
.radio-wrapper label
|
||||
flex-grow: 1
|
||||
display: inline-block
|
||||
|
||||
.management
|
||||
li
|
||||
margin: 0
|
||||
|
||||
label
|
||||
margin-bottom: 0.3em
|
||||
display: block
|
||||
|
||||
input[type=submit],
|
||||
input[type=button],
|
||||
button
|
||||
width: 100%
|
||||
&:focus
|
||||
border: 2px solid $text-color !important
|
||||
|
||||
.messages
|
||||
margin-top: 1em
|
@ -1,14 +1,20 @@
|
||||
@import colors
|
||||
|
||||
.post-upload
|
||||
$cancel-button-color = tomato
|
||||
|
||||
#post-upload
|
||||
form
|
||||
width: 100%
|
||||
max-width: 40em
|
||||
margin: 0 auto
|
||||
text-align: left
|
||||
|
||||
&.inactive
|
||||
input[type=submit]
|
||||
display: none
|
||||
&.inactive input[type=submit],
|
||||
&.inactive .skip-duplicates
|
||||
&.uploading input[type=submit],
|
||||
&.uploading .skip-duplicates,
|
||||
&:not(.uploading) .cancel
|
||||
display: none
|
||||
|
||||
.dropper-container
|
||||
margin: 0 auto
|
||||
@ -17,31 +23,54 @@
|
||||
padding: 2em
|
||||
|
||||
input[type=submit]
|
||||
float: left
|
||||
margin-top: 1em
|
||||
|
||||
.cancel
|
||||
margin-top: 1em
|
||||
background: $cancel-button-color
|
||||
border-color: $cancel-button-color
|
||||
&:focus
|
||||
border: 2px solid $text-color
|
||||
|
||||
.skip-duplicates
|
||||
margin-left: 1em
|
||||
|
||||
.messages
|
||||
margin-top: 1em
|
||||
|
||||
.uploadables-container
|
||||
margin: 2em 0
|
||||
text-align: left
|
||||
line-height: 200%
|
||||
li
|
||||
margin: 0 0 1.2em 0
|
||||
|
||||
.uploadable
|
||||
.file
|
||||
margin: 0.3em 0
|
||||
overflow: hidden
|
||||
white-space: nowrap
|
||||
text-align: left
|
||||
text-overflow: ellipsis
|
||||
|
||||
.anonymous
|
||||
margin: 0.3em 0
|
||||
|
||||
.safety
|
||||
margin: 0.3em 0
|
||||
label
|
||||
display: inline-block
|
||||
margin-right: 1em
|
||||
|
||||
.thumbnail
|
||||
.thumbnail-wrapper
|
||||
float: left
|
||||
width: 12.5em
|
||||
height: 7em
|
||||
margin: 0.2em 1em 0 0
|
||||
|
||||
.thumbnail
|
||||
width: 100%
|
||||
height: 100%
|
||||
|
||||
.controls
|
||||
float: right
|
||||
a
|
||||
color: $inactive-link-color
|
||||
margin-left: 0.5em
|
||||
|
@ -1,311 +0,0 @@
|
||||
@import colors
|
||||
$safety-safe = #88D488
|
||||
$safety-sketchy = #F3D75F
|
||||
$safety-unsafe = #F3985F
|
||||
|
||||
.post-view
|
||||
width: 100%
|
||||
display: flex !important
|
||||
flex-direction: row
|
||||
>.sidebar
|
||||
margin-right: 1em
|
||||
max-width: 20em
|
||||
min-width: 20em
|
||||
line-height: 160%
|
||||
|
||||
a:active
|
||||
border: 0
|
||||
outline: 0
|
||||
|
||||
nav.buttons
|
||||
margin-top: 0
|
||||
display: flex
|
||||
flex-wrap: wrap
|
||||
article
|
||||
flex: 1 0 33%
|
||||
a
|
||||
display: inline-block
|
||||
width: 100%
|
||||
padding: 0.3em 0
|
||||
text-align: center
|
||||
vertical-align: middle
|
||||
transition: background 0.2s linear
|
||||
&:not(.inactive):hover
|
||||
background: lighten($main-color, 90%)
|
||||
i
|
||||
font-size: 140%
|
||||
text-align: center
|
||||
|
||||
>.content
|
||||
width: 100%
|
||||
|
||||
.post-container
|
||||
margin-bottom: 2em
|
||||
|
||||
.post-content
|
||||
margin: 0
|
||||
|
||||
.post-list
|
||||
ul
|
||||
list-style-type: none
|
||||
margin: 0
|
||||
padding: 0
|
||||
display: flex
|
||||
align-content: flex-end
|
||||
flex-wrap: wrap
|
||||
margin: 0 -0.25em
|
||||
|
||||
li
|
||||
position: relative
|
||||
flex-grow: 1
|
||||
margin: 0 0.25em 0.5em 0.25em
|
||||
display: inline-block
|
||||
text-align: left
|
||||
min-width: 10em
|
||||
width: 12vw
|
||||
&:not(.flexbox-dummy)
|
||||
min-height: 7.5em
|
||||
height: 9vw
|
||||
|
||||
.thumbnail-wrapper
|
||||
display: inline-block
|
||||
width: 100%
|
||||
height: 100%
|
||||
line-height: 80%
|
||||
font-size: 80%
|
||||
color: white
|
||||
outline-offset: -3px
|
||||
box-shadow: 0 0 0 1px rgba(0,0,0,0.2)
|
||||
|
||||
.type, .stats
|
||||
position: absolute
|
||||
bottom: 0.5em
|
||||
padding: 0.33em 0.5em
|
||||
background: rgba(0,0,0,0.5)
|
||||
height: 1em
|
||||
|
||||
.type
|
||||
float: left
|
||||
left: 0.5em
|
||||
&[data-type=image]
|
||||
display: none
|
||||
|
||||
.stats
|
||||
float: right
|
||||
right: 0.5em
|
||||
text-align: right
|
||||
i
|
||||
margin-right: 0.25em
|
||||
.icon:not(:first-of-type)
|
||||
margin-left: 1em
|
||||
|
||||
.masstag
|
||||
position: absolute
|
||||
top: 0.5em
|
||||
left: 0.5em
|
||||
display: inline-block
|
||||
padding: 0.5em
|
||||
box-sizing: border-box
|
||||
border: 0
|
||||
&:after
|
||||
display: inline-block
|
||||
width: 1em
|
||||
height: 1em
|
||||
text-align: center
|
||||
line-height: 1em
|
||||
font-size: 20pt
|
||||
&.tagged
|
||||
background: rgba(0, 230, 0, 0.7)
|
||||
&:after
|
||||
color: white
|
||||
content: '-'
|
||||
&:not(.tagged)
|
||||
background: rgba(255, 0, 0, 0.7)
|
||||
&:after
|
||||
color: white
|
||||
content: '+'
|
||||
&[data-disabled]
|
||||
background: rgba(200, 200, 200, 0.7)
|
||||
|
||||
.thumbnail
|
||||
background-position: 50% 30%
|
||||
width: 100%
|
||||
height: 100%
|
||||
outline-offset: -3px
|
||||
|
||||
&:hover
|
||||
background: $main-color
|
||||
.thumbnail
|
||||
opacity: .9
|
||||
|
||||
&:hover a, a:active, a:focus
|
||||
box-shadow: 0 0 0 1px $main-color
|
||||
.thumbnail
|
||||
outline: 3px solid $main-color
|
||||
|
||||
.post-list-header
|
||||
label
|
||||
display: none
|
||||
text-align: left
|
||||
form
|
||||
width: auto
|
||||
*
|
||||
vertical-align: top
|
||||
input[name=search-text]
|
||||
width: 25em
|
||||
max-width: 90vw
|
||||
input[name=masstag]
|
||||
width: 15em
|
||||
margin-left: 1em
|
||||
.append
|
||||
font-size: 0.95em
|
||||
color: $inactive-link-color
|
||||
.masstag
|
||||
&:not(.active)
|
||||
[type=text],
|
||||
.start-tagging,
|
||||
.stop-tagging
|
||||
display: none
|
||||
|
||||
.safety
|
||||
&.safety-safe
|
||||
background-color: $safety-safe
|
||||
border-color: @background-color
|
||||
&.disabled
|
||||
background-color: alpha(@background-color, 0.15)
|
||||
&.safety-sketchy
|
||||
background-color: $safety-sketchy
|
||||
border-color: @background-color
|
||||
&.disabled
|
||||
background-color: alpha(@background-color, 0.15)
|
||||
&.safety-unsafe
|
||||
background-color: $safety-unsafe
|
||||
border-color: @background-color
|
||||
&.disabled
|
||||
background-color: alpha(@background-color, 0.15)
|
||||
|
||||
.post-container
|
||||
.post-content.transparency-grid img
|
||||
background: url('/img/transparency_grid.png')
|
||||
|
||||
text-align: center
|
||||
.post-content
|
||||
text-align: left
|
||||
margin: 0 auto
|
||||
position: relative
|
||||
|
||||
img, object, video, .post-overlay
|
||||
position: absolute
|
||||
height: 100%
|
||||
width: 100%
|
||||
left: 0
|
||||
right: 0
|
||||
top: 0
|
||||
bottom: 0
|
||||
|
||||
.post-overlay>*
|
||||
position: absolute
|
||||
left: 0
|
||||
right: 0
|
||||
top: 0
|
||||
bottom: 0
|
||||
width: 100%
|
||||
height: 100%
|
||||
|
||||
.post-view .readonly-sidebar
|
||||
.details
|
||||
i
|
||||
margin-right: 0.6em
|
||||
display: inline-block
|
||||
width: 1em
|
||||
text-align: center
|
||||
|
||||
.safety-safe
|
||||
color: $safety-safe
|
||||
.safety-sketchy
|
||||
color: $safety-sketchy
|
||||
.safety-unsafe
|
||||
color: $safety-unsafe
|
||||
|
||||
.upload-info
|
||||
.thumbnail
|
||||
width: 1em
|
||||
height: 1em
|
||||
margin: -0.1em 0.6em 0 0
|
||||
|
||||
.zoom
|
||||
margin-top: 1em
|
||||
a
|
||||
display: inline-block
|
||||
.active
|
||||
text-decoration: underline
|
||||
|
||||
.social
|
||||
margin-top: 1em
|
||||
.score-container
|
||||
float: left
|
||||
margin-right: 3em
|
||||
.downvote i
|
||||
text-align: right
|
||||
i
|
||||
text-align: left
|
||||
margin: 0
|
||||
.value
|
||||
text-align: center
|
||||
display: inline-block
|
||||
width: 2em
|
||||
|
||||
.relations
|
||||
margin-top: 2em
|
||||
h1
|
||||
margin-bottom: 0.5em
|
||||
.thumbnail
|
||||
background-position: 50% 30%
|
||||
width: 4em
|
||||
height: 3em
|
||||
li
|
||||
margin: 0 0.3em 0.3em 0
|
||||
display: inline-block
|
||||
|
||||
.tags
|
||||
margin-top: 2em
|
||||
h1
|
||||
margin-bottom: 0.5em
|
||||
|
||||
i
|
||||
padding-right: 0.4em
|
||||
|
||||
.tag-usages
|
||||
font-size: 90%
|
||||
color: $inactive-link-color
|
||||
margin-left: 0.7em
|
||||
|
||||
.post-view .edit-sidebar
|
||||
.expander-content
|
||||
section:not(:last-child)
|
||||
margin-bottom: 1em
|
||||
|
||||
.safety
|
||||
display: flex
|
||||
flex-wrap: wrap
|
||||
label:not(.radio)
|
||||
width: 100%
|
||||
.radio
|
||||
flex-grow: 1
|
||||
display: inline-block
|
||||
|
||||
.management
|
||||
li
|
||||
margin: 0
|
||||
|
||||
label
|
||||
margin-bottom: 0.3em
|
||||
display: block
|
||||
|
||||
input[type=submit],
|
||||
input[type=button],
|
||||
button
|
||||
margin-top: 1em
|
||||
width: 100%
|
||||
&:focus
|
||||
border: 2px solid $text-color !important
|
23
client/css/tag-categories-view.styl
Normal file
23
client/css/tag-categories-view.styl
Normal file
@ -0,0 +1,23 @@
|
||||
@import colors
|
||||
|
||||
.content-wrapper.tag-categories
|
||||
width: 100%
|
||||
max-width: 40em
|
||||
table
|
||||
border-spacing: 0
|
||||
width: 100%
|
||||
tr.default td
|
||||
background: $default-tag-category-background-color
|
||||
td, th
|
||||
padding: .4em
|
||||
&.color
|
||||
text-align: center
|
||||
&.usages
|
||||
text-align: center
|
||||
&.remove, &.set-default
|
||||
white-space: pre
|
||||
tfoot
|
||||
display: none
|
||||
form
|
||||
width: auto
|
||||
|
@ -85,32 +85,35 @@ div.tag-input
|
||||
font-size: 90%
|
||||
unselectable()
|
||||
|
||||
ul.compact-tags
|
||||
ul.compact-tags
|
||||
width: 100%
|
||||
margin-top: 0.5em
|
||||
li
|
||||
margin: 0
|
||||
width: 100%
|
||||
margin-top: 0.5em
|
||||
li
|
||||
margin: 0
|
||||
width: 100%
|
||||
line-height: 140%
|
||||
white-space: nowrap
|
||||
overflow: hidden
|
||||
text-overflow: ellipsis
|
||||
transition: background-color 0.5s linear
|
||||
a:focus
|
||||
outline: 0
|
||||
box-shadow: inset 0 0 0 2px $main-color
|
||||
&.implication
|
||||
background: $implied-tag-background-color
|
||||
color: $implied-tag-text-color
|
||||
&.new
|
||||
background: $new-tag-background-color
|
||||
color: $new-tag-text-color
|
||||
&.duplicate
|
||||
background: $duplicate-tag-background-color
|
||||
color: $duplicate-tag-text-color
|
||||
i
|
||||
padding-right: 0.4em
|
||||
line-height: 140%
|
||||
white-space: nowrap
|
||||
overflow: hidden
|
||||
text-overflow: ellipsis
|
||||
transition: background-color 0.5s linear
|
||||
a
|
||||
display: inline
|
||||
a:focus
|
||||
outline: 0
|
||||
box-shadow: inset 0 0 0 2px $main-color
|
||||
&.implication
|
||||
background: $implied-tag-background-color
|
||||
color: $implied-tag-text-color
|
||||
&.new
|
||||
background: $new-tag-background-color
|
||||
color: $new-tag-text-color
|
||||
&.duplicate
|
||||
background: $duplicate-tag-background-color
|
||||
color: $duplicate-tag-text-color
|
||||
i
|
||||
padding-right: 0.4em
|
||||
|
||||
div.tag-input, ul.compact-tags
|
||||
.tag-usages, .tag-weight, .remove-tag
|
||||
color: $inactive-link-color
|
||||
unselectable()
|
52
client/css/tag-list-view.styl
Normal file
52
client/css/tag-list-view.styl
Normal file
@ -0,0 +1,52 @@
|
||||
@import colors
|
||||
|
||||
.tag-list
|
||||
table
|
||||
width: 100%
|
||||
border-spacing: 0
|
||||
text-align: left
|
||||
line-height: 1.3em
|
||||
tr:hover td
|
||||
background: $top-navigation-color
|
||||
th, td
|
||||
padding: 0.1em 0.5em
|
||||
th
|
||||
background: $top-navigation-color
|
||||
.names
|
||||
width: 28%
|
||||
.implications
|
||||
width: 28%
|
||||
.suggestions
|
||||
width: 28%
|
||||
.usages
|
||||
text-align: center
|
||||
width: 8%
|
||||
.creation-time
|
||||
text-align: center
|
||||
width: 8%
|
||||
white-space: pre
|
||||
ul
|
||||
list-style-type: none
|
||||
margin: 0
|
||||
padding: 0
|
||||
display: inline
|
||||
li
|
||||
padding: 0
|
||||
display: inline
|
||||
&:not(:last-child):after
|
||||
content: ', '
|
||||
@media (max-width: 800px)
|
||||
.implications, .suggestions
|
||||
display: none
|
||||
|
||||
.tag-list-header
|
||||
label
|
||||
display: none
|
||||
text-align: left
|
||||
form
|
||||
width: auto
|
||||
input[name=search-text]
|
||||
max-width: 15em
|
||||
.append
|
||||
font-size: 0.95em
|
||||
color: $inactive-link-color
|
33
client/css/tag-view.styl
Normal file
33
client/css/tag-view.styl
Normal file
@ -0,0 +1,33 @@
|
||||
#tag
|
||||
width: 100%
|
||||
max-width: 40em
|
||||
h1
|
||||
word-break: break-all
|
||||
line-height: 130%
|
||||
margin-top: 0
|
||||
form
|
||||
width: 100%
|
||||
.tag-edit
|
||||
textarea
|
||||
height: 10em
|
||||
.tag-summary
|
||||
section
|
||||
&.description
|
||||
margin: 1.5em 0 0 0
|
||||
&.details
|
||||
vertical-align: top
|
||||
padding-right: 0.5em
|
||||
ul
|
||||
margin: 0
|
||||
padding: 0
|
||||
list-style-type: none
|
||||
li
|
||||
display: inline
|
||||
margin: 0
|
||||
padding: 0
|
||||
li:not(:last-of-type):after
|
||||
content: ', '
|
||||
ul:empty:after
|
||||
content: '(none)'
|
||||
section
|
||||
margin-bottom: 1em
|
@ -1,107 +0,0 @@
|
||||
@import colors
|
||||
|
||||
.tag-list
|
||||
table
|
||||
width: 100%
|
||||
border-spacing: 0
|
||||
text-align: left
|
||||
line-height: 1.3em
|
||||
tr:hover td
|
||||
background: $top-navigation-color
|
||||
th, td
|
||||
padding: 0.1em 0.5em
|
||||
th
|
||||
background: $top-navigation-color
|
||||
.names
|
||||
width: 28%
|
||||
.implications
|
||||
width: 28%
|
||||
.suggestions
|
||||
width: 28%
|
||||
.usages
|
||||
text-align: center
|
||||
width: 8%
|
||||
.edit-time
|
||||
text-align: center
|
||||
width: 8%
|
||||
white-space: pre
|
||||
ul
|
||||
list-style-type: none
|
||||
margin: 0
|
||||
padding: 0
|
||||
display: inline
|
||||
li
|
||||
padding: 0
|
||||
display: inline
|
||||
&:not(:last-child):after
|
||||
content: ', '
|
||||
@media (max-width: 800px)
|
||||
.implications, .suggestions
|
||||
display: none
|
||||
|
||||
.tag-list-header
|
||||
label
|
||||
display: none
|
||||
text-align: left
|
||||
form
|
||||
width: auto
|
||||
input[name=search-text]
|
||||
max-width: 15em
|
||||
.append
|
||||
font-size: 0.95em
|
||||
color: $inactive-link-color
|
||||
|
||||
.content-wrapper.tag
|
||||
width: 100%
|
||||
max-width: 40em
|
||||
h1
|
||||
word-break: break-all
|
||||
line-height: 130%
|
||||
margin-top: 0
|
||||
form, .messages
|
||||
width: 100%
|
||||
.tag-edit
|
||||
textarea
|
||||
height: 10em
|
||||
.tag-summary
|
||||
section
|
||||
&.description
|
||||
margin: 1.5em 0 0 0
|
||||
&.details
|
||||
vertical-align: top
|
||||
padding-right: 0.5em
|
||||
ul
|
||||
margin: 0
|
||||
padding: 0
|
||||
list-style-type: none
|
||||
li
|
||||
display: inline
|
||||
margin: 0
|
||||
padding: 0
|
||||
li:not(:last-of-type):after
|
||||
content: ', '
|
||||
ul:empty:after
|
||||
content: '(none)'
|
||||
section
|
||||
margin-bottom: 1em
|
||||
|
||||
.content-wrapper.tag-categories
|
||||
width: 100%
|
||||
max-width: 40em
|
||||
table
|
||||
border-spacing: 0
|
||||
width: 100%
|
||||
tr.default td
|
||||
background: $default-tag-category-background-color
|
||||
td, th
|
||||
padding: .4em
|
||||
&.color
|
||||
text-align: center
|
||||
&.usages
|
||||
text-align: center
|
||||
&.remove, &.set-default
|
||||
white-space: pre
|
||||
tfoot
|
||||
display: none
|
||||
.messages, form
|
||||
width: auto
|
39
client/css/user-list-view.styl
Normal file
39
client/css/user-list-view.styl
Normal file
@ -0,0 +1,39 @@
|
||||
@import colors
|
||||
|
||||
.user-list
|
||||
ul
|
||||
list-style-type: none
|
||||
padding: 0
|
||||
display: flex
|
||||
align-content: flex-end
|
||||
flex-wrap: wrap
|
||||
margin: 0 -0.5em
|
||||
li
|
||||
flex-grow: 1
|
||||
width: 20em
|
||||
margin: 0 0.5em 1em 0.5em
|
||||
padding: 0.75em
|
||||
vertical-align: top
|
||||
background: $top-navigation-color
|
||||
text-align: left
|
||||
.wrapper
|
||||
display: flex
|
||||
.details
|
||||
font-size: 90%
|
||||
line-height: 130%
|
||||
.thumbnail
|
||||
width: 3em
|
||||
height: 3em
|
||||
margin: 0.25em 0.6em 0 0
|
||||
|
||||
.user-list-header
|
||||
label
|
||||
display: none
|
||||
text-align: left
|
||||
form
|
||||
width: auto
|
||||
input[name=search-text]
|
||||
max-width: 15em
|
||||
.append
|
||||
font-size: 0.95em
|
||||
color: $inactive-link-color
|
29
client/css/user-registration.styl
Normal file
29
client/css/user-registration.styl
Normal file
@ -0,0 +1,29 @@
|
||||
@import colors
|
||||
|
||||
#user-registration
|
||||
padding-bottom: calc(2vw - 1em) !important
|
||||
form
|
||||
float: left
|
||||
margin-right: 3em
|
||||
margin-bottom: 1em
|
||||
.info
|
||||
float: left
|
||||
border-radius: 0.2em
|
||||
width: 20em
|
||||
margin-bottom: 1em
|
||||
ul
|
||||
line-height: 1.8em
|
||||
list-style-type: none
|
||||
margin: 0
|
||||
padding: 0
|
||||
li
|
||||
margin: 0
|
||||
padding: 0
|
||||
i
|
||||
margin-right: 0.5em
|
||||
i.fa
|
||||
color: $main-color
|
||||
p:first-child
|
||||
margin: 0 0 0.5em 0
|
||||
p:last-child
|
||||
margin-bottom: 0
|
43
client/css/user-view.styl
Normal file
43
client/css/user-view.styl
Normal file
@ -0,0 +1,43 @@
|
||||
#user
|
||||
width: 100%
|
||||
max-width: 35em
|
||||
nav.text-nav
|
||||
margin-bottom: 1.5em
|
||||
|
||||
#user-summary
|
||||
.thumbnail
|
||||
width: 6em
|
||||
height: 6em
|
||||
margin: 0 1.5em 1.5em 0
|
||||
float: left
|
||||
.basic-info
|
||||
list-style-type: none
|
||||
margin: 0
|
||||
div
|
||||
clear: both
|
||||
nav
|
||||
float: left
|
||||
width: 45%
|
||||
margin-right: 1em
|
||||
|
||||
#user-edit
|
||||
form
|
||||
width: 100%
|
||||
.avatar
|
||||
#avatar-content
|
||||
float: right
|
||||
width: 65%
|
||||
margin-top: .5em
|
||||
#avatar-radio
|
||||
float: left
|
||||
width: 30%
|
||||
&:after
|
||||
content: ' '
|
||||
display: block
|
||||
height: 1px
|
||||
clear: both
|
||||
|
||||
#user-delete form
|
||||
width: 100%
|
||||
|
||||
|
@ -1,106 +0,0 @@
|
||||
@import colors
|
||||
|
||||
#user-registration
|
||||
form
|
||||
float: left
|
||||
.info
|
||||
float: left
|
||||
margin-left: 3em
|
||||
border-radius: 0.2em
|
||||
width: 20em
|
||||
ul
|
||||
line-height: 1.8em
|
||||
list-style-type: none
|
||||
margin: 0
|
||||
padding: 0
|
||||
li
|
||||
margin: 0
|
||||
padding: 0
|
||||
i
|
||||
margin-right: 0.5em
|
||||
i.fa
|
||||
color: $main-color
|
||||
p:first-child
|
||||
margin: 0 0 0.5em 0
|
||||
|
||||
|
||||
#user
|
||||
width: 100%
|
||||
max-width: 35em
|
||||
nav.text-nav
|
||||
margin-bottom: 1.5em
|
||||
|
||||
#user-summary
|
||||
.thumbnail
|
||||
width: 6em
|
||||
height: 6em
|
||||
margin: 0 1.5em 1.5em 0
|
||||
float: left
|
||||
.basic-info
|
||||
list-style-type: none
|
||||
margin: 0
|
||||
div
|
||||
clear: both
|
||||
nav
|
||||
float: left
|
||||
width: 45%
|
||||
margin-right: 1em
|
||||
|
||||
#user-edit
|
||||
form, .messages
|
||||
width: 100%
|
||||
.avatar
|
||||
#avatar-content
|
||||
float: right
|
||||
width: 65%
|
||||
margin-top: .5em
|
||||
#avatar-radio
|
||||
float: left
|
||||
width: 30%
|
||||
&:after
|
||||
content: ' '
|
||||
display: block
|
||||
height: 1px
|
||||
clear: both
|
||||
|
||||
#user-delete form
|
||||
width: 100%
|
||||
|
||||
|
||||
.user-list
|
||||
ul
|
||||
list-style-type: none
|
||||
padding: 0
|
||||
display: flex
|
||||
align-content: flex-end
|
||||
flex-wrap: wrap
|
||||
margin: 0 -0.5em
|
||||
li
|
||||
flex-grow: 1
|
||||
width: 20em
|
||||
margin: 0 0.5em 1em 0.5em
|
||||
padding: 0.75em
|
||||
vertical-align: top
|
||||
background: $top-navigation-color
|
||||
text-align: left
|
||||
.wrapper
|
||||
display: flex
|
||||
.details
|
||||
font-size: 90%
|
||||
line-height: 130%
|
||||
.thumbnail
|
||||
width: 3em
|
||||
height: 3em
|
||||
margin: 0.25em 0.6em 0 0
|
||||
|
||||
.user-list-header
|
||||
label
|
||||
display: none
|
||||
text-align: left
|
||||
form
|
||||
width: auto
|
||||
input[name=search-text]
|
||||
max-width: 15em
|
||||
.append
|
||||
font-size: 0.95em
|
||||
color: $inactive-link-color
|
@ -12,37 +12,45 @@
|
||||
</div>
|
||||
|
||||
<div class='body'>
|
||||
<header><!--
|
||||
--><span class='nickname'><!--
|
||||
--><% if (ctx.comment.user && ctx.comment.user.name && ctx.canViewUsers) { %><!--
|
||||
--><a href='/user/<%- encodeURIComponent(ctx.comment.user.name) %>'><!--
|
||||
--><% } %><!--
|
||||
<header><%
|
||||
%><span class='nickname'><%
|
||||
%><% if (ctx.comment.user && ctx.comment.user.name && ctx.canViewUsers) { %><%
|
||||
%><a href='/user/<%- encodeURIComponent(ctx.comment.user.name) %>'><%
|
||||
%><% } %><%
|
||||
|
||||
--><%- ctx.comment.user ? ctx.comment.user.name : 'Deleted user' %><!--
|
||||
%><%- ctx.comment.user ? ctx.comment.user.name : 'Deleted user' %><%
|
||||
|
||||
--><% if (ctx.comment.user && ctx.comment.user.name && ctx.canViewUsers) { %><!--
|
||||
--></a><!--
|
||||
--><% } %><!--
|
||||
--></span><!--
|
||||
%><% if (ctx.comment.user && ctx.comment.user.name && ctx.canViewUsers) { %><%
|
||||
%></a><%
|
||||
%><% } %><%
|
||||
%></span><%
|
||||
|
||||
--><span class='date'><!--
|
||||
--><%= ctx.makeRelativeTime(ctx.comment.creationTime) %><!--
|
||||
--></span><!--
|
||||
%><wbr><%
|
||||
|
||||
--><span class='score-container'></span><!--
|
||||
%><span class='date'><%
|
||||
%><%= ctx.makeRelativeTime(ctx.comment.creationTime) %><%
|
||||
%></span><%
|
||||
|
||||
--><% if (ctx.canEditComment) { %><!--
|
||||
--><a href class='edit'><!--
|
||||
--><i class='fa fa-pencil'></i> edit<!--
|
||||
--></a><!--
|
||||
--><% } %><!--
|
||||
%><wbr><%
|
||||
|
||||
--><% if (ctx.canDeleteComment) { %><!--
|
||||
--><a href class='delete'><!--
|
||||
--><i class='fa fa-remove'></i> delete<!--
|
||||
--></a><!--
|
||||
--><% } %><!--
|
||||
--></header>
|
||||
%><span class='score-container'></span><%
|
||||
|
||||
%><wbr><%
|
||||
|
||||
%><% if (ctx.canEditComment) { %><%
|
||||
%><a href class='edit'><%
|
||||
%><i class='fa fa-pencil'></i> edit<%
|
||||
%></a><%
|
||||
%><% } %><%
|
||||
|
||||
%><wbr><%
|
||||
|
||||
%><% if (ctx.canDeleteComment) { %><%
|
||||
%><a href class='delete'><%
|
||||
%><i class='fa fa-remove'></i> delete<%
|
||||
%></a><%
|
||||
%><% } %><%
|
||||
%></header>
|
||||
|
||||
<div class='comment-form-container'></div>
|
||||
</div>
|
||||
|
@ -1,18 +1,18 @@
|
||||
<div class='tabs'>
|
||||
<form>
|
||||
<div class='tabs-wrapper'><!--
|
||||
--><div class='preview tab'><!--
|
||||
--><div class='comment-content-wrapper'><!--
|
||||
--><div class='comment-content'><!--
|
||||
--><%= ctx.makeMarkdown(ctx.comment.text) %><!--
|
||||
--></div><!--
|
||||
--></div><!--
|
||||
--></div><!--
|
||||
<div class='tabs-wrapper'><%
|
||||
%><div class='tab-wrapper'><%
|
||||
%><div class='preview tab'><%
|
||||
%><div class='comment-content'><%
|
||||
%><%= ctx.makeMarkdown(ctx.comment.text) %><%
|
||||
%></div><%
|
||||
%></div><%
|
||||
|
||||
--><div class='edit tab'><!--
|
||||
--><textarea required minlength=1><%- ctx.comment.text %></textarea><!--
|
||||
--></div><!--
|
||||
--></div>
|
||||
%><div class='edit tab'><%
|
||||
%><textarea required minlength=1><%- ctx.comment.text %></textarea><%
|
||||
%></div><%
|
||||
%></div><%
|
||||
%></div>
|
||||
|
||||
<nav class='buttons'>
|
||||
<ul>
|
||||
|
@ -66,6 +66,10 @@
|
||||
<td><code>type</code></td>
|
||||
<td>given type of posts. <code><value></code> can be either <code>image</code>, <code>animation</code> (or <code>animated</code> or <code>anim</code>), <code>flash</code> (or <code>swf</code>) or <code>video</code> (or <code>webm</code>).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>content-checksum</code></td>
|
||||
<td>having given SHA1 checksum</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>file-size</code></td>
|
||||
<td>having given file size (in bytes)</td>
|
||||
|
@ -1,10 +1,7 @@
|
||||
<div class='post-container'></div>
|
||||
<% if (ctx.featuredPost) { %>
|
||||
<aside>
|
||||
Featured post: <%= ctx.makePostLink(ctx.featuredPost.id, true) %>,
|
||||
posted
|
||||
<%= ctx.makeRelativeTime(ctx.featuredPost.creationTime) %>
|
||||
by
|
||||
<%= ctx.makeUserLink(ctx.featuredPost.user) %>
|
||||
Featured post: <%= ctx.makePostLink(ctx.featuredPost.id, true) %>,<wbr>
|
||||
posted <%= ctx.makeRelativeTime(ctx.featuredPost.creationTime) %> by <%= ctx.makeUserLink(ctx.featuredPost.user) %>
|
||||
</aside>
|
||||
<% } %>
|
||||
|
@ -1,10 +1,7 @@
|
||||
<%- ctx.postCount %> posts
|
||||
<span class=sep>•</span>
|
||||
<%= ctx.makeFileSize(ctx.diskUsage) %>
|
||||
<span class=sep>•</span>
|
||||
Build <a class='version' href='https://github.com/rr-/szurubooru/commits/master'><%- ctx.version %></a>
|
||||
from <%= ctx.makeRelativeTime(ctx.buildDate) %>
|
||||
<% if (ctx.canListSnapshots) { %>
|
||||
<span class=sep>•</span>
|
||||
<a href='/history'>History</a>
|
||||
<% } %>
|
||||
<ul>
|
||||
<li><%- ctx.postCount %> posts</li><span class='sep'>
|
||||
</span><li><%= ctx.makeFileSize(ctx.diskUsage) %></li><span class='sep'>
|
||||
</span><li>Build <a class='version' href='https://github.com/rr-/szurubooru/commits/master'><%- ctx.version %></a> from <%= ctx.makeRelativeTime(ctx.buildDate) %></li><span class='sep'>
|
||||
</span><% if (ctx.canListSnapshots) { %><li><a href='/history'>History</a></li><span class='sep'>
|
||||
</span><% } %>
|
||||
</ul>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'/>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>
|
||||
<title><!-- configured in the config file --></title>
|
||||
<link href='/css/app.min.css' rel='stylesheet' type='text/css'/>
|
||||
<link href='/css/vendor.min.css' rel='stylesheet' type='text/css'/>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<a class='prev disabled'>
|
||||
<% } %>
|
||||
<i class='fa fa-chevron-left'></i>
|
||||
<span>Previous page</span>
|
||||
<span class='vim-nav-hint'>< Previous page</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
<a class='next disabled'>
|
||||
<% } %>
|
||||
<i class='fa fa-chevron-right'></i>
|
||||
<span>Next page</span>
|
||||
<span class='vim-nav-hint'>Next page ></span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<div class='not-found'>
|
||||
<img src='/img/404.png' alt='404 Not found'/>
|
||||
<h1>Not found</h1>
|
||||
<p><%- ctx.path %> is not a valid URL.</p>
|
||||
<p><a href='/'>Back to main page</a></p>
|
||||
</div>
|
||||
|
12
client/html/post_detail.tpl
Normal file
12
client/html/post_detail.tpl
Normal file
@ -0,0 +1,12 @@
|
||||
<div class='content-wrapper' id='post'>
|
||||
<h1>Post #<%- ctx.post.id %></h1>
|
||||
<nav class='buttons'><!--
|
||||
--><ul><!--
|
||||
--><li><a href='/post/<%- ctx.post.id %>'><i class='fa fa-reply'></i> Main view</a></li><!--
|
||||
--><% if (ctx.canMerge) { %><!--
|
||||
--><li data-name='merge'><a href='/post/<%- ctx.post.id %>/merge'>Merge with…</a></li><!--
|
||||
--><% } %><!--
|
||||
--></ul><!--
|
||||
--></nav>
|
||||
<div class='post-content-holder'></div>
|
||||
</div>
|
@ -1,26 +1,32 @@
|
||||
<div class='edit-sidebar'>
|
||||
<form autocomplete='off'>
|
||||
<input type='submit' value='Save' class='submit'/>
|
||||
|
||||
<div class='messages'></div>
|
||||
|
||||
<% if (ctx.canEditPostSafety) { %>
|
||||
<section class='safety'>
|
||||
<label>Safety</label>
|
||||
<%= ctx.makeRadio({
|
||||
name: 'safety',
|
||||
class: 'safety-safe',
|
||||
value: 'safe',
|
||||
selectedValue: ctx.post.safety,
|
||||
text: 'Safe'}) %>
|
||||
<%= ctx.makeRadio({
|
||||
name: 'safety',
|
||||
class: 'safety-sketchy',
|
||||
value: 'sketchy',
|
||||
selectedValue: ctx.post.safety,
|
||||
text: 'Sketchy'}) %>
|
||||
<%= ctx.makeRadio({
|
||||
name: 'safety',
|
||||
value: 'unsafe',
|
||||
selectedValue: ctx.post.safety,
|
||||
class: 'safety-unsafe',
|
||||
text: 'Unsafe'}) %>
|
||||
<div class='radio-wrapper'>
|
||||
<%= ctx.makeRadio({
|
||||
name: 'safety',
|
||||
class: 'safety-safe',
|
||||
value: 'safe',
|
||||
selectedValue: ctx.post.safety,
|
||||
text: 'Safe'}) %>
|
||||
<%= ctx.makeRadio({
|
||||
name: 'safety',
|
||||
class: 'safety-sketchy',
|
||||
value: 'sketchy',
|
||||
selectedValue: ctx.post.safety,
|
||||
text: 'Sketchy'}) %>
|
||||
<%= ctx.makeRadio({
|
||||
name: 'safety',
|
||||
value: 'unsafe',
|
||||
selectedValue: ctx.post.safety,
|
||||
class: 'safety-unsafe',
|
||||
text: 'Unsafe'}) %>
|
||||
</div>
|
||||
</section>
|
||||
<% } %>
|
||||
|
||||
@ -78,21 +84,20 @@
|
||||
</section>
|
||||
<% } %>
|
||||
|
||||
<% if (ctx.canFeaturePosts) { %>
|
||||
<% if (ctx.canFeaturePosts || ctx.canDeletePosts || ctx.canMergePosts) { %>
|
||||
<section class='management'>
|
||||
<ul>
|
||||
<% if (ctx.canFeaturePosts) { %>
|
||||
<li><a href class='feature'>Feature this post on main page</a></li>
|
||||
<% } %>
|
||||
<% if (ctx.canMergePosts) { %>
|
||||
<li><a href class='merge'>Merge this post with another</a></li>
|
||||
<% } %>
|
||||
<% if (ctx.canDeletePosts) { %>
|
||||
<li><a href class='delete'>Delete this post</a></li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</section>
|
||||
<% } %>
|
||||
|
||||
<div class='messages'></div>
|
||||
|
||||
<input type='submit' value='Submit' class='submit'/>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -1,20 +1,6 @@
|
||||
<div class='content-wrapper transparent post-view'>
|
||||
<aside class='sidebar'>
|
||||
<nav class='buttons'>
|
||||
<article class='next-post'>
|
||||
<% if (ctx.nextPostId) { %>
|
||||
<% if (ctx.editMode) { %>
|
||||
<a href='<%= ctx.getPostEditUrl(ctx.nextPostId, ctx.parameters) %>'>
|
||||
<% } else { %>
|
||||
<a href='<%= ctx.getPostUrl(ctx.nextPostId, ctx.parameters) %>'>
|
||||
<% } %>
|
||||
<% } else { %>
|
||||
<a class='inactive'>
|
||||
<% } %>
|
||||
<i class='fa fa-chevron-left'></i>
|
||||
<span class='vim-nav-hint'>Next post</span>
|
||||
</a>
|
||||
</article>
|
||||
<article class='previous-post'>
|
||||
<% if (ctx.prevPostId) { %>
|
||||
<% if (ctx.editMode) { %>
|
||||
@ -24,9 +10,23 @@
|
||||
<% } %>
|
||||
<% } else { %>
|
||||
<a class='inactive'>
|
||||
<% } %>
|
||||
<i class='fa fa-chevron-left'></i>
|
||||
<span class='vim-nav-hint'>< Previous post</span>
|
||||
</a>
|
||||
</article>
|
||||
<article class='next-post'>
|
||||
<% if (ctx.nextPostId) { %>
|
||||
<% if (ctx.editMode) { %>
|
||||
<a href='<%= ctx.getPostEditUrl(ctx.nextPostId, ctx.parameters) %>'>
|
||||
<% } else { %>
|
||||
<a href='<%= ctx.getPostUrl(ctx.nextPostId, ctx.parameters) %>'>
|
||||
<% } %>
|
||||
<% } else { %>
|
||||
<a class='inactive'>
|
||||
<% } %>
|
||||
<i class='fa fa-chevron-right'></i>
|
||||
<span class='vim-nav-hint'>Previous post</span>
|
||||
<span class='vim-nav-hint'>Next post ></span>
|
||||
</a>
|
||||
</article>
|
||||
<article class='edit-post'>
|
23
client/html/post_merge.tpl
Normal file
23
client/html/post_merge.tpl
Normal file
@ -0,0 +1,23 @@
|
||||
<div class='post-merge'>
|
||||
<form>
|
||||
<ul>
|
||||
<li class='post-mirror'>
|
||||
<div class='left-post-container'></div>
|
||||
<div class='right-post-container'></div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<p>Tags, relations, scores, favorites and comments will be
|
||||
merged. All other properties need to be handled manually.</p>
|
||||
|
||||
<%= ctx.makeCheckbox({required: true, text: 'I confirm that I want to merge these posts.'}) %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class='messages'></div>
|
||||
|
||||
<div class='buttons'>
|
||||
<input type='submit' value='Merge posts'/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
48
client/html/post_merge_side.tpl
Normal file
48
client/html/post_merge_side.tpl
Normal file
@ -0,0 +1,48 @@
|
||||
<% if (ctx.editable) { %>
|
||||
<p>Post # <input type='text' pattern='^[0-9]+$' value='<%- ctx.post ? ctx.post.id : '' %>'/></p>
|
||||
<% } else { %>
|
||||
<p>Post # <input type='text' pattern='^[0-9]+$' value='<%- ctx.post ? ctx.post.id : '' %>' readonly/></p>
|
||||
<% } %>
|
||||
|
||||
<% if (ctx.post) { %>
|
||||
<div class='post-thumbnail'>
|
||||
<a rel='external' href='<%- ctx.post.contentUrl %>'>
|
||||
<%= ctx.makeThumbnail(ctx.post.thumbnailUrl) %>
|
||||
</a>
|
||||
</div>
|
||||
<div class='target-post'>
|
||||
<%= ctx.makeRadio({
|
||||
required: true,
|
||||
text: 'Merge to this post<br/><small>' +
|
||||
ctx.makeUserLink(ctx.post.user) +
|
||||
', ' +
|
||||
ctx.makeRelativeTime(ctx.post.creationTime) +
|
||||
'</small>',
|
||||
name: 'target-post',
|
||||
value: ctx.name,
|
||||
}) %>
|
||||
</div>
|
||||
<div class='target-post-content'>
|
||||
<%= ctx.makeRadio({
|
||||
required: true,
|
||||
text: 'Use this file<br/><small>' +
|
||||
ctx.makeFileSize(ctx.post.fileSize) + ' ' +
|
||||
{
|
||||
'image/gif': 'GIF',
|
||||
'image/jpeg': 'JPEG',
|
||||
'image/png': 'PNG',
|
||||
'video/webm': 'WEBM',
|
||||
'application/x-shockwave-flash': 'SWF',
|
||||
}[ctx.post.mimeType] +
|
||||
' (' +
|
||||
(ctx.post.canvasWidth ?
|
||||
`${ctx.post.canvasWidth}x${ctx.post.canvasHeight}` :
|
||||
'?') +
|
||||
')</small>',
|
||||
name: 'target-post-content',
|
||||
value: ctx.name,
|
||||
}) %>
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
<% } %>
|
@ -63,7 +63,7 @@
|
||||
<nav class='tags'>
|
||||
<h1>Tags (<%- ctx.post.tags.length %>)</h1>
|
||||
<% if (ctx.post.tags.length) { %>
|
||||
<ul class="compact-tags"><!--
|
||||
<ul class='compact-tags'><!--
|
||||
--><% for (let tag of ctx.post.tags) { %><!--
|
||||
--><li><!--
|
||||
--><% if (ctx.canViewTags) { %><!--
|
||||
|
@ -1,11 +1,23 @@
|
||||
<div class='post-upload'>
|
||||
<div id='post-upload'>
|
||||
<form>
|
||||
<div class='dropper-container'></div>
|
||||
|
||||
<ul class='uploadables-container'></ul>
|
||||
<div class='control-strip'>
|
||||
<input type='submit' value='Upload all' class='submit'/>
|
||||
|
||||
<span class='skip-duplicates'>
|
||||
<%= ctx.makeCheckbox({
|
||||
text: 'Skip duplicates',
|
||||
name: 'skip-duplicates',
|
||||
checked: false,
|
||||
}) %>
|
||||
</span>
|
||||
|
||||
<input type='button' value='Cancel' class='cancel'/>
|
||||
</div>
|
||||
|
||||
<div class='messages'></div>
|
||||
|
||||
<input type='submit' value='Upload all' class='submit'/>
|
||||
<ul class='uploadables-container'></ul>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -5,17 +5,21 @@
|
||||
<a href class='remove'><i class='fa fa-remove'></i></a>
|
||||
</div>
|
||||
|
||||
<div class='thumbnail'>
|
||||
<div class='thumbnail-wrapper'>
|
||||
<% if (['image'].includes(ctx.uploadable.type)) { %>
|
||||
|
||||
<%= ctx.makeThumbnail(ctx.uploadable.previewUrl) %>
|
||||
<a href='<%= ctx.uploadable.previewUrl %>'>
|
||||
<%= ctx.makeThumbnail(ctx.uploadable.previewUrl) %>
|
||||
</a>
|
||||
|
||||
<% } else if (['video'].includes(ctx.uploadable.type)) { %>
|
||||
|
||||
<div class='thumbnail'>
|
||||
<video id='video' nocontrols muted>
|
||||
<source type='<%- ctx.uploadable.mimeType %>' src='<%- ctx.uploadable.previewUrl %>'/>
|
||||
</video>
|
||||
<a href='<%= ctx.uploadable.previewUrl %>'>
|
||||
<video id='video' nocontrols muted>
|
||||
<source type='<%- ctx.uploadable.mimeType %>' src='<%- ctx.uploadable.previewUrl %>'/>
|
||||
</video>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<% } else { %>
|
||||
|
@ -1,22 +1,24 @@
|
||||
<div class='post-list-header'>
|
||||
<form class='horizontal search'>
|
||||
<%= ctx.makeTextInput({text: 'Search query', id: 'search-text', name: 'search-text', value: ctx.parameters.query}) %>
|
||||
<input class='mousetrap' type='submit' value='Search'/>
|
||||
<input data-safety=safe type='button' class='mousetrap safety safety-safe <%- ctx.settings.listPosts.safe ? '' : 'disabled' %>'/>
|
||||
<input data-safety=sketchy type='button' class='mousetrap safety safety-sketchy <%- ctx.settings.listPosts.sketchy ? '' : 'disabled' %>'/>
|
||||
<input data-safety=unsafe type='button' class='mousetrap safety safety-unsafe <%- ctx.settings.listPosts.unsafe ? '' : 'disabled' %>'/>
|
||||
<a class='mousetrap button append' href='/help/search/posts'>Syntax help</a>
|
||||
</form>
|
||||
<% if (ctx.canMassTag) { %>
|
||||
<form class='masstag horizontal'>
|
||||
<% if (ctx.parameters.tag) { %>
|
||||
<span class='append'>Tagging with:</span>
|
||||
<% } else { %>
|
||||
<a href class='mousetrap button append open-masstag'>Mass tag</a>
|
||||
<% } %>
|
||||
<%= ctx.makeTextInput({name: 'masstag', value: ctx.parameters.tag}) %>
|
||||
<input class='mousetrap start-tagging' type='submit' value='Start tagging'/>
|
||||
<a href class='mousetrap button append stop-tagging'>Stop tagging</a>
|
||||
</form>
|
||||
<% } %>
|
||||
</div>
|
||||
<div class='post-list-header'><%
|
||||
%><form class='horizontal'><%
|
||||
%><%= ctx.makeTextInput({text: 'Search query', id: 'search-text', name: 'search-text', value: ctx.parameters.query}) %><%
|
||||
%><wbr/><%
|
||||
%><input class='mousetrap' type='submit' value='Search'/><%
|
||||
%><wbr/><%
|
||||
%><input data-safety=safe type='button' class='mousetrap safety safety-safe <%- ctx.settings.listPosts.safe ? '' : 'disabled' %>'/><%
|
||||
%><input data-safety=sketchy type='button' class='mousetrap safety safety-sketchy <%- ctx.settings.listPosts.sketchy ? '' : 'disabled' %>'/><%
|
||||
%><input data-safety=unsafe type='button' class='mousetrap safety safety-unsafe <%- ctx.settings.listPosts.unsafe ? '' : 'disabled' %>'/><%
|
||||
%><wbr/><%
|
||||
%><a class='mousetrap button append' href='/help/search/posts'>Syntax help</a><%
|
||||
%><% if (ctx.canMassTag) { %><%
|
||||
%><wbr/><%
|
||||
%><span class='masstag'><%
|
||||
%><span class='append masstag-hint'>Tagging with:</span><%
|
||||
%><a href class='mousetrap button append open-masstag'>Mass tag</a><%
|
||||
%><wbr/><%
|
||||
%><%= ctx.makeTextInput({name: 'masstag', value: ctx.parameters.tag}) %><%
|
||||
%><input class='mousetrap start-tagging' type='submit' value='Start tagging'/><%
|
||||
%><a href class='mousetrap button append stop-tagging'>Stop tagging</a><%
|
||||
%></span><%
|
||||
%><% } %><%
|
||||
%></form><%
|
||||
%></div>
|
||||
|
@ -3,11 +3,9 @@
|
||||
<ul>
|
||||
<% for (let post of ctx.results) { %>
|
||||
<li>
|
||||
<% if (ctx.canViewPosts) { %>
|
||||
<a class='thumbnail-wrapper' href='<%= ctx.getPostUrl(post.id, ctx.parameters) %>' title='@<%- post.id %> (<%- post.type %>) Tags: <%- post.tags.map(tag => '#' + tag).join(' ') %>'>
|
||||
<% } else { %>
|
||||
<a class='thumbnail-wrapper'>
|
||||
<% } %>
|
||||
<a class='thumbnail-wrapper <%= post.tags.length > 0 ? "tags" : "no-tags" %>'
|
||||
title='@<%- post.id %> (<%- post.type %>) Tags: <%- post.tags.map(tag => '#' + tag).join(' ') || 'none' %>'
|
||||
href='<%= ctx.canViewPosts ? ctx.getPostUrl(post.id, ctx.parameters) : "" %>'>
|
||||
<%= ctx.makeThumbnail(post.thumbnailUrl) %>
|
||||
<span class='type' data-type='<%- post.type %>'>
|
||||
<%- post.type %>
|
||||
@ -16,7 +14,7 @@
|
||||
<span class='stats'>
|
||||
<% if (post.score) { %>
|
||||
<span class='icon'>
|
||||
<i class='fa fa-star'></i>
|
||||
<i class='fa fa-thumbs-up'></i>
|
||||
<%- post.score %>
|
||||
</span>
|
||||
<% } %>
|
||||
@ -35,7 +33,7 @@
|
||||
</span>
|
||||
<% } %>
|
||||
</a>
|
||||
<% if (ctx.canMassTagg && ctx.parameters && ctx.parameters.tag) { %>
|
||||
<% if (ctx.canMassTag && ctx.parameters && ctx.parameters.tag) { %>
|
||||
<a href data-post-id='<%= post.id %>' class='masstag'>
|
||||
</a>
|
||||
<% } %>
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
<li>
|
||||
<%= ctx.makeCheckbox({
|
||||
text: 'Endless scroll',
|
||||
text: 'Enable endless scroll',
|
||||
name: 'endless-scroll',
|
||||
checked: ctx.browsingSettings.endlessScroll,
|
||||
}) %>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div class='content-wrapper tag'>
|
||||
<div class='content-wrapper' id='tag'>
|
||||
<h1><%- ctx.tag.names[0] %></h1>
|
||||
<nav class='buttons'><!--
|
||||
--><ul><!--
|
||||
|
@ -1,14 +1,14 @@
|
||||
<div class='tag-merge'>
|
||||
<form>
|
||||
<p>Proceeding will remove this tag and retag its posts with the tag
|
||||
specified below. Aliases, suggestions and implications are discarded
|
||||
and need to be handled manually.</p>
|
||||
|
||||
<ul>
|
||||
<li class='target'>
|
||||
<%= ctx.makeTextInput({required: true, text: 'Target tag', pattern: ctx.tagNamePattern}) %>
|
||||
</li>
|
||||
<li class='confirm'>
|
||||
|
||||
<li>
|
||||
<p>Usages in posts, suggestions and implications will be
|
||||
merged. Category and aliases need to be handled manually.</p>
|
||||
|
||||
<%= ctx.makeCheckbox({required: true, text: 'I confirm that I want to merge this tag.'}) %>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -30,11 +30,11 @@
|
||||
<a href='/tags/query=sort:usages'>Usages</a>
|
||||
<% } %>
|
||||
</th>
|
||||
<th class='edit-time'>
|
||||
<% if (ctx.query == 'sort:last-edit-time') { %>
|
||||
<a href='/tags/query=-sort:last-edit-time'>Edit time</a>
|
||||
<th class='creation-time'>
|
||||
<% if (ctx.query == 'sort:creation-time') { %>
|
||||
<a href='/tags/query=-sort:creation-time'>Created on</a>
|
||||
<% } else { %>
|
||||
<a href='/tags/query=sort:last-edit-time'>Edit time</a>
|
||||
<a href='/tags/query=sort:creation-time'>Created on</a>
|
||||
<% } %>
|
||||
</th>
|
||||
</thead>
|
||||
@ -73,8 +73,8 @@
|
||||
<td class='usages'>
|
||||
<%- tag.postCount %>
|
||||
</td>
|
||||
<td class='edit-time'>
|
||||
<%= ctx.makeRelativeTime(tag.lastEditTime) %>
|
||||
<td class='creation-time'>
|
||||
<%= ctx.makeRelativeTime(tag.creationTime) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% } %>
|
||||
|
8433
client/img/404.ai
8433
client/img/404.ai
File diff suppressed because one or more lines are too long
Binary file not shown.
Before Width: | Height: | Size: 36 KiB |
@ -63,12 +63,17 @@ class Api extends events.EventTarget {
|
||||
|
||||
_process(url, requestFactory, data, files, options) {
|
||||
options = options || {};
|
||||
const fullUrl = this._getFullUrl(url);
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!options.noProgress) {
|
||||
nprogress.start();
|
||||
}
|
||||
const [fullUrl, query] = this._getFullUrl(url);
|
||||
|
||||
let abortFunction = null;
|
||||
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
let req = requestFactory(fullUrl);
|
||||
|
||||
req.set('Accept', 'application/json');
|
||||
if (query) {
|
||||
req.query(query);
|
||||
}
|
||||
if (data) {
|
||||
req.attach('metadata', new Blob([JSON.stringify(data)]));
|
||||
}
|
||||
@ -77,21 +82,49 @@ class Api extends events.EventTarget {
|
||||
req.attach(key, files[key] || new Blob());
|
||||
}
|
||||
}
|
||||
if (this.userName && this.userPassword) {
|
||||
req.auth(this.userName, this.userPassword);
|
||||
try {
|
||||
if (this.userName && this.userPassword) {
|
||||
req.auth(
|
||||
this.userName,
|
||||
encodeURIComponent(this.userPassword)
|
||||
.replace(/%([0-9A-F]{2})/g, (match, p1) => {
|
||||
return String.fromCharCode('0x' + p1);
|
||||
}));
|
||||
}
|
||||
} catch (e) {
|
||||
reject({
|
||||
title: 'Authentication error',
|
||||
description: 'Malformed credentials'});
|
||||
}
|
||||
req.set('Accept', 'application/json')
|
||||
.end((error, response) => {
|
||||
nprogress.done();
|
||||
if (error) {
|
||||
reject(response && response.body ? response.body : {
|
||||
'title': 'Networking error',
|
||||
'description': error.message});
|
||||
} else {
|
||||
resolve(response.body);
|
||||
}
|
||||
});
|
||||
|
||||
if (!options.noProgress) {
|
||||
nprogress.start();
|
||||
}
|
||||
|
||||
abortFunction = () => {
|
||||
req.abort(); // does *NOT* call the callback passed in .end()
|
||||
nprogress.done();
|
||||
reject({
|
||||
title: 'Cancelled',
|
||||
description:
|
||||
'The request was aborted due to user cancel.'});
|
||||
};
|
||||
|
||||
req.end((error, response) => {
|
||||
nprogress.done();
|
||||
if (error) {
|
||||
reject(response && response.body ? response.body : {
|
||||
title: 'Networking error',
|
||||
description: error.message});
|
||||
} else {
|
||||
resolve(response.body);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
promise.abort = () => abortFunction();
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
hasPrivilege(lookup) {
|
||||
@ -149,7 +182,7 @@ class Api extends events.EventTarget {
|
||||
resolve();
|
||||
this.dispatchEvent(new CustomEvent('login'));
|
||||
}, response => {
|
||||
reject(response.description);
|
||||
reject(response.description || response || 'Unknown error');
|
||||
this.logout();
|
||||
});
|
||||
});
|
||||
@ -176,8 +209,12 @@ class Api extends events.EventTarget {
|
||||
}
|
||||
|
||||
_getFullUrl(url) {
|
||||
return (config.apiUrl + '/' + encodeURI(url))
|
||||
.replace(/([^:])\/+/g, '$1/');
|
||||
const fullUrl =
|
||||
(config.apiUrl + '/' + url).replace(/([^:])\/+/g, '$1/');
|
||||
const matches = fullUrl.match(/^([^?]*)\??(.*)$/);
|
||||
const baseUrl = matches[1];
|
||||
const request = matches[2];
|
||||
return [baseUrl, request];
|
||||
}
|
||||
}
|
||||
|
||||
|
20
client/js/controllers/base_post_controller.js
Normal file
20
client/js/controllers/base_post_controller.js
Normal file
@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
const api = require('../api.js');
|
||||
const topNavigation = require('../models/top_navigation.js');
|
||||
const EmptyView = require('../views/empty_view.js');
|
||||
|
||||
class BasePostController {
|
||||
constructor(ctx) {
|
||||
if (!api.hasPrivilege('posts:view')) {
|
||||
this._view = new EmptyView();
|
||||
this._view.showError('You don\'t have privileges to view posts.');
|
||||
return;
|
||||
}
|
||||
|
||||
topNavigation.activate('posts');
|
||||
topNavigation.setTitle('Post #' + ctx.parameters.id.toString());
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BasePostController;
|
@ -22,7 +22,8 @@ class CommentsController {
|
||||
topNavigation.activate('comments');
|
||||
topNavigation.setTitle('Listing comments');
|
||||
|
||||
this._pageController = new PageController({
|
||||
this._pageController = new PageController();
|
||||
this._pageController.run({
|
||||
parameters: ctx.parameters,
|
||||
getClientUrlForPage: page => {
|
||||
const parameters = Object.assign(
|
||||
@ -31,7 +32,7 @@ class CommentsController {
|
||||
},
|
||||
requestPage: page => {
|
||||
return PostList.search(
|
||||
'sort:comment-date+comment-count-min:1', page, 10, fields);
|
||||
'sort:comment-date comment-count-min:1', page, 10, fields);
|
||||
},
|
||||
pageRenderer: pageCtx => {
|
||||
Object.assign(pageCtx, {
|
||||
|
@ -6,19 +6,25 @@ const ManualPageView = require('../views/manual_page_view.js');
|
||||
|
||||
class PageController {
|
||||
constructor(ctx) {
|
||||
if (settings.get().endlessScroll) {
|
||||
this._view = new EndlessPageView();
|
||||
} else {
|
||||
this._view = new ManualPageView();
|
||||
}
|
||||
}
|
||||
|
||||
get view() {
|
||||
return this._view;
|
||||
}
|
||||
|
||||
run(ctx) {
|
||||
const extendedContext = {
|
||||
getClientUrlForPage: ctx.getClientUrlForPage,
|
||||
parameters: ctx.parameters,
|
||||
};
|
||||
|
||||
ctx.headerContext = Object.assign({}, extendedContext);
|
||||
ctx.pageContext = Object.assign({}, extendedContext);
|
||||
|
||||
if (settings.get().endlessScroll) {
|
||||
this._view = new EndlessPageView(ctx);
|
||||
} else {
|
||||
this._view = new ManualPageView(ctx);
|
||||
}
|
||||
this._view.run(ctx);
|
||||
}
|
||||
|
||||
showSuccess(message) {
|
||||
|
86
client/js/controllers/post_detail_controller.js
Normal file
86
client/js/controllers/post_detail_controller.js
Normal file
@ -0,0 +1,86 @@
|
||||
'use strict';
|
||||
|
||||
const router = require('../router.js');
|
||||
const api = require('../api.js');
|
||||
const misc = require('../util/misc.js');
|
||||
const settings = require('../models/settings.js');
|
||||
const Comment = require('../models/comment.js');
|
||||
const Post = require('../models/post.js');
|
||||
const PostList = require('../models/post_list.js');
|
||||
const PostDetailView = require('../views/post_detail_view.js');
|
||||
const BasePostController = require('./base_post_controller.js');
|
||||
const EmptyView = require('../views/empty_view.js');
|
||||
|
||||
class PostDetailController extends BasePostController {
|
||||
constructor(ctx, section) {
|
||||
super(ctx);
|
||||
|
||||
Post.get(ctx.parameters.id).then(post => {
|
||||
this._id = ctx.parameters.id;
|
||||
post.addEventListener('change', e => this._evtSaved(e, section));
|
||||
|
||||
this._view = new PostDetailView({
|
||||
post: post,
|
||||
section: section,
|
||||
canMerge: api.hasPrivilege('posts:merge'),
|
||||
});
|
||||
|
||||
this._view.addEventListener('select', e => this._evtSelect(e));
|
||||
this._view.addEventListener('merge', e => this._evtMerge(e));
|
||||
}, errorMessage => {
|
||||
this._view = new EmptyView();
|
||||
this._view.showError(errorMessage);
|
||||
});
|
||||
}
|
||||
|
||||
showSuccess(message) {
|
||||
this._view.showSuccess(message);
|
||||
}
|
||||
|
||||
_evtSelect(e) {
|
||||
this._view.clearMessages();
|
||||
this._view.disableForm();
|
||||
Post.get(e.detail.postId).then(post => {
|
||||
this._view.selectPost(post);
|
||||
this._view.enableForm();
|
||||
}, errorMessage => {
|
||||
this._view.showError(errorMessage);
|
||||
this._view.enableForm();
|
||||
});
|
||||
}
|
||||
|
||||
_evtSaved(e, section) {
|
||||
misc.disableExitConfirmation();
|
||||
if (this._id !== e.detail.post.id) {
|
||||
router.replace(
|
||||
'/post/' + e.detail.post.id + '/' + section, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
_evtMerge(e) {
|
||||
this._view.clearMessages();
|
||||
this._view.disableForm();
|
||||
e.detail.post.merge(e.detail.targetPost.id, e.detail.useOldContent)
|
||||
.then(() => {
|
||||
this._view = new PostDetailView({
|
||||
post: e.detail.targetPost,
|
||||
section: 'merge',
|
||||
canMerge: api.hasPrivilege('posts:merge'),
|
||||
});
|
||||
this._view.showSuccess('Post merged.');
|
||||
router.replace(
|
||||
'/post/' + e.detail.targetPost.id + '/merge', null, false);
|
||||
}, errorMessage => {
|
||||
this._view.showError(errorMessage);
|
||||
this._view.enableForm();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = router => {
|
||||
router.enter(
|
||||
'/post/:id/merge',
|
||||
(ctx, next) => {
|
||||
ctx.controller = new PostDetailController(ctx, 'merge');
|
||||
});
|
||||
};
|
@ -26,37 +26,18 @@ class PostListController {
|
||||
topNavigation.setTitle('Listing posts');
|
||||
|
||||
this._ctx = ctx;
|
||||
this._pageController = new PageController({
|
||||
this._pageController = new PageController();
|
||||
|
||||
this._headerView = new PostsHeaderView({
|
||||
hostNode: this._pageController.view.pageHeaderHolderNode,
|
||||
parameters: ctx.parameters,
|
||||
getClientUrlForPage: page => {
|
||||
const parameters = Object.assign(
|
||||
{}, ctx.parameters, {page: page});
|
||||
return '/posts/' + misc.formatUrlParameters(parameters);
|
||||
},
|
||||
requestPage: page => {
|
||||
return PostList.search(
|
||||
this._decorateSearchQuery(ctx.parameters.query),
|
||||
page, settings.get().postsPerPage, fields);
|
||||
},
|
||||
headerRenderer: headerCtx => {
|
||||
Object.assign(headerCtx, {
|
||||
canMassTag: api.hasPrivilege('tags:masstag'),
|
||||
massTagTags: this._massTagTags,
|
||||
});
|
||||
return new PostsHeaderView(headerCtx);
|
||||
},
|
||||
pageRenderer: pageCtx => {
|
||||
Object.assign(pageCtx, {
|
||||
canViewPosts: api.hasPrivilege('posts:view'),
|
||||
canMassTag: api.hasPrivilege('tags:masstag'),
|
||||
massTagTags: this._massTagTags,
|
||||
});
|
||||
const view = new PostsPageView(pageCtx);
|
||||
view.addEventListener('tag', e => this._evtTag(e));
|
||||
view.addEventListener('untag', e => this._evtUntag(e));
|
||||
return view;
|
||||
},
|
||||
canMassTag: api.hasPrivilege('tags:masstag'),
|
||||
massTagTags: this._massTagTags,
|
||||
});
|
||||
this._headerView.addEventListener(
|
||||
'navigate', e => this._evtNavigate(e));
|
||||
|
||||
this._syncPageController();
|
||||
}
|
||||
|
||||
showSuccess(message) {
|
||||
@ -67,6 +48,15 @@ class PostListController {
|
||||
return (this._ctx.parameters.tag || '').split(/\s+/).filter(s => s);
|
||||
}
|
||||
|
||||
_evtNavigate(e) {
|
||||
history.pushState(
|
||||
null,
|
||||
window.title,
|
||||
'/posts/' + misc.formatUrlParameters(e.detail.parameters));
|
||||
Object.assign(this._ctx.parameters, e.detail.parameters);
|
||||
this._syncPageController();
|
||||
}
|
||||
|
||||
_evtTag(e) {
|
||||
for (let tag of this._massTagTags) {
|
||||
e.detail.post.addTag(tag);
|
||||
@ -100,11 +90,37 @@ class PostListController {
|
||||
}
|
||||
return text.trim();
|
||||
}
|
||||
|
||||
_syncPageController() {
|
||||
this._pageController.run({
|
||||
parameters: this._ctx.parameters,
|
||||
getClientUrlForPage: page => {
|
||||
return '/posts/' + misc.formatUrlParameters(
|
||||
Object.assign({}, this._ctx.parameters, {page: page}));
|
||||
},
|
||||
requestPage: page => {
|
||||
return PostList.search(
|
||||
this._decorateSearchQuery(this._ctx.parameters.query),
|
||||
page, settings.get().postsPerPage, fields);
|
||||
},
|
||||
pageRenderer: pageCtx => {
|
||||
Object.assign(pageCtx, {
|
||||
canViewPosts: api.hasPrivilege('posts:view'),
|
||||
canMassTag: api.hasPrivilege('tags:masstag'),
|
||||
massTagTags: this._massTagTags,
|
||||
});
|
||||
const view = new PostsPageView(pageCtx);
|
||||
view.addEventListener('tag', e => this._evtTag(e));
|
||||
view.addEventListener('untag', e => this._evtUntag(e));
|
||||
return view;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = router => {
|
||||
router.enter(
|
||||
'/posts/:parameters?',
|
||||
'/posts/:parameters(.*)?',
|
||||
(ctx, next) => { misc.parseUrlParametersRoute(ctx, next); },
|
||||
(ctx, next) => { ctx.controller = new PostListController(ctx); });
|
||||
};
|
||||
|
@ -7,26 +7,19 @@ const settings = require('../models/settings.js');
|
||||
const Comment = require('../models/comment.js');
|
||||
const Post = require('../models/post.js');
|
||||
const PostList = require('../models/post_list.js');
|
||||
const topNavigation = require('../models/top_navigation.js');
|
||||
const PostView = require('../views/post_view.js');
|
||||
const PostMainView = require('../views/post_main_view.js');
|
||||
const BasePostController = require('./base_post_controller.js');
|
||||
const EmptyView = require('../views/empty_view.js');
|
||||
|
||||
class PostController {
|
||||
constructor(id, editMode, ctx) {
|
||||
if (!api.hasPrivilege('posts:view')) {
|
||||
this._view = new EmptyView();
|
||||
this._view.showError('You don\'t have privileges to view posts.');
|
||||
return;
|
||||
}
|
||||
|
||||
topNavigation.activate('posts');
|
||||
topNavigation.setTitle('Post #' + id.toString());
|
||||
class PostMainController extends BasePostController {
|
||||
constructor(ctx, editMode) {
|
||||
super(ctx);
|
||||
|
||||
let parameters = ctx.parameters;
|
||||
Promise.all([
|
||||
Post.get(id),
|
||||
Post.get(ctx.parameters.id),
|
||||
PostList.getAround(
|
||||
id, this._decorateSearchQuery(
|
||||
ctx.parameters.id, this._decorateSearchQuery(
|
||||
parameters ? parameters.query : '')),
|
||||
]).then(responses => {
|
||||
const [post, aroundResponse] = responses;
|
||||
@ -36,17 +29,17 @@ class PostController {
|
||||
if (parameters.query) {
|
||||
ctx.state.parameters = parameters;
|
||||
const url = editMode ?
|
||||
'/post/' + id + '/edit' :
|
||||
'/post/' + id;
|
||||
'/post/' + ctx.parameters.id + '/edit' :
|
||||
'/post/' + ctx.parameters.id;
|
||||
router.replace(url, ctx.state, false);
|
||||
}
|
||||
|
||||
this._post = post;
|
||||
this._view = new PostView({
|
||||
this._view = new PostMainView({
|
||||
post: post,
|
||||
editMode: editMode,
|
||||
nextPostId: aroundResponse.next ? aroundResponse.next.id : null,
|
||||
prevPostId: aroundResponse.prev ? aroundResponse.prev.id : null,
|
||||
nextPostId: aroundResponse.next ? aroundResponse.next.id : null,
|
||||
canEditPosts: api.hasPrivilege('posts:edit'),
|
||||
canDeletePosts: api.hasPrivilege('posts:delete'),
|
||||
canFeaturePosts: api.hasPrivilege('posts:feature'),
|
||||
@ -72,6 +65,8 @@ class PostController {
|
||||
'feature', e => this._evtFeaturePost(e));
|
||||
this._view.sidebarControl.addEventListener(
|
||||
'delete', e => this._evtDeletePost(e));
|
||||
this._view.sidebarControl.addEventListener(
|
||||
'merge', e => this._evtMergePost(e));
|
||||
}
|
||||
|
||||
if (this._view.commentFormControl) {
|
||||
@ -128,6 +123,10 @@ class PostController {
|
||||
});
|
||||
}
|
||||
|
||||
_evtMergePost(e) {
|
||||
router.show('/post/' + e.detail.post.id + '/merge');
|
||||
}
|
||||
|
||||
_evtDeletePost(e) {
|
||||
this._view.sidebarControl.disableForm();
|
||||
this._view.sidebarControl.clearMessages();
|
||||
@ -255,23 +254,23 @@ class PostController {
|
||||
}
|
||||
|
||||
module.exports = router => {
|
||||
router.enter('/post/:id/edit/:parameters?',
|
||||
router.enter('/post/:id/edit/:parameters(.*)?',
|
||||
(ctx, next) => { misc.parseUrlParametersRoute(ctx, next); },
|
||||
(ctx, next) => {
|
||||
// restore parameters from history state
|
||||
if (ctx.state.parameters) {
|
||||
Object.assign(ctx.parameters, ctx.state.parameters);
|
||||
}
|
||||
ctx.controller = new PostController(ctx.parameters.id, true, ctx);
|
||||
ctx.controller = new PostMainController(ctx, true);
|
||||
});
|
||||
router.enter(
|
||||
'/post/:id/:parameters?',
|
||||
'/post/:id/:parameters(.*)?',
|
||||
(ctx, next) => { misc.parseUrlParametersRoute(ctx, next); },
|
||||
(ctx, next) => {
|
||||
// restore parameters from history state
|
||||
if (ctx.state.parameters) {
|
||||
Object.assign(ctx.parameters, ctx.state.parameters);
|
||||
}
|
||||
ctx.controller = new PostController(ctx.parameters.id, false, ctx);
|
||||
ctx.controller = new PostMainController(ctx, false);
|
||||
});
|
||||
};
|
@ -10,6 +10,8 @@ const EmptyView = require('../views/empty_view.js');
|
||||
|
||||
class PostUploadController {
|
||||
constructor() {
|
||||
this._lastPromise = null;
|
||||
|
||||
if (!api.hasPrivilege('posts:create')) {
|
||||
this._view = new EmptyView();
|
||||
this._view.showError('You don\'t have privileges to upload posts.');
|
||||
@ -23,6 +25,7 @@ class PostUploadController {
|
||||
});
|
||||
this._view.addEventListener('change', e => this._evtChange(e));
|
||||
this._view.addEventListener('submit', e => this._evtSubmit(e));
|
||||
this._view.addEventListener('cancel', e => this._evtCancel(e));
|
||||
}
|
||||
|
||||
_evtChange(e) {
|
||||
@ -34,28 +37,47 @@ class PostUploadController {
|
||||
this._view.clearMessages();
|
||||
}
|
||||
|
||||
_evtCancel(e) {
|
||||
if (this._lastPromise) {
|
||||
this._lastPromise.abort();
|
||||
}
|
||||
}
|
||||
|
||||
_evtSubmit(e) {
|
||||
this._view.disableForm();
|
||||
this._view.clearMessages();
|
||||
|
||||
e.detail.uploadables.reduce((promise, uploadable) => {
|
||||
return promise.then(
|
||||
() => {
|
||||
let post = new Post();
|
||||
post.safety = uploadable.safety;
|
||||
if (uploadable.url) {
|
||||
post.newContentUrl = uploadable.url;
|
||||
} else {
|
||||
post.newContent = uploadable.file;
|
||||
}
|
||||
return post.save(uploadable.anonymous)
|
||||
.then(() => {
|
||||
this._view.removeUploadable(uploadable);
|
||||
return promise.then(() => {
|
||||
let post = new Post();
|
||||
post.safety = uploadable.safety;
|
||||
if (uploadable.url) {
|
||||
post.newContentUrl = uploadable.url;
|
||||
} else {
|
||||
post.newContent = uploadable.file;
|
||||
}
|
||||
|
||||
let modelPromise = post.save(uploadable.anonymous);
|
||||
this._lastPromise = modelPromise;
|
||||
|
||||
return modelPromise
|
||||
.then(() => {
|
||||
this._view.removeUploadable(uploadable);
|
||||
return Promise.resolve();
|
||||
}).catch(errorMessage => {
|
||||
// XXX:
|
||||
// lame, API eats error codes so we need to match
|
||||
// messages instead
|
||||
if (e.detail.skipDuplicates &&
|
||||
errorMessage.match(/already uploaded/)) {
|
||||
return Promise.resolve();
|
||||
});
|
||||
});
|
||||
}, Promise.resolve()).then(
|
||||
() => {
|
||||
}
|
||||
return Promise.reject(errorMessage);
|
||||
});
|
||||
});
|
||||
}, Promise.resolve())
|
||||
|
||||
.then(() => {
|
||||
misc.disableExitConfirmation();
|
||||
const ctx = router.show('/posts');
|
||||
ctx.controller.showSuccess('Posts uploaded.');
|
||||
|
@ -19,7 +19,8 @@ class SnapshotsController {
|
||||
topNavigation.activate('');
|
||||
topNavigation.setTitle('History');
|
||||
|
||||
this._pageController = new PageController({
|
||||
this._pageController = new PageController();
|
||||
this._pageController.run({
|
||||
parameters: ctx.parameters,
|
||||
getClientUrlForPage: page => {
|
||||
const parameters = Object.assign(
|
||||
|
@ -22,7 +22,7 @@ class TagController {
|
||||
topNavigation.setTitle('Tag #' + tag.names[0]);
|
||||
|
||||
this._name = ctx.parameters.name;
|
||||
tag.addEventListener('change', e => this._evtSaved(e));
|
||||
tag.addEventListener('change', e => this._evtSaved(e, section));
|
||||
|
||||
const categories = {};
|
||||
for (let category of tags.getAllCategories()) {
|
||||
@ -57,10 +57,11 @@ class TagController {
|
||||
misc.enableExitConfirmation();
|
||||
}
|
||||
|
||||
_evtSaved(e) {
|
||||
_evtSaved(e, section) {
|
||||
misc.disableExitConfirmation();
|
||||
if (this._name !== e.detail.tag.names[0]) {
|
||||
router.replace('/tag/' + e.detail.tag.names[0], null, false);
|
||||
router.replace(
|
||||
'/tag/' + e.detail.tag.names[0] + '/' + section, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,6 +98,8 @@ class TagController {
|
||||
e.detail.tag.merge(e.detail.targetTagName).then(() => {
|
||||
this._view.showSuccess('Tag merged.');
|
||||
this._view.enableForm();
|
||||
router.replace(
|
||||
'/tag/' + e.detail.targetTagName + '/merge', null, false);
|
||||
}, errorMessage => {
|
||||
this._view.showError(errorMessage);
|
||||
this._view.enableForm();
|
||||
@ -118,16 +121,16 @@ class TagController {
|
||||
}
|
||||
|
||||
module.exports = router => {
|
||||
router.enter('/tag/:name', (ctx, next) => {
|
||||
ctx.controller = new TagController(ctx, 'summary');
|
||||
});
|
||||
router.enter('/tag/:name/edit', (ctx, next) => {
|
||||
router.enter('/tag/:name(.+?)/edit', (ctx, next) => {
|
||||
ctx.controller = new TagController(ctx, 'edit');
|
||||
});
|
||||
router.enter('/tag/:name/merge', (ctx, next) => {
|
||||
router.enter('/tag/:name(.+?)/merge', (ctx, next) => {
|
||||
ctx.controller = new TagController(ctx, 'merge');
|
||||
});
|
||||
router.enter('/tag/:name/delete', (ctx, next) => {
|
||||
router.enter('/tag/:name(.+?)/delete', (ctx, next) => {
|
||||
ctx.controller = new TagController(ctx, 'delete');
|
||||
});
|
||||
router.enter('/tag/:name(.+)', (ctx, next) => {
|
||||
ctx.controller = new TagController(ctx, 'summary');
|
||||
});
|
||||
};
|
||||
|
@ -10,7 +10,7 @@ const TagsPageView = require('../views/tags_page_view.js');
|
||||
const EmptyView = require('../views/empty_view.js');
|
||||
|
||||
const fields = [
|
||||
'names', 'suggestions', 'implications', 'lastEditTime', 'usages'];
|
||||
'names', 'suggestions', 'implications', 'creationTime', 'usages'];
|
||||
|
||||
class TagListController {
|
||||
constructor(ctx) {
|
||||
@ -23,27 +23,18 @@ class TagListController {
|
||||
topNavigation.activate('tags');
|
||||
topNavigation.setTitle('Listing tags');
|
||||
|
||||
this._pageController = new PageController({
|
||||
this._ctx = ctx;
|
||||
this._pageController = new PageController();
|
||||
|
||||
this._headerView = new TagsHeaderView({
|
||||
hostNode: this._pageController.view.pageHeaderHolderNode,
|
||||
parameters: ctx.parameters,
|
||||
getClientUrlForPage: page => {
|
||||
const parameters = Object.assign(
|
||||
{}, ctx.parameters, {page: page});
|
||||
return '/tags/' + misc.formatUrlParameters(parameters);
|
||||
},
|
||||
requestPage: page => {
|
||||
return TagList.search(ctx.parameters.query, page, 50, fields);
|
||||
},
|
||||
headerRenderer: headerCtx => {
|
||||
Object.assign(headerCtx, {
|
||||
canEditTagCategories:
|
||||
api.hasPrivilege('tagCategories:edit'),
|
||||
});
|
||||
return new TagsHeaderView(headerCtx);
|
||||
},
|
||||
pageRenderer: pageCtx => {
|
||||
return new TagsPageView(pageCtx);
|
||||
},
|
||||
canEditTagCategories: api.hasPrivilege('tagCategories:edit'),
|
||||
});
|
||||
this._headerView.addEventListener(
|
||||
'navigate', e => this._evtNavigate(e));
|
||||
|
||||
this._syncPageController();
|
||||
}
|
||||
|
||||
showSuccess(message) {
|
||||
@ -53,11 +44,38 @@ class TagListController {
|
||||
showError(message) {
|
||||
this._pageController.showError(message);
|
||||
}
|
||||
|
||||
_evtNavigate(e) {
|
||||
history.pushState(
|
||||
null,
|
||||
window.title,
|
||||
'/tags/' + misc.formatUrlParameters(e.detail.parameters));
|
||||
Object.assign(this._ctx.parameters, e.detail.parameters);
|
||||
this._syncPageController();
|
||||
}
|
||||
|
||||
_syncPageController() {
|
||||
this._pageController.run({
|
||||
parameters: this._ctx.parameters,
|
||||
getClientUrlForPage: page => {
|
||||
const parameters = Object.assign(
|
||||
{}, this._ctx.parameters, {page: page});
|
||||
return '/tags/' + misc.formatUrlParameters(parameters);
|
||||
},
|
||||
requestPage: page => {
|
||||
return TagList.search(
|
||||
this._ctx.parameters.query, page, 50, fields);
|
||||
},
|
||||
pageRenderer: pageCtx => {
|
||||
return new TagsPageView(pageCtx);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = router => {
|
||||
router.enter(
|
||||
'/tags/:parameters?',
|
||||
'/tags/:parameters(.*)?',
|
||||
(ctx, next) => { misc.parseUrlParametersRoute(ctx, next); },
|
||||
(ctx, next) => { ctx.controller = new TagListController(ctx); });
|
||||
};
|
||||
|
@ -26,7 +26,7 @@ class UserController {
|
||||
const infix = isLoggedIn ? 'self' : 'any';
|
||||
|
||||
this._name = userName;
|
||||
user.addEventListener('change', e => this._evtSaved(e));
|
||||
user.addEventListener('change', e => this._evtSaved(e, section));
|
||||
|
||||
const myRankIndex = api.user ?
|
||||
api.allRanks.indexOf(api.user.rank) :
|
||||
@ -73,11 +73,11 @@ class UserController {
|
||||
misc.enableExitConfirmation();
|
||||
}
|
||||
|
||||
_evtSaved(e) {
|
||||
_evtSaved(e, section) {
|
||||
misc.disableExitConfirmation();
|
||||
if (this._name !== e.detail.user.name) {
|
||||
router.replace(
|
||||
'/user/' + e.detail.user.name + '/edit', null, false);
|
||||
'/user/' + e.detail.user.name + '/' + section, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,18 +20,42 @@ class UserListController {
|
||||
topNavigation.activate('users');
|
||||
topNavigation.setTitle('Listing users');
|
||||
|
||||
this._pageController = new PageController({
|
||||
this._ctx = ctx;
|
||||
this._pageController = new PageController();
|
||||
|
||||
this._headerView = new UsersHeaderView({
|
||||
hostNode: this._pageController.view.pageHeaderHolderNode,
|
||||
parameters: ctx.parameters,
|
||||
});
|
||||
this._headerView.addEventListener(
|
||||
'navigate', e => this._evtNavigate(e));
|
||||
|
||||
this._syncPageController();
|
||||
}
|
||||
|
||||
showSuccess(message) {
|
||||
this._pageController.showSuccess(message);
|
||||
}
|
||||
|
||||
_evtNavigate(e) {
|
||||
history.pushState(
|
||||
null,
|
||||
window.title,
|
||||
'/users/' + misc.formatUrlParameters(e.detail.parameters));
|
||||
Object.assign(this._ctx.parameters, e.detail.parameters);
|
||||
this._syncPageController();
|
||||
}
|
||||
|
||||
_syncPageController() {
|
||||
this._pageController.run({
|
||||
parameters: this._ctx.parameters,
|
||||
getClientUrlForPage: page => {
|
||||
const parameters = Object.assign(
|
||||
{}, ctx.parameters, {page: page});
|
||||
{}, this._ctx.parameters, {page: page});
|
||||
return '/users/' + misc.formatUrlParameters(parameters);
|
||||
},
|
||||
requestPage: page => {
|
||||
return UserList.search(ctx.parameters.query, page);
|
||||
},
|
||||
headerRenderer: headerCtx => {
|
||||
return new UsersHeaderView(headerCtx);
|
||||
return UserList.search(this._ctx.parameters.query, page);
|
||||
},
|
||||
pageRenderer: pageCtx => {
|
||||
Object.assign(pageCtx, {
|
||||
@ -41,15 +65,11 @@ class UserListController {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
showSuccess(message) {
|
||||
this._pageController.showSuccess(message);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = router => {
|
||||
router.enter(
|
||||
'/users/:parameters?',
|
||||
'/users/:parameters(.*)?',
|
||||
(ctx, next) => { misc.parseUrlParametersRoute(ctx, next); },
|
||||
(ctx, next) => { ctx.controller = new UserListController(ctx); });
|
||||
};
|
||||
|
@ -28,6 +28,7 @@ class AutoCompleteControl {
|
||||
this._sourceInputNode = sourceInputNode;
|
||||
this._options = {};
|
||||
Object.assign(this._options, {
|
||||
transform: null,
|
||||
verticalShift: 2,
|
||||
source: null,
|
||||
addSpace: false,
|
||||
@ -37,27 +38,8 @@ class AutoCompleteControl {
|
||||
const start = _getSelectionStart(sourceInputNode);
|
||||
return value.substring(0, start).replace(/.*\s+/, '');
|
||||
},
|
||||
confirm: text => {
|
||||
const start = _getSelectionStart(sourceInputNode);
|
||||
let prefix = '';
|
||||
let suffix = sourceInputNode.value.substring(start);
|
||||
let middle = sourceInputNode.value.substring(0, start);
|
||||
const index = middle.lastIndexOf(' ');
|
||||
if (index !== -1) {
|
||||
prefix = sourceInputNode.value.substring(0, index + 1);
|
||||
middle = sourceInputNode.value.substring(index + 1);
|
||||
}
|
||||
sourceInputNode.value = prefix +
|
||||
this._results[this._activeResult].value +
|
||||
' ' +
|
||||
suffix.trimLeft();
|
||||
if (!this._options.addSpace) {
|
||||
sourceInputNode.value = sourceInputNode.value.trim();
|
||||
}
|
||||
sourceInputNode.focus();
|
||||
},
|
||||
delete: text => {
|
||||
},
|
||||
confirm: null,
|
||||
delete: null,
|
||||
getMatches: null,
|
||||
}, options);
|
||||
|
||||
@ -74,6 +56,43 @@ class AutoCompleteControl {
|
||||
this._isVisible = false;
|
||||
}
|
||||
|
||||
defaultConfirmStrategy(text) {
|
||||
const start = _getSelectionStart(this._sourceInputNode);
|
||||
let prefix = '';
|
||||
let suffix = this._sourceInputNode.value.substring(start);
|
||||
let middle = this._sourceInputNode.value.substring(0, start);
|
||||
const index = middle.lastIndexOf(' ');
|
||||
if (index !== -1) {
|
||||
prefix = this._sourceInputNode.value.substring(0, index + 1);
|
||||
middle = this._sourceInputNode.value.substring(index + 1);
|
||||
}
|
||||
this._sourceInputNode.value = prefix + text + ' ' + suffix.trimLeft();
|
||||
if (!this._options.addSpace) {
|
||||
this._sourceInputNode.value = this._sourceInputNode.value.trim();
|
||||
}
|
||||
this._sourceInputNode.focus();
|
||||
}
|
||||
|
||||
_delete(text) {
|
||||
if (this._options.transform) {
|
||||
text = this._options.transform(text);
|
||||
}
|
||||
if (this._options.delete) {
|
||||
this._options.delete(text);
|
||||
}
|
||||
}
|
||||
|
||||
_confirm(text) {
|
||||
if (this._options.transform) {
|
||||
text = this._options.transform(text);
|
||||
}
|
||||
if (this._options.confirm) {
|
||||
this._options.confirm(text);
|
||||
} else {
|
||||
this.defaultConfirmStrategy(text);
|
||||
}
|
||||
}
|
||||
|
||||
_show() {
|
||||
this._suggestionDiv.style.display = 'block';
|
||||
this._isVisible = true;
|
||||
@ -136,12 +155,12 @@ class AutoCompleteControl {
|
||||
func = () => { this._selectNext(); };
|
||||
} else if (key === KEY_RETURN && this._activeResult >= 0) {
|
||||
func = () => {
|
||||
this._options.confirm(this._getActiveSuggestion());
|
||||
this._confirm(this._getActiveSuggestion());
|
||||
this.hide();
|
||||
};
|
||||
} else if (key === KEY_DELETE && this._activeResult >= 0) {
|
||||
func = () => {
|
||||
this._options.delete(this._getActiveSuggestion());
|
||||
this._delete(this._getActiveSuggestion());
|
||||
this.hide();
|
||||
};
|
||||
}
|
||||
@ -229,7 +248,7 @@ class AutoCompleteControl {
|
||||
e => {
|
||||
e.preventDefault();
|
||||
this._activeResult = resultIndexWorkaround;
|
||||
this._options.confirm(this._getActiveSuggestion());
|
||||
this._confirm(this._getActiveSuggestion());
|
||||
this.hide();
|
||||
});
|
||||
listItem.appendChild(link);
|
||||
|
@ -64,7 +64,7 @@ class CommentFormControl extends events.EventTarget {
|
||||
|
||||
exitEditMode() {
|
||||
this._hostNode.classList.remove('editing');
|
||||
this._hostNode.querySelector('.tabs-wrapper').style.minHeight = null;
|
||||
this._hostNode.querySelector('.tab-wrapper').style.minHeight = null;
|
||||
views.clearMessages(this._hostNode);
|
||||
this.setText(this._comment.text);
|
||||
}
|
||||
@ -117,13 +117,15 @@ class CommentFormControl extends events.EventTarget {
|
||||
|
||||
_selectTab(tabName) {
|
||||
this._freezeTabHeights();
|
||||
const tabWrapperNode = this._hostNode.querySelector('.tab-wrapper');
|
||||
tabWrapperNode.setAttribute('data-tab', tabName);
|
||||
for (let tab of this._hostNode.querySelectorAll('.tab, .buttons li')) {
|
||||
tab.classList.toggle('active', tab.classList.contains(tabName));
|
||||
}
|
||||
}
|
||||
|
||||
_freezeTabHeights() {
|
||||
const tabsNode = this._hostNode.querySelector('.tabs-wrapper');
|
||||
const tabsNode = this._hostNode.querySelector('.tab-wrapper');
|
||||
const tabsHeight = tabsNode.getBoundingClientRect().height;
|
||||
tabsNode.style.minHeight = tabsHeight + 'px';
|
||||
}
|
||||
|
@ -40,7 +40,11 @@ class ExpanderControl {
|
||||
}
|
||||
|
||||
set title(newTitle) {
|
||||
this._expanderNode.querySelector('header span').textContent = newTitle;
|
||||
if (this._expanderNode) {
|
||||
this._expanderNode
|
||||
.querySelector('header span')
|
||||
.textContent = newTitle;
|
||||
}
|
||||
}
|
||||
|
||||
get _isOpened() {
|
||||
|
@ -65,7 +65,7 @@ class FileDropperControl extends events.EventTarget {
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
if (!url.match(/^https:?\/\/[^.]+\..+$/)) {
|
||||
if (!url.match(/^https?:\/\/[^.]+\..+$/)) {
|
||||
window.alert(`"${url}" does not look like a valid URL.`);
|
||||
return;
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ const views = require('../util/views.js');
|
||||
const optimizedResize = require('../util/optimized_resize.js');
|
||||
|
||||
class PostContentControl {
|
||||
constructor(containerNode, post, viewportSizeCalculator) {
|
||||
constructor(hostNode, post, viewportSizeCalculator) {
|
||||
this._post = post;
|
||||
this._viewportSizeCalculator = viewportSizeCalculator;
|
||||
this._containerNode = containerNode;
|
||||
this._hostNode = hostNode;
|
||||
this._template = views.getTemplate('post-content');
|
||||
|
||||
this._currentFitFunction = {
|
||||
@ -24,6 +24,10 @@ class PostContentControl {
|
||||
'changeContent', e => this._evtPostContentChange(e));
|
||||
}
|
||||
|
||||
disableOverlay() {
|
||||
this._hostNode.querySelector('.post-overlay').style.display = 'none';
|
||||
}
|
||||
|
||||
fitWidth() {
|
||||
this._currentFitFunction = this.fitWidth;
|
||||
const mul = this._post.canvasHeight / this._post.canvasWidth;
|
||||
@ -94,7 +98,7 @@ class PostContentControl {
|
||||
this._reinstall();
|
||||
optimizedResize.add(() => this._refreshSize());
|
||||
views.monitorNodeRemoval(
|
||||
this._containerNode, () => { this._uninstall(); });
|
||||
this._hostNode, () => { this._uninstall(); });
|
||||
}
|
||||
|
||||
_reinstall() {
|
||||
@ -103,9 +107,9 @@ class PostContentControl {
|
||||
newNode.classList.add('transparency-grid');
|
||||
}
|
||||
if (this._postContentNode) {
|
||||
this._containerNode.replaceChild(newNode, this._postContentNode);
|
||||
this._hostNode.replaceChild(newNode, this._postContentNode);
|
||||
} else {
|
||||
this._containerNode.appendChild(newNode);
|
||||
this._hostNode.appendChild(newNode);
|
||||
}
|
||||
this._postContentNode = newNode;
|
||||
this._refreshSize();
|
||||
|
@ -27,13 +27,16 @@ class PostEditSidebarControl extends events.EventTarget {
|
||||
canEditPostSource: api.hasPrivilege('posts:edit:source'),
|
||||
canEditPostTags: api.hasPrivilege('posts:edit:tags'),
|
||||
canEditPostRelations: api.hasPrivilege('posts:edit:relations'),
|
||||
canEditPostNotes: api.hasPrivilege('posts:edit:notes'),
|
||||
canEditPostNotes: api.hasPrivilege('posts:edit:notes') &&
|
||||
post.type !== 'video' &&
|
||||
post.type !== 'flash',
|
||||
canEditPostFlags: api.hasPrivilege('posts:edit:flags'),
|
||||
canEditPostContent: api.hasPrivilege('posts:edit:content'),
|
||||
canEditPostThumbnail: api.hasPrivilege('posts:edit:thumbnail'),
|
||||
canCreateAnonymousPosts: api.hasPrivilege('posts:create:anonymous'),
|
||||
canDeletePosts: api.hasPrivilege('posts:delete'),
|
||||
canFeaturePosts: api.hasPrivilege('posts:feature'),
|
||||
canMergePosts: api.hasPrivilege('posts:merge'),
|
||||
}));
|
||||
|
||||
new ExpanderControl(
|
||||
@ -106,6 +109,11 @@ class PostEditSidebarControl extends events.EventTarget {
|
||||
'click', e => this._evtFeatureClick(e));
|
||||
}
|
||||
|
||||
if (this._mergeLinkNode) {
|
||||
this._mergeLinkNode.addEventListener(
|
||||
'click', e => this._evtMergeClick(e));
|
||||
}
|
||||
|
||||
if (this._deleteLinkNode) {
|
||||
this._deleteLinkNode.addEventListener(
|
||||
'click', e => this._evtDeleteClick(e));
|
||||
@ -184,6 +192,15 @@ class PostEditSidebarControl extends events.EventTarget {
|
||||
}
|
||||
}
|
||||
|
||||
_evtMergeClick(e) {
|
||||
e.preventDefault();
|
||||
this.dispatchEvent(new CustomEvent('merge', {
|
||||
detail: {
|
||||
post: this._post,
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
_evtDeleteClick(e) {
|
||||
e.preventDefault();
|
||||
if (confirm('Are you sure you want to delete this post?')) {
|
||||
@ -242,7 +259,7 @@ class PostEditSidebarControl extends events.EventTarget {
|
||||
detail: {
|
||||
post: this._post,
|
||||
|
||||
safety: this._safetyButtonNodes.legnth ?
|
||||
safety: this._safetyButtonNodes.length ?
|
||||
Array.from(this._safetyButtonNodes)
|
||||
.filter(node => node.checked)[0]
|
||||
.value.toLowerCase() :
|
||||
@ -312,6 +329,10 @@ class PostEditSidebarControl extends events.EventTarget {
|
||||
return this._formNode.querySelector('.management .feature');
|
||||
}
|
||||
|
||||
get _mergeLinkNode() {
|
||||
return this._formNode.querySelector('.management .merge');
|
||||
}
|
||||
|
||||
get _deleteLinkNode() {
|
||||
return this._formNode.querySelector('.management .delete');
|
||||
}
|
||||
|
@ -199,10 +199,11 @@ class SelectedState extends ActiveState {
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
e.preventDefault();
|
||||
const args = offsetMap[e.which];
|
||||
if (e.shiftKey) {
|
||||
this._scaleEditedNote(...offsetMap[e.which]);
|
||||
this._scaleEditedNote(...args);
|
||||
} else {
|
||||
this._moveEditedNote(...offsetMap[e.which]);
|
||||
this._moveEditedNote(...args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -440,7 +441,7 @@ class DrawingRectangleState extends ActiveState {
|
||||
const width = (x2 - x1) * this._control.boundingBox.width;
|
||||
const height = (y2 - y1) * this._control.boundingBox.height;
|
||||
if (width < 20 && height < 20) {
|
||||
this._control._deletePolygonNode(this._note);
|
||||
this._control._deleteDomNode(this._note);
|
||||
this._control._state = new ReadyToDrawState(this._control);
|
||||
} else {
|
||||
this._control._post.notes.add(this._note);
|
||||
@ -523,7 +524,7 @@ class DrawingPolygonState extends ActiveState {
|
||||
}
|
||||
|
||||
_cancel() {
|
||||
this._control._deletePolygonNode(this._note);
|
||||
this._control._deleteDomNode(this._note);
|
||||
this._control._state = new ReadyToDrawState(this._control);
|
||||
}
|
||||
|
||||
@ -554,7 +555,7 @@ class PostNotesOverlayControl extends events.EventTarget {
|
||||
this._hostNode.appendChild(this._svgNode);
|
||||
this._post.addEventListener('change', e => this._evtPostChange(e));
|
||||
this._post.notes.addEventListener('remove', e => {
|
||||
this._deletePolygonNode(e.detail.note);
|
||||
this._deleteDomNode(e.detail.note);
|
||||
});
|
||||
|
||||
const keyHandler = e => this._evtCanvasKeyDown(e);
|
||||
@ -609,6 +610,10 @@ class PostNotesOverlayControl extends events.EventTarget {
|
||||
}
|
||||
|
||||
_evtCanvasKeyDown(e) {
|
||||
const illegalNodeNames = ['textarea', 'input', 'select'];
|
||||
if (illegalNodeNames.includes(e.target.nodeName.toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
this._state.evtCanvasKeyDown(e);
|
||||
}
|
||||
|
||||
@ -709,8 +714,8 @@ class PostNotesOverlayControl extends events.EventTarget {
|
||||
point.edgeNode.setAttribute('cy', point.y);
|
||||
}
|
||||
|
||||
_deletePolygonNode(note) {
|
||||
note.polygonNode.parentNode.removeChild(note.polygonNode);
|
||||
_deleteDomNode(note) {
|
||||
note.groupNode.parentNode.removeChild(note.groupNode);
|
||||
}
|
||||
|
||||
_createPolygonNode(note) {
|
||||
|
@ -6,8 +6,6 @@ const AutoCompleteControl = require('./auto_complete_control.js');
|
||||
|
||||
class TagAutoCompleteControl extends AutoCompleteControl {
|
||||
constructor(input, options) {
|
||||
const allTags = tags.getNameToTagMap();
|
||||
const caseSensitive = false;
|
||||
const minLengthForPartialSearch = 3;
|
||||
|
||||
options = Object.assign({
|
||||
@ -15,21 +13,18 @@ class TagAutoCompleteControl extends AutoCompleteControl {
|
||||
}, options);
|
||||
|
||||
options.getMatches = text => {
|
||||
const transform = caseSensitive ?
|
||||
x => x :
|
||||
x => x.toLowerCase();
|
||||
const transform = x => x.toLowerCase();
|
||||
const match = text.length < minLengthForPartialSearch ?
|
||||
(a, b) => a.startsWith(b) :
|
||||
(a, b) => a.includes(b);
|
||||
text = transform(text);
|
||||
return Array.from(allTags.entries())
|
||||
return Array.from(tags.getNameToTagMap().entries())
|
||||
.filter(kv => match(transform(kv[0]), text))
|
||||
.sort((kv1, kv2) => {
|
||||
return kv2[1].usages - kv1[1].usages;
|
||||
})
|
||||
.map(kv => {
|
||||
const origName = misc.escapeHtml(
|
||||
tags.getOriginalTagName(kv[0]));
|
||||
const origName = tags.getOriginalTagName(kv[0]);
|
||||
const category = kv[1].category;
|
||||
const usages = kv[1].usages;
|
||||
let cssName = misc.makeCssName(category, 'tag');
|
||||
@ -39,9 +34,9 @@ class TagAutoCompleteControl extends AutoCompleteControl {
|
||||
return {
|
||||
caption: misc.unindent`
|
||||
<span class="${cssName}">
|
||||
${origName} (${usages})
|
||||
${misc.escapeHtml(origName)} (${usages})
|
||||
</span>`,
|
||||
value: kv[0],
|
||||
value: origName,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
@ -135,6 +135,8 @@ class TagInputControl extends events.EventTarget {
|
||||
}
|
||||
|
||||
isTaggedWith(tagName) {
|
||||
let actualTag = null;
|
||||
[tagName, actualTag] = this._transformTagName(tagName);
|
||||
return this.tags
|
||||
.map(t => t.toLowerCase())
|
||||
.includes(tagName.toLowerCase());
|
||||
@ -153,6 +155,8 @@ class TagInputControl extends events.EventTarget {
|
||||
return;
|
||||
}
|
||||
|
||||
let actualTag = null;
|
||||
[tagName, actualTag] = this._transformTagName(tagName);
|
||||
if (!this.isTaggedWith(tagName)) {
|
||||
this.tags.push(tagName);
|
||||
}
|
||||
@ -177,6 +181,8 @@ class TagInputControl extends events.EventTarget {
|
||||
if (!tagName) {
|
||||
return;
|
||||
}
|
||||
let actualTag = null;
|
||||
[tagName, actualTag] = this._transformTagName(tagName);
|
||||
if (!this.isTaggedWith(tagName)) {
|
||||
return;
|
||||
}
|
||||
@ -270,7 +276,17 @@ class TagInputControl extends events.EventTarget {
|
||||
}
|
||||
}
|
||||
|
||||
_transformTagName(tagName) {
|
||||
const actualTag = tags.getTagByName(tagName);
|
||||
if (actualTag) {
|
||||
tagName = actualTag.names[0];
|
||||
}
|
||||
return [tagName, actualTag];
|
||||
}
|
||||
|
||||
_getListItemNodeFromTagName(tagName) {
|
||||
let actualTag = null;
|
||||
[tagName, actualTag] = this._transformTagName(tagName);
|
||||
for (let listItemNode of this._tagListNode.querySelectorAll('li')) {
|
||||
if (listItemNode.getAttribute('data-tag').toLowerCase() ===
|
||||
tagName.toLowerCase()) {
|
||||
@ -281,13 +297,11 @@ class TagInputControl extends events.EventTarget {
|
||||
}
|
||||
|
||||
_createListItemNode(tagName) {
|
||||
const actualTag = tags.getTagByName(tagName);
|
||||
let actualTag = null;
|
||||
[tagName, actualTag] = this._transformTagName(tagName);
|
||||
const className = actualTag ?
|
||||
misc.makeCssName(actualTag.category, 'tag') :
|
||||
null;
|
||||
if (actualTag) {
|
||||
tagName = actualTag.names[0];
|
||||
}
|
||||
|
||||
const tagLinkNode = document.createElement('a');
|
||||
if (className) {
|
||||
@ -352,8 +366,8 @@ class TagInputControl extends events.EventTarget {
|
||||
}, response => {
|
||||
return Promise.resolve([]);
|
||||
}).then(siblings => {
|
||||
let maxSiblingOccurrences = Math.max(
|
||||
1, ...siblings.map(s => s.occurrences));
|
||||
const args = siblings.map(s => s.occurrences);
|
||||
let maxSiblingOccurrences = Math.max(1, ...args);
|
||||
for (let sibling of siblings) {
|
||||
this._suggestions.set(
|
||||
sibling.tag.names[0],
|
||||
|
@ -34,7 +34,8 @@ controllers.push(require('./controllers/auth_controller.js'));
|
||||
controllers.push(require('./controllers/password_reset_controller.js'));
|
||||
controllers.push(require('./controllers/comments_controller.js'));
|
||||
controllers.push(require('./controllers/snapshots_controller.js'));
|
||||
controllers.push(require('./controllers/post_controller.js'));
|
||||
controllers.push(require('./controllers/post_detail_controller.js'));
|
||||
controllers.push(require('./controllers/post_main_controller.js'));
|
||||
controllers.push(require('./controllers/post_list_controller.js'));
|
||||
controllers.push(require('./controllers/post_upload_controller.js'));
|
||||
controllers.push(require('./controllers/tag_controller.js'));
|
||||
|
@ -7,13 +7,16 @@ class Info {
|
||||
static get() {
|
||||
return api.get('/info')
|
||||
.then(response => {
|
||||
if (response.featuredPost) {
|
||||
response.featuredPost =
|
||||
Post.fromResponse(response.featuredPost);
|
||||
}
|
||||
return Promise.resolve(response);
|
||||
return Promise.resolve(Object.assign(
|
||||
{},
|
||||
response,
|
||||
{
|
||||
featuredPost: response.featuredPost ?
|
||||
Post.fromResponse(response.featuredPost) :
|
||||
undefined
|
||||
}));
|
||||
}, response => {
|
||||
return Promise.reject(response.errorMessage);
|
||||
return Promise.reject(response.description);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,23 @@ const NoteList = require('./note_list.js');
|
||||
const CommentList = require('./comment_list.js');
|
||||
const misc = require('../util/misc.js');
|
||||
|
||||
function _syncObservableCollection(target, plainList) {
|
||||
target.clear();
|
||||
for (let item of (plainList || [])) {
|
||||
target.add(target.constructor._itemClass.fromResponse(item));
|
||||
}
|
||||
}
|
||||
|
||||
class Post extends events.EventTarget {
|
||||
constructor() {
|
||||
super();
|
||||
this._orig = {};
|
||||
|
||||
for (let obj of [this, this._orig]) {
|
||||
obj._notes = new NoteList();
|
||||
obj._comments = new CommentList();
|
||||
}
|
||||
|
||||
this._updateFromResponse({});
|
||||
}
|
||||
|
||||
@ -122,11 +135,11 @@ class Post extends events.EventTarget {
|
||||
files.thumbnail = this._newThumbnail;
|
||||
}
|
||||
|
||||
let promise = this._id ?
|
||||
let apiPromise = this._id ?
|
||||
api.put('/post/' + this._id, detail, files) :
|
||||
api.post('/posts', detail, files);
|
||||
|
||||
return promise.then(response => {
|
||||
let returnedPromise = apiPromise.then(response => {
|
||||
this._updateFromResponse(response);
|
||||
this.dispatchEvent(
|
||||
new CustomEvent('change', {detail: {post: this}}));
|
||||
@ -140,8 +153,18 @@ class Post extends events.EventTarget {
|
||||
}
|
||||
return Promise.resolve();
|
||||
}, response => {
|
||||
if (response.name === 'PostAlreadyUploadedError') {
|
||||
return Promise.reject(
|
||||
`Post already uploaded (@${response.otherPostId})`);
|
||||
}
|
||||
return Promise.reject(response.description);
|
||||
});
|
||||
|
||||
returnedPromise.abort = () => {
|
||||
apiPromise.abort();
|
||||
};
|
||||
|
||||
return returnedPromise;
|
||||
}
|
||||
|
||||
feature() {
|
||||
@ -167,6 +190,31 @@ class Post extends events.EventTarget {
|
||||
});
|
||||
}
|
||||
|
||||
merge(targetId, useOldContent) {
|
||||
return api.get('/post/' + encodeURIComponent(targetId))
|
||||
.then(response => {
|
||||
return api.post('/post-merge/', {
|
||||
removeVersion: this._version,
|
||||
remove: this._id,
|
||||
mergeToVersion: response.version,
|
||||
mergeTo: targetId,
|
||||
replaceContent: useOldContent,
|
||||
});
|
||||
}, response => {
|
||||
return Promise.reject(response);
|
||||
}).then(response => {
|
||||
this._updateFromResponse(response);
|
||||
this.dispatchEvent(new CustomEvent('change', {
|
||||
detail: {
|
||||
post: this,
|
||||
},
|
||||
}));
|
||||
return Promise.resolve();
|
||||
}, response => {
|
||||
return Promise.reject(response.description);
|
||||
});
|
||||
}
|
||||
|
||||
setScore(score) {
|
||||
return api.put('/post/' + this._id + '/score', {score: score})
|
||||
.then(response => {
|
||||
@ -260,9 +308,6 @@ class Post extends events.EventTarget {
|
||||
|
||||
_flags: [...response.flags || []],
|
||||
_tags: [...response.tags || []],
|
||||
_notes: NoteList.fromResponse([...response.notes || []]),
|
||||
_comments: CommentList.fromResponse(
|
||||
[...response.comments || []]),
|
||||
_relations: [...response.relations || []],
|
||||
|
||||
_score: response.score,
|
||||
@ -273,6 +318,11 @@ class Post extends events.EventTarget {
|
||||
_hasCustomThumbnail: response.hasCustomThumbnail,
|
||||
});
|
||||
|
||||
for (let obj of [this, this._orig]) {
|
||||
_syncObservableCollection(obj._notes, response.notes);
|
||||
_syncObservableCollection(obj._comments, response.comments);
|
||||
}
|
||||
|
||||
Object.assign(this, map());
|
||||
Object.assign(this._orig, map());
|
||||
}
|
||||
|
@ -6,7 +6,10 @@ const Post = require('./post.js');
|
||||
|
||||
class PostList extends AbstractList {
|
||||
static getAround(id, searchQuery) {
|
||||
return api.get(`/post/${id}/around?fields=id&query=${searchQuery}`)
|
||||
const url =
|
||||
`/post/${id}/around?fields=id` +
|
||||
`&query=${encodeURIComponent(searchQuery)}`;
|
||||
return api.get(url)
|
||||
.then(response => {
|
||||
return Promise.resolve(response);
|
||||
}).catch(response => {
|
||||
@ -16,7 +19,7 @@ class PostList extends AbstractList {
|
||||
|
||||
static search(text, page, pageSize, fields) {
|
||||
const url =
|
||||
`/posts/?query=${text}` +
|
||||
`/posts/?query=${encodeURIComponent(text)}` +
|
||||
`&page=${page}` +
|
||||
`&pageSize=${pageSize}` +
|
||||
`&fields=${fields.join(',')}`;
|
||||
|
@ -14,11 +14,12 @@ const defaultSettings = {
|
||||
transparencyGrid: true,
|
||||
fitMode: 'fit-both',
|
||||
tagSuggestions: true,
|
||||
postsPerPage: 40,
|
||||
postsPerPage: 42,
|
||||
};
|
||||
|
||||
class Settings extends events.EventTarget {
|
||||
save(newSettings, silent) {
|
||||
newSettings = Object.assign(this.get(), newSettings);
|
||||
localStorage.setItem('settings', JSON.stringify(newSettings));
|
||||
if (silent !== true) {
|
||||
this.dispatchEvent(new CustomEvent('change', {
|
||||
@ -30,8 +31,7 @@ class Settings extends events.EventTarget {
|
||||
}
|
||||
|
||||
get() {
|
||||
let ret = {};
|
||||
Object.assign(ret, defaultSettings);
|
||||
let ret = Object.assign({}, defaultSettings);
|
||||
try {
|
||||
Object.assign(ret, JSON.parse(localStorage.getItem('settings')));
|
||||
} catch (e) {
|
||||
|
@ -7,7 +7,7 @@ const Snapshot = require('./snapshot.js');
|
||||
class SnapshotList extends AbstractList {
|
||||
static search(text, page, pageSize) {
|
||||
const url =
|
||||
`/snapshots/?query=${text}` +
|
||||
`/snapshots/?query=${encodeURIComponent(text)}` +
|
||||
`&page=${page}` +
|
||||
`&pageSize=${pageSize}`;
|
||||
return api.get(url).then(response => {
|
||||
|
@ -45,7 +45,7 @@ class Tag extends events.EventTarget {
|
||||
const detail = {version: this._version};
|
||||
|
||||
// send only changed fields to avoid user privilege violation
|
||||
if (misc.arraysDiffer(this._names, this._orig._names)) {
|
||||
if (misc.arraysDiffer(this._names, this._orig._names, true)) {
|
||||
detail.names = this._names;
|
||||
}
|
||||
if (this._category !== this._orig._category) {
|
||||
|
@ -7,13 +7,15 @@ const Tag = require('./tag.js');
|
||||
class TagList extends AbstractList {
|
||||
static search(text, page, pageSize, fields) {
|
||||
const url =
|
||||
`/tags/?query=${text}` +
|
||||
`/tags/?query=${encodeURIComponent(text)}` +
|
||||
`&page=${page}` +
|
||||
`&pageSize=${pageSize}` +
|
||||
`&fields=${fields.join(',')}`;
|
||||
return api.get(url).then(response => {
|
||||
response.results = TagList.fromResponse(response.results);
|
||||
return Promise.resolve(response);
|
||||
return Promise.resolve(Object.assign(
|
||||
{},
|
||||
response,
|
||||
{results: TagList.fromResponse(response.results)}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ class TopNavigation extends events.EventTarget {
|
||||
}
|
||||
|
||||
setTitle(title) {
|
||||
document.oldTitle = null;
|
||||
document.title = config.name + (title ? (' – ' + title) : '');
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,9 @@ const User = require('./user.js');
|
||||
|
||||
class UserList extends AbstractList {
|
||||
static search(text, page) {
|
||||
const url = `/users/?query=${text}&page=${page}&pageSize=30`;
|
||||
const url =
|
||||
`/users/?query=${encodeURIComponent(text)}` +
|
||||
`&page=${page}&pageSize=30`;
|
||||
return api.get(url).then(response => {
|
||||
return Promise.resolve(Object.assign(
|
||||
{},
|
||||
|
@ -75,7 +75,7 @@ class Route {
|
||||
const keys = this.keys;
|
||||
const qsIndex = path.indexOf('?');
|
||||
const pathname = ~qsIndex ? path.slice(0, qsIndex) : path;
|
||||
const m = this.regexp.exec(decodeURIComponent(pathname));
|
||||
const m = this.regexp.exec(pathname);
|
||||
|
||||
if (!m) {
|
||||
return false;
|
||||
@ -137,8 +137,8 @@ class Router {
|
||||
}
|
||||
|
||||
show(path, state, push) {
|
||||
const oldPath = this.ctx ? this.ctx.path : ctx.path;
|
||||
const ctx = new Context(path, state);
|
||||
const oldPath = this.ctx ? this.ctx.path : ctx.path;
|
||||
this.dispatch(ctx, () => {
|
||||
if (ctx.path !== oldPath && push !== false) {
|
||||
ctx.pushState();
|
||||
|
@ -3,8 +3,8 @@
|
||||
const misc = require('./util/misc.js');
|
||||
const request = require('superagent');
|
||||
|
||||
let _tags = null;
|
||||
let _categories = null;
|
||||
let _tags = new Map();
|
||||
let _categories = new Map();
|
||||
let _stylesheet = null;
|
||||
|
||||
function getTagByName(name) {
|
||||
@ -112,14 +112,14 @@ function getSuggestions(tagName) {
|
||||
return actualTag.suggestions || [];
|
||||
}
|
||||
|
||||
module.exports = misc.arrayToObject([
|
||||
getAllCategories,
|
||||
getAllTags,
|
||||
getTagByName,
|
||||
getCategoryByName,
|
||||
getNameToTagMap,
|
||||
getOriginalTagName,
|
||||
refreshExport,
|
||||
getAllImplications,
|
||||
getSuggestions,
|
||||
], func => func.name);
|
||||
module.exports = {
|
||||
getAllCategories: getAllCategories,
|
||||
getAllTags: getAllTags,
|
||||
getTagByName: getTagByName,
|
||||
getCategoryByName: getCategoryByName,
|
||||
getNameToTagMap: getNameToTagMap,
|
||||
getOriginalTagName: getOriginalTagName,
|
||||
refreshExport: refreshExport,
|
||||
getAllImplications: getAllImplications,
|
||||
getSuggestions: getSuggestions,
|
||||
};
|
||||
|
165
client/js/util/markdown.js
Normal file
165
client/js/util/markdown.js
Normal file
@ -0,0 +1,165 @@
|
||||
'use strict';
|
||||
|
||||
const marked = require('marked');
|
||||
|
||||
class BaseMarkdownWrapper {
|
||||
preprocess(text) {
|
||||
return text;
|
||||
}
|
||||
|
||||
postprocess(text) {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
class SjisWrapper extends BaseMarkdownWrapper {
|
||||
constructor() {
|
||||
super();
|
||||
this.buf = [];
|
||||
}
|
||||
|
||||
preprocess(text) {
|
||||
return text.replace(
|
||||
/\[sjis\]((?:[^\[]|\[(?!\/?sjis\]))+)\[\/sjis\]/ig,
|
||||
(match, capture) => {
|
||||
var ret = '%%%SJIS' + this.buf.length;
|
||||
this.buf.push(capture);
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
|
||||
postprocess(text) {
|
||||
return text.replace(
|
||||
/(?:<p>)?%%%SJIS(\d+)(?:<\/p>)?/,
|
||||
(match, capture) => {
|
||||
return '<div class="sjis">' + this.buf[capture] + '</div>';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// fix \ before ~ being stripped away
|
||||
class TildeWrapper extends BaseMarkdownWrapper {
|
||||
preprocess(text) {
|
||||
return text.replace(/\\~/g, '%%%T');
|
||||
}
|
||||
|
||||
postprocess(text) {
|
||||
return text.replace(/%%%T/g, '\\~');
|
||||
}
|
||||
}
|
||||
|
||||
//prevent ^#... from being treated as headers, due to tag permalinks
|
||||
class TagPermalinkFixWrapper extends BaseMarkdownWrapper {
|
||||
preprocess(text) {
|
||||
return text.replace(/^#/g, '%%%#');
|
||||
}
|
||||
|
||||
postprocess(text) {
|
||||
return text.replace(/%%%#/g, '#');
|
||||
}
|
||||
}
|
||||
|
||||
//post, user and tags permalinks
|
||||
class EntityPermalinkWrapper extends BaseMarkdownWrapper {
|
||||
preprocess(text) {
|
||||
text = text.replace(
|
||||
/(^|^\(|(?:[^\]])\(|[\s<>\[\]\)])([+#@][a-zA-Z0-9_-]+)/g,
|
||||
'$1[$2]($2)');
|
||||
text = text.replace(/\]\(@(\d+)\)/g, '](/post/$1)');
|
||||
text = text.replace(/\]\(\+([a-zA-Z0-9_-]+)\)/g, '](/user/$1)');
|
||||
text = text.replace(/\]\(#([a-zA-Z0-9_-]+)\)/g, '](/posts/query=$1)');
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
class SearchPermalinkWrapper extends BaseMarkdownWrapper {
|
||||
postprocess(text) {
|
||||
return text.replace(
|
||||
/\[search\]((?:[^\[]|\[(?!\/?search\]))+)\[\/search\]/ig,
|
||||
'<a href="/posts/query=$1"><code>$1</code></a>');
|
||||
}
|
||||
}
|
||||
|
||||
class SpoilersWrapper extends BaseMarkdownWrapper {
|
||||
postprocess(text) {
|
||||
return text.replace(
|
||||
/\[spoiler\]((?:[^\[]|\[(?!\/?spoiler\]))+)\[\/spoiler\]/ig,
|
||||
'<span class="spoiler">$1</span>');
|
||||
}
|
||||
}
|
||||
|
||||
class SmallWrapper extends BaseMarkdownWrapper {
|
||||
postprocess(text) {
|
||||
return text.replace(
|
||||
/\[small\]((?:[^\[]|\[(?!\/?small\]))+)\[\/small\]/ig,
|
||||
'<small>$1</small>');
|
||||
}
|
||||
}
|
||||
|
||||
class StrikeThroughWrapper extends BaseMarkdownWrapper {
|
||||
postprocess(text) {
|
||||
text = text.replace(/(^|[^\\])(~~|~)([^~]+)\2/g, '$1<del>$3</del>');
|
||||
return text.replace(/\\~/g, '~');
|
||||
}
|
||||
}
|
||||
|
||||
function formatMarkdown(text) {
|
||||
const renderer = new marked.Renderer();
|
||||
const options = {
|
||||
renderer: renderer,
|
||||
breaks: true,
|
||||
sanitize: true,
|
||||
smartypants: true,
|
||||
};
|
||||
let wrappers = [
|
||||
new SjisWrapper(),
|
||||
new TildeWrapper(),
|
||||
new TagPermalinkFixWrapper(),
|
||||
new EntityPermalinkWrapper(),
|
||||
new SearchPermalinkWrapper(),
|
||||
new SpoilersWrapper(),
|
||||
new SmallWrapper(),
|
||||
new StrikeThroughWrapper(),
|
||||
];
|
||||
for (let wrapper of wrappers) {
|
||||
text = wrapper.preprocess(text);
|
||||
}
|
||||
text = marked(text, options);
|
||||
wrappers.reverse();
|
||||
for (let wrapper of wrappers) {
|
||||
text = wrapper.postprocess(text);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
function formatInlineMarkdown(text) {
|
||||
const renderer = new marked.Renderer();
|
||||
const options = {
|
||||
renderer: renderer,
|
||||
breaks: true,
|
||||
sanitize: true,
|
||||
smartypants: true,
|
||||
};
|
||||
let wrappers = [
|
||||
new TildeWrapper(),
|
||||
new EntityPermalinkWrapper(),
|
||||
new SearchPermalinkWrapper(),
|
||||
new SpoilersWrapper(),
|
||||
new SmallWrapper(),
|
||||
new StrikeThroughWrapper(),
|
||||
];
|
||||
for (let wrapper of wrappers) {
|
||||
text = wrapper.preprocess(text);
|
||||
}
|
||||
text = marked.inlineLexer(text, [], options);
|
||||
wrappers.reverse();
|
||||
for (let wrapper of wrappers) {
|
||||
text = wrapper.postprocess(text);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatMarkdown: formatMarkdown,
|
||||
formatInlineMarkdown: formatInlineMarkdown,
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const marked = require('marked');
|
||||
const markdown = require('./markdown.js');
|
||||
|
||||
function decamelize(str, sep) {
|
||||
sep = sep === undefined ? '-' : sep;
|
||||
@ -92,69 +92,11 @@ function formatRelativeTime(timeString) {
|
||||
}
|
||||
|
||||
function formatMarkdown(text) {
|
||||
const renderer = new marked.Renderer();
|
||||
return markdown.formatMarkdown(text);
|
||||
}
|
||||
|
||||
const options = {
|
||||
renderer: renderer,
|
||||
breaks: true,
|
||||
sanitize: true,
|
||||
smartypants: true,
|
||||
};
|
||||
|
||||
const sjis = [];
|
||||
|
||||
const preDecorator = text => {
|
||||
text = text.replace(
|
||||
/\[sjis\]((?:[^\[]|\[(?!\/?sjis\]))+)\[\/sjis\]/ig,
|
||||
(match, capture) => {
|
||||
var ret = '%%%SJIS' + sjis.length;
|
||||
sjis.push(capture);
|
||||
return ret;
|
||||
});
|
||||
//prevent ^#... from being treated as headers, due to tag permalinks
|
||||
text = text.replace(/^#/g, '%%%#');
|
||||
//fix \ before ~ being stripped away
|
||||
text = text.replace(/\\~/g, '%%%T');
|
||||
//post, user and tags premalinks
|
||||
text = text.replace(
|
||||
/(^|^\(|(?:[^\]])\(|[\s<>\[\]\)])([+#@][a-zA-Z0-9_-]+)/g,
|
||||
'$1[$2]($2)');
|
||||
text = text.replace(/\]\(@(\d+)\)/g, '](/post/$1)');
|
||||
text = text.replace(/\]\(\+([a-zA-Z0-9_-]+)\)/g, '](/user/$1)');
|
||||
text = text.replace(/\]\(#([a-zA-Z0-9_-]+)\)/g, '](/posts/query=$1)');
|
||||
return text;
|
||||
};
|
||||
|
||||
const postDecorator = text => {
|
||||
//restore fixes
|
||||
text = text.replace(/%%%T/g, '\\~');
|
||||
text = text.replace(/%%%#/g, '#');
|
||||
|
||||
text = text.replace(
|
||||
/(?:<p>)?%%%SJIS(\d+)(?:<\/p>)?/,
|
||||
(match, capture) => {
|
||||
return '<div class="sjis">' + sjis[capture] + '</div>';
|
||||
});
|
||||
|
||||
//search permalinks
|
||||
text = text.replace(
|
||||
/\[search\]((?:[^\[]|\[(?!\/?search\]))+)\[\/search\]/ig,
|
||||
'<a href="/posts/query=$1"><code>$1</code></a>');
|
||||
//spoilers
|
||||
text = text.replace(
|
||||
/\[spoiler\]((?:[^\[]|\[(?!\/?spoiler\]))+)\[\/spoiler\]/ig,
|
||||
'<span class="spoiler">$1</span>');
|
||||
//[small]
|
||||
text = text.replace(
|
||||
/\[small\]((?:[^\[]|\[(?!\/?small\]))+)\[\/small\]/ig,
|
||||
'<small>$1</small>');
|
||||
//strike-through
|
||||
text = text.replace(/(^|[^\\])(~~|~)([^~]+)\2/g, '$1<del>$3</del>');
|
||||
text = text.replace(/\\~/g, '~');
|
||||
return text;
|
||||
};
|
||||
|
||||
return postDecorator(marked(preDecorator(text), options));
|
||||
function formatInlineMarkdown(text) {
|
||||
return markdown.formatInlineMarkdown(text);
|
||||
}
|
||||
|
||||
function formatUrlParameters(dict) {
|
||||
@ -165,7 +107,7 @@ function formatUrlParameters(dict) {
|
||||
continue;
|
||||
}
|
||||
if (value) {
|
||||
result.push(`${key}=${value}`);
|
||||
result.push(`${key}=${encodeURIComponent(value)}`);
|
||||
}
|
||||
}
|
||||
return result.join(';');
|
||||
@ -252,43 +194,46 @@ function escapeHtml(unsafe) {
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
function arraysDiffer(source1, source2) {
|
||||
function arraysDiffer(source1, source2, orderImportant) {
|
||||
source1 = [...source1];
|
||||
source2 = [...source2];
|
||||
if (orderImportant === true) {
|
||||
if (source1.length !== source2.length) {
|
||||
return true;
|
||||
}
|
||||
for (let i = 0; i < source1.length; i++) {
|
||||
if (source1[i] !== source2[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
source1.filter(value => !source2.includes(value)).length > 0 ||
|
||||
source2.filter(value => !source1.includes(value)).length > 0);
|
||||
}
|
||||
|
||||
function arrayToObject(array, keySelector, valueSelector) {
|
||||
if (keySelector === undefined) {
|
||||
keySelector = item => item;
|
||||
}
|
||||
if (valueSelector === undefined) {
|
||||
valueSelector = item => item;
|
||||
}
|
||||
return array.reduce((obj, item) => {
|
||||
obj[keySelector(item)] = valueSelector(item);
|
||||
return obj;
|
||||
}, {});
|
||||
function escapeSearchTerm(text) {
|
||||
return text.replace(/([a-z_-]):/g, '$1\\:');
|
||||
}
|
||||
|
||||
module.exports = arrayToObject([
|
||||
range,
|
||||
formatUrlParameters,
|
||||
parseUrlParameters,
|
||||
parseUrlParametersRoute,
|
||||
formatRelativeTime,
|
||||
formatFileSize,
|
||||
formatMarkdown,
|
||||
unindent,
|
||||
enableExitConfirmation,
|
||||
disableExitConfirmation,
|
||||
confirmPageExit,
|
||||
escapeHtml,
|
||||
makeCssName,
|
||||
splitByWhitespace,
|
||||
arraysDiffer,
|
||||
decamelize,
|
||||
arrayToObject,
|
||||
], func => func.name);
|
||||
module.exports = {
|
||||
range: range,
|
||||
formatUrlParameters: formatUrlParameters,
|
||||
parseUrlParameters: parseUrlParameters,
|
||||
parseUrlParametersRoute: parseUrlParametersRoute,
|
||||
formatRelativeTime: formatRelativeTime,
|
||||
formatFileSize: formatFileSize,
|
||||
formatMarkdown: formatMarkdown,
|
||||
formatInlineMarkdown: formatInlineMarkdown,
|
||||
unindent: unindent,
|
||||
enableExitConfirmation: enableExitConfirmation,
|
||||
disableExitConfirmation: disableExitConfirmation,
|
||||
confirmPageExit: confirmPageExit,
|
||||
escapeHtml: escapeHtml,
|
||||
makeCssName: makeCssName,
|
||||
splitByWhitespace: splitByWhitespace,
|
||||
arraysDiffer: arraysDiffer,
|
||||
decamelize: decamelize,
|
||||
escapeSearchTerm: escapeSearchTerm,
|
||||
};
|
||||
|
17
client/js/util/search.js
Normal file
17
client/js/util/search.js
Normal file
@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
const misc = require('./misc.js');
|
||||
const keyboard = require('../util/keyboard.js');
|
||||
const views = require('./views.js');
|
||||
|
||||
function searchInputNodeFocusHelper(inputNode) {
|
||||
keyboard.bind('q', () => {
|
||||
inputNode.focus();
|
||||
inputNode.setSelectionRange(
|
||||
inputNode.value.length, inputNode.value.length);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
searchInputNodeFocusHelper: searchInputNodeFocusHelper,
|
||||
};
|
@ -53,35 +53,41 @@ function makeThumbnail(url) {
|
||||
|
||||
function makeRadio(options) {
|
||||
_imbueId(options);
|
||||
return makeVoidElement(
|
||||
'input',
|
||||
{
|
||||
id: options.id,
|
||||
name: options.name,
|
||||
value: options.value,
|
||||
type: 'radio',
|
||||
checked: options.selectedValue === options.value,
|
||||
disabled: options.readonly,
|
||||
required: options.required,
|
||||
}) +
|
||||
_makeLabel(options, {class: 'radio'});
|
||||
return makeNonVoidElement(
|
||||
'label',
|
||||
{for: options.id},
|
||||
makeVoidElement(
|
||||
'input',
|
||||
{
|
||||
id: options.id,
|
||||
name: options.name,
|
||||
value: options.value,
|
||||
type: 'radio',
|
||||
checked: options.selectedValue === options.value,
|
||||
disabled: options.readonly,
|
||||
required: options.required,
|
||||
}) +
|
||||
makeNonVoidElement('span', {class: 'radio'}, options.text));
|
||||
}
|
||||
|
||||
function makeCheckbox(options) {
|
||||
_imbueId(options);
|
||||
return makeVoidElement(
|
||||
'input',
|
||||
{
|
||||
id: options.id,
|
||||
name: options.name,
|
||||
value: options.value,
|
||||
type: 'checkbox',
|
||||
checked: options.checked !== undefined ?
|
||||
options.checked : false,
|
||||
disabled: options.readonly,
|
||||
required: options.required,
|
||||
}) +
|
||||
_makeLabel(options, {class: 'checkbox'});
|
||||
return makeNonVoidElement(
|
||||
'label',
|
||||
{for: options.id},
|
||||
makeVoidElement(
|
||||
'input',
|
||||
{
|
||||
id: options.id,
|
||||
name: options.name,
|
||||
value: options.value,
|
||||
type: 'checkbox',
|
||||
checked: options.checked !== undefined ?
|
||||
options.checked : false,
|
||||
disabled: options.readonly,
|
||||
required: options.required,
|
||||
}) +
|
||||
makeNonVoidElement('span', {class: 'checkbox'}, options.text));
|
||||
}
|
||||
|
||||
function makeSelect(options) {
|
||||
@ -178,8 +184,10 @@ function makePostLink(id, includeHash) {
|
||||
}
|
||||
return api.hasPrivilege('posts:view') ?
|
||||
makeNonVoidElement(
|
||||
'a', {'href': '/post/' + encodeURIComponent(id)}, text) :
|
||||
text;
|
||||
'a',
|
||||
{'href': '/post/' + encodeURIComponent(id)},
|
||||
misc.escapeHtml(text)) :
|
||||
misc.escapeHtml(text);
|
||||
}
|
||||
|
||||
function makeTagLink(name, includeHash) {
|
||||
@ -196,19 +204,21 @@ function makeTagLink(name, includeHash) {
|
||||
'href': '/tag/' + encodeURIComponent(name),
|
||||
'class': misc.makeCssName(category, 'tag'),
|
||||
},
|
||||
text) :
|
||||
misc.escapeHtml(text)) :
|
||||
makeNonVoidElement(
|
||||
'span',
|
||||
{'class': misc.makeCssName(category, 'tag')},
|
||||
text);
|
||||
misc.escapeHtml(text));
|
||||
}
|
||||
|
||||
function makeUserLink(user) {
|
||||
let text = makeThumbnail(user ? user.avatarUrl : null);
|
||||
text += user && user.name ? user.name : 'Anonymous';
|
||||
text += user && user.name ? misc.escapeHtml(user.name) : 'Anonymous';
|
||||
const link = user && api.hasPrivilege('users:view') ?
|
||||
makeNonVoidElement(
|
||||
'a', {'href': '/user/' + encodeURIComponent(user.name)}, text) :
|
||||
'a',
|
||||
{'href': '/user/' + encodeURIComponent(user.name)},
|
||||
text) :
|
||||
text;
|
||||
return makeNonVoidElement('span', {class: 'user'}, link);
|
||||
}
|
||||
@ -248,6 +258,25 @@ function makeVoidElement(name, attributes) {
|
||||
return `<${_serializeElement(name, attributes)}/>`;
|
||||
}
|
||||
|
||||
function emptyContent(target) {
|
||||
while (target.lastChild) {
|
||||
target.removeChild(target.lastChild);
|
||||
}
|
||||
}
|
||||
|
||||
function replaceContent(target, source) {
|
||||
emptyContent(target);
|
||||
if (source instanceof NodeList) {
|
||||
for (let child of [...source]) {
|
||||
target.appendChild(child);
|
||||
}
|
||||
} else if (source instanceof Node) {
|
||||
target.appendChild(source);
|
||||
} else if (source !== null) {
|
||||
throw `Invalid view source: ${source}`;
|
||||
}
|
||||
}
|
||||
|
||||
function showMessage(target, message, className) {
|
||||
if (!message) {
|
||||
message = 'Unknown message';
|
||||
@ -269,23 +298,27 @@ function showMessage(target, message, className) {
|
||||
}
|
||||
|
||||
function showError(target, message) {
|
||||
return showMessage(target, message, 'error');
|
||||
document.oldTitle = document.title;
|
||||
document.title = `! ${document.title}`;
|
||||
return showMessage(target, misc.formatInlineMarkdown(message), 'error');
|
||||
}
|
||||
|
||||
function showSuccess(target, message) {
|
||||
return showMessage(target, message, 'success');
|
||||
return showMessage(target, misc.formatInlineMarkdown(message), 'success');
|
||||
}
|
||||
|
||||
function showInfo(target, message) {
|
||||
return showMessage(target, message, 'info');
|
||||
return showMessage(target, misc.formatInlineMarkdown(message), 'info');
|
||||
}
|
||||
|
||||
function clearMessages(target) {
|
||||
if (document.oldTitle) {
|
||||
document.title = document.oldTitle;
|
||||
document.oldTitle = null;
|
||||
}
|
||||
const messagesHolder = target.querySelector('.messages');
|
||||
/* TODO: animate that */
|
||||
while (messagesHolder.lastChild) {
|
||||
messagesHolder.removeChild(messagesHolder.lastChild);
|
||||
}
|
||||
emptyContent(messagesHolder);
|
||||
}
|
||||
|
||||
function htmlToDom(html) {
|
||||
@ -336,31 +369,31 @@ function getTemplate(templatePath) {
|
||||
if (!ctx) {
|
||||
ctx = {};
|
||||
}
|
||||
Object.assign(ctx, misc.arrayToObject([
|
||||
getPostUrl,
|
||||
getPostEditUrl,
|
||||
makeRelativeTime,
|
||||
makeFileSize,
|
||||
makeMarkdown,
|
||||
makeThumbnail,
|
||||
makeRadio,
|
||||
makeCheckbox,
|
||||
makeSelect,
|
||||
makeInput,
|
||||
makeButton,
|
||||
makeTextarea,
|
||||
makeTextInput,
|
||||
makePasswordInput,
|
||||
makeEmailInput,
|
||||
makeColorInput,
|
||||
makePostLink,
|
||||
makeTagLink,
|
||||
makeUserLink,
|
||||
makeFlexboxAlign,
|
||||
makeAccessKey,
|
||||
misc.makeCssName,
|
||||
makeNumericInput,
|
||||
], func => func.name));
|
||||
Object.assign(ctx, {
|
||||
getPostUrl: getPostUrl,
|
||||
getPostEditUrl: getPostEditUrl,
|
||||
makeRelativeTime: makeRelativeTime,
|
||||
makeFileSize: makeFileSize,
|
||||
makeMarkdown: makeMarkdown,
|
||||
makeThumbnail: makeThumbnail,
|
||||
makeRadio: makeRadio,
|
||||
makeCheckbox: makeCheckbox,
|
||||
makeSelect: makeSelect,
|
||||
makeInput: makeInput,
|
||||
makeButton: makeButton,
|
||||
makeTextarea: makeTextarea,
|
||||
makeTextInput: makeTextInput,
|
||||
makePasswordInput: makePasswordInput,
|
||||
makeEmailInput: makeEmailInput,
|
||||
makeColorInput: makeColorInput,
|
||||
makePostLink: makePostLink,
|
||||
makeTagLink: makeTagLink,
|
||||
makeUserLink: makeUserLink,
|
||||
makeFlexboxAlign: makeFlexboxAlign,
|
||||
makeAccessKey: makeAccessKey,
|
||||
makeCssName: misc.makeCssName,
|
||||
makeNumericInput: makeNumericInput,
|
||||
});
|
||||
return htmlToDom(templateFactory(ctx));
|
||||
};
|
||||
}
|
||||
@ -394,25 +427,10 @@ function enableForm(form) {
|
||||
}
|
||||
}
|
||||
|
||||
function replaceContent(target, source) {
|
||||
while (target.lastChild) {
|
||||
target.removeChild(target.lastChild);
|
||||
}
|
||||
if (source instanceof NodeList) {
|
||||
for (let child of [...source]) {
|
||||
target.appendChild(child);
|
||||
}
|
||||
} else if (source instanceof Node) {
|
||||
target.appendChild(source);
|
||||
} else if (source !== null) {
|
||||
throw `Invalid view source: ${source}`;
|
||||
}
|
||||
}
|
||||
|
||||
function syncScrollPosition() {
|
||||
window.requestAnimationFrame(
|
||||
() => {
|
||||
if (history.state.hasOwnProperty('scrollX')) {
|
||||
if (history.state && history.state.hasOwnProperty('scrollX')) {
|
||||
window.scrollTo(history.state.scrollX, history.state.scrollY);
|
||||
} else {
|
||||
window.scrollTo(0, 0);
|
||||
@ -481,30 +499,30 @@ document.addEventListener('input', e => {
|
||||
// prevent opening buttons in new tabs
|
||||
document.addEventListener('click', e => {
|
||||
if (e.target.getAttribute('href') === '' && e.which === 2) {
|
||||
console.log('prevented');
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = misc.arrayToObject([
|
||||
htmlToDom,
|
||||
getTemplate,
|
||||
replaceContent,
|
||||
enableForm,
|
||||
disableForm,
|
||||
decorateValidator,
|
||||
makeVoidElement,
|
||||
makeNonVoidElement,
|
||||
makeTagLink,
|
||||
makePostLink,
|
||||
makeCheckbox,
|
||||
makeRadio,
|
||||
syncScrollPosition,
|
||||
slideDown,
|
||||
slideUp,
|
||||
monitorNodeRemoval,
|
||||
clearMessages,
|
||||
showError,
|
||||
showSuccess,
|
||||
showInfo,
|
||||
], func => func.name);
|
||||
module.exports = {
|
||||
htmlToDom: htmlToDom,
|
||||
getTemplate: getTemplate,
|
||||
emptyContent: emptyContent,
|
||||
replaceContent: replaceContent,
|
||||
enableForm: enableForm,
|
||||
disableForm: disableForm,
|
||||
decorateValidator: decorateValidator,
|
||||
makeVoidElement: makeVoidElement,
|
||||
makeNonVoidElement: makeNonVoidElement,
|
||||
makeTagLink: makeTagLink,
|
||||
makePostLink: makePostLink,
|
||||
makeCheckbox: makeCheckbox,
|
||||
makeRadio: makeRadio,
|
||||
syncScrollPosition: syncScrollPosition,
|
||||
slideDown: slideDown,
|
||||
slideUp: slideUp,
|
||||
monitorNodeRemoval: monitorNodeRemoval,
|
||||
clearMessages: clearMessages,
|
||||
showError: showError,
|
||||
showSuccess: showSuccess,
|
||||
showInfo: showInfo,
|
||||
};
|
||||
|
@ -9,27 +9,23 @@ const pageTemplate = views.getTemplate('endless-pager-page');
|
||||
class EndlessPageView {
|
||||
constructor(ctx) {
|
||||
this._hostNode = document.getElementById('content-holder');
|
||||
views.replaceContent(this._hostNode, holderTemplate());
|
||||
}
|
||||
|
||||
run(ctx) {
|
||||
this._active = true;
|
||||
this._working = 0;
|
||||
this._init = false;
|
||||
|
||||
this.clearMessages();
|
||||
views.emptyContent(this._pagesHolderNode);
|
||||
|
||||
this.threshold = window.innerHeight / 3;
|
||||
this.minPageShown = null;
|
||||
this.maxPageShown = null;
|
||||
this.totalPages = null;
|
||||
this.currentPage = null;
|
||||
|
||||
const sourceNode = holderTemplate();
|
||||
const pageHeaderHolderNode
|
||||
= sourceNode.querySelector('.page-header-holder');
|
||||
this._pagesHolderNode = sourceNode.querySelector('.pages-holder');
|
||||
views.replaceContent(this._hostNode, sourceNode);
|
||||
|
||||
ctx.headerContext.hostNode = pageHeaderHolderNode;
|
||||
if (ctx.headerRenderer) {
|
||||
ctx.headerRenderer(ctx.headerContext);
|
||||
}
|
||||
|
||||
this._loadPage(ctx, ctx.parameters.page, true).then(pageNode => {
|
||||
if (ctx.parameters.page !== 1) {
|
||||
pageNode.scrollIntoView();
|
||||
@ -40,6 +36,14 @@ class EndlessPageView {
|
||||
views.monitorNodeRemoval(this._pagesHolderNode, () => this._destroy());
|
||||
}
|
||||
|
||||
get pageHeaderHolderNode() {
|
||||
return this._hostNode.querySelector('.page-header-holder');
|
||||
}
|
||||
|
||||
get _pagesHolderNode() {
|
||||
return this._hostNode.querySelector('.pages-holder');
|
||||
}
|
||||
|
||||
_destroy() {
|
||||
this._active = false;
|
||||
}
|
||||
@ -162,6 +166,10 @@ class EndlessPageView {
|
||||
return pageNode;
|
||||
}
|
||||
|
||||
clearMessages() {
|
||||
views.clearMessages(this._hostNode);
|
||||
}
|
||||
|
||||
showSuccess(message) {
|
||||
views.showSuccess(this._hostNode, message);
|
||||
}
|
||||
|
@ -56,25 +56,17 @@ function _getPages(currentPage, pageNumbers, ctx) {
|
||||
class ManualPageView {
|
||||
constructor(ctx) {
|
||||
this._hostNode = document.getElementById('content-holder');
|
||||
views.replaceContent(this._hostNode, holderTemplate());
|
||||
}
|
||||
|
||||
const sourceNode = holderTemplate();
|
||||
const pageContentHolderNode
|
||||
= sourceNode.querySelector('.page-content-holder');
|
||||
const pageHeaderHolderNode
|
||||
= sourceNode.querySelector('.page-header-holder');
|
||||
const pageNavNode = sourceNode.querySelector('.page-nav');
|
||||
run(ctx) {
|
||||
const currentPage = ctx.parameters.page;
|
||||
|
||||
ctx.headerContext.hostNode = pageHeaderHolderNode;
|
||||
if (ctx.headerRenderer) {
|
||||
ctx.headerRenderer(ctx.headerContext);
|
||||
}
|
||||
|
||||
views.replaceContent(this._hostNode, sourceNode);
|
||||
this.clearMessages();
|
||||
views.emptyContent(this._pageNavNode);
|
||||
|
||||
ctx.requestPage(currentPage).then(response => {
|
||||
Object.assign(ctx.pageContext, response);
|
||||
ctx.pageContext.hostNode = pageContentHolderNode;
|
||||
ctx.pageContext.hostNode = this._pageContentHolderNode;
|
||||
ctx.pageRenderer(ctx.pageContext);
|
||||
|
||||
const totalPages = Math.ceil(response.total / response.pageSize);
|
||||
@ -94,7 +86,7 @@ class ManualPageView {
|
||||
|
||||
if (response.total) {
|
||||
views.replaceContent(
|
||||
pageNavNode,
|
||||
this._pageNavNode,
|
||||
navTemplate({
|
||||
prevLink: ctx.getClientUrlForPage(currentPage - 1),
|
||||
nextLink: ctx.getClientUrlForPage(currentPage + 1),
|
||||
@ -114,6 +106,22 @@ class ManualPageView {
|
||||
});
|
||||
}
|
||||
|
||||
get pageHeaderHolderNode() {
|
||||
return this._hostNode.querySelector('.page-header-holder');
|
||||
}
|
||||
|
||||
get _pageContentHolderNode() {
|
||||
return this._hostNode.querySelector('.page-content-holder');
|
||||
}
|
||||
|
||||
get _pageNavNode() {
|
||||
return this._hostNode.querySelector('.page-nav');
|
||||
}
|
||||
|
||||
clearMessages() {
|
||||
views.clearMessages(this._hostNode);
|
||||
}
|
||||
|
||||
showSuccess(message) {
|
||||
views.showSuccess(this._hostNode, message);
|
||||
}
|
||||
|
80
client/js/views/post_detail_view.js
Normal file
80
client/js/views/post_detail_view.js
Normal file
@ -0,0 +1,80 @@
|
||||
'use strict';
|
||||
|
||||
const events = require('../events.js');
|
||||
const views = require('../util/views.js');
|
||||
const PostMergeView = require('./post_merge_view.js');
|
||||
const EmptyView = require('../views/empty_view.js');
|
||||
|
||||
const template = views.getTemplate('post-detail');
|
||||
|
||||
class PostDetailView extends events.EventTarget {
|
||||
constructor(ctx) {
|
||||
super();
|
||||
|
||||
this._ctx = ctx;
|
||||
ctx.post.addEventListener('change', e => this._evtChange(e));
|
||||
ctx.section = ctx.section || 'summary';
|
||||
|
||||
this._hostNode = document.getElementById('content-holder');
|
||||
this._install();
|
||||
}
|
||||
|
||||
_install() {
|
||||
const ctx = this._ctx;
|
||||
views.replaceContent(this._hostNode, template(ctx));
|
||||
|
||||
for (let item of this._hostNode.querySelectorAll('[data-name]')) {
|
||||
item.classList.toggle(
|
||||
'active', item.getAttribute('data-name') === ctx.section);
|
||||
}
|
||||
|
||||
ctx.hostNode = this._hostNode.querySelector('.post-content-holder');
|
||||
if (ctx.section === 'merge') {
|
||||
if (!this._ctx.canMerge) {
|
||||
this._view = new EmptyView();
|
||||
this._view.showError(
|
||||
'You don\'t have privileges to merge posts.');
|
||||
} else {
|
||||
this._view = new PostMergeView(ctx);
|
||||
events.proxyEvent(this._view, this, 'select');
|
||||
events.proxyEvent(this._view, this, 'submit', 'merge');
|
||||
}
|
||||
|
||||
} else {
|
||||
// this._view = new PostSummaryView(ctx);
|
||||
}
|
||||
|
||||
views.syncScrollPosition();
|
||||
}
|
||||
|
||||
clearMessages() {
|
||||
this._view.clearMessages();
|
||||
}
|
||||
|
||||
enableForm() {
|
||||
this._view.enableForm();
|
||||
}
|
||||
|
||||
disableForm() {
|
||||
this._view.disableForm();
|
||||
}
|
||||
|
||||
showSuccess(message) {
|
||||
this._view.showSuccess(message);
|
||||
}
|
||||
|
||||
showError(message) {
|
||||
this._view.showError(message);
|
||||
}
|
||||
|
||||
selectPost(post) {
|
||||
this._view.selectPost(post);
|
||||
}
|
||||
|
||||
_evtChange(e) {
|
||||
this._ctx.post = e.detail.post;
|
||||
this._install(this._ctx);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PostDetailView;
|
@ -13,9 +13,9 @@ const PostEditSidebarControl =
|
||||
const CommentListControl = require('../controls/comment_list_control.js');
|
||||
const CommentFormControl = require('../controls/comment_form_control.js');
|
||||
|
||||
const template = views.getTemplate('post');
|
||||
const template = views.getTemplate('post-main');
|
||||
|
||||
class PostView {
|
||||
class PostMainView {
|
||||
constructor(ctx) {
|
||||
this._hostNode = document.getElementById('content-holder');
|
||||
|
||||
@ -51,6 +51,10 @@ class PostView {
|
||||
postContainerNode.querySelector('.post-overlay'),
|
||||
ctx.post);
|
||||
|
||||
if (ctx.post.type === 'video' || ctx.post.type === 'flash') {
|
||||
this._postContentControl.disableOverlay();
|
||||
}
|
||||
|
||||
this._installSidebar(ctx);
|
||||
this._installCommentForm();
|
||||
this._installComments(ctx.post.comments);
|
||||
@ -63,13 +67,13 @@ class PostView {
|
||||
}
|
||||
});
|
||||
keyboard.bind(['a', 'left'], () => {
|
||||
if (ctx.nextPostId) {
|
||||
router.show('/post/' + ctx.nextPostId);
|
||||
if (ctx.prevPostId) {
|
||||
router.show('/post/' + ctx.prevPostId);
|
||||
}
|
||||
});
|
||||
keyboard.bind(['d', 'right'], () => {
|
||||
if (ctx.prevPostId) {
|
||||
router.show('/post/' + ctx.prevPostId);
|
||||
if (ctx.nextPostId) {
|
||||
router.show('/post/' + ctx.nextPostId);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -114,4 +118,4 @@ class PostView {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PostView;
|
||||
module.exports = PostMainView;
|
129
client/js/views/post_merge_view.js
Normal file
129
client/js/views/post_merge_view.js
Normal file
@ -0,0 +1,129 @@
|
||||
'use strict';
|
||||
|
||||
const config = require('../config.js');
|
||||
const events = require('../events.js');
|
||||
const views = require('../util/views.js');
|
||||
|
||||
const KEY_RETURN = 13;
|
||||
const template = views.getTemplate('post-merge');
|
||||
const sideTemplate = views.getTemplate('post-merge-side');
|
||||
|
||||
class PostMergeView extends events.EventTarget {
|
||||
constructor(ctx) {
|
||||
super();
|
||||
|
||||
this._ctx = ctx;
|
||||
this._post = ctx.post;
|
||||
this._hostNode = ctx.hostNode;
|
||||
|
||||
this._leftPost = ctx.post;
|
||||
this._rightPost = null;
|
||||
views.replaceContent(this._hostNode, template(this._ctx));
|
||||
views.decorateValidator(this._formNode);
|
||||
|
||||
this._refreshLeftSide();
|
||||
this._refreshRightSide();
|
||||
|
||||
this._formNode.addEventListener('submit', e => this._evtSubmit(e));
|
||||
}
|
||||
|
||||
clearMessages() {
|
||||
views.clearMessages(this._hostNode);
|
||||
}
|
||||
|
||||
enableForm() {
|
||||
views.enableForm(this._formNode);
|
||||
}
|
||||
|
||||
disableForm() {
|
||||
views.disableForm(this._formNode);
|
||||
}
|
||||
|
||||
showSuccess(message) {
|
||||
views.showSuccess(this._hostNode, message);
|
||||
}
|
||||
|
||||
showError(message) {
|
||||
views.showError(this._hostNode, message);
|
||||
}
|
||||
|
||||
selectPost(post) {
|
||||
this._rightPost = post;
|
||||
this._refreshRightSide();
|
||||
}
|
||||
|
||||
_refreshLeftSide() {
|
||||
views.replaceContent(
|
||||
this._leftSideNode,
|
||||
sideTemplate(Object.assign({}, this._ctx, {
|
||||
post: this._leftPost,
|
||||
name: 'left',
|
||||
editable: false})));
|
||||
}
|
||||
|
||||
_refreshRightSide() {
|
||||
views.replaceContent(
|
||||
this._rightSideNode,
|
||||
sideTemplate(Object.assign({}, this._ctx, {
|
||||
post: this._rightPost,
|
||||
name: 'right',
|
||||
editable: true})));
|
||||
|
||||
if (this._targetPostFieldNode) {
|
||||
this._targetPostFieldNode.addEventListener(
|
||||
'keydown', e => this._evtTargetPostFieldKeyDown(e));
|
||||
}
|
||||
}
|
||||
|
||||
_evtSubmit(e) {
|
||||
e.preventDefault();
|
||||
const checkedTargetPost = this._formNode.querySelector(
|
||||
'.target-post :checked').value;
|
||||
const checkedTargetPostContent = this._formNode.querySelector(
|
||||
'.target-post-content :checked').value;
|
||||
this.dispatchEvent(new CustomEvent('submit', {
|
||||
detail: {
|
||||
post: checkedTargetPost == 'left' ?
|
||||
this._rightPost :
|
||||
this._leftPost,
|
||||
targetPost: checkedTargetPost == 'left' ?
|
||||
this._leftPost :
|
||||
this._rightPost,
|
||||
useOldContent: checkedTargetPostContent !== checkedTargetPost,
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
_evtTargetPostFieldKeyDown(e) {
|
||||
const key = e.which;
|
||||
if (key !== KEY_RETURN) {
|
||||
return;
|
||||
}
|
||||
e.target.blur();
|
||||
e.preventDefault();
|
||||
this.dispatchEvent(new CustomEvent('select', {
|
||||
detail: {
|
||||
postId: this._targetPostFieldNode.value,
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
get _formNode() {
|
||||
return this._hostNode.querySelector('form');
|
||||
}
|
||||
|
||||
get _leftSideNode() {
|
||||
return this._hostNode.querySelector('.left-post-container');
|
||||
}
|
||||
|
||||
get _rightSideNode() {
|
||||
return this._hostNode.querySelector('.right-post-container');
|
||||
}
|
||||
|
||||
get _targetPostFieldNode() {
|
||||
return this._formNode.querySelector(
|
||||
'.post-mirror input:not([readonly])[type=text]');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PostMergeView;
|
@ -133,9 +133,12 @@ class PostUploadView extends events.EventTarget {
|
||||
super();
|
||||
this._ctx = ctx;
|
||||
this._hostNode = document.getElementById('content-holder');
|
||||
|
||||
views.replaceContent(this._hostNode, template());
|
||||
views.syncScrollPosition();
|
||||
|
||||
this._cancelButtonNode.disabled = true;
|
||||
|
||||
this._uploadables = new Map();
|
||||
this._contentFileDropper = new FileDropperControl(
|
||||
this._contentInputNode,
|
||||
@ -149,16 +152,22 @@ class PostUploadView extends events.EventTarget {
|
||||
this._contentFileDropper.addEventListener(
|
||||
'urladd', e => this._evtUrlsAdded(e));
|
||||
|
||||
this._cancelButtonNode.addEventListener(
|
||||
'click', e => this._evtCancelButtonClick(e));
|
||||
this._formNode.addEventListener('submit', e => this._evtFormSubmit(e));
|
||||
this._formNode.classList.add('inactive');
|
||||
}
|
||||
|
||||
enableForm() {
|
||||
views.enableForm(this._formNode);
|
||||
this._cancelButtonNode.disabled = true;
|
||||
this._formNode.classList.remove('uploading');
|
||||
}
|
||||
|
||||
disableForm() {
|
||||
views.disableForm(this._formNode);
|
||||
this._cancelButtonNode.disabled = false;
|
||||
this._formNode.classList.add('uploading');
|
||||
}
|
||||
|
||||
clearMessages() {
|
||||
@ -223,6 +232,11 @@ class PostUploadView extends events.EventTarget {
|
||||
this.addUploadables(e.detail.urls.map(url => new Url(url)));
|
||||
}
|
||||
|
||||
_evtCancelButtonClick(e) {
|
||||
e.preventDefault();
|
||||
this._emit('cancel');
|
||||
}
|
||||
|
||||
_evtFormSubmit(e) {
|
||||
e.preventDefault();
|
||||
this._emit('submit');
|
||||
@ -230,11 +244,17 @@ class PostUploadView extends events.EventTarget {
|
||||
|
||||
_evtRemoveClick(e, uploadable) {
|
||||
e.preventDefault();
|
||||
if (this._uploading) {
|
||||
return;
|
||||
}
|
||||
this.removeUploadable(uploadable);
|
||||
}
|
||||
|
||||
_evtMoveUpClick(e, uploadable) {
|
||||
e.preventDefault();
|
||||
if (this._uploading) {
|
||||
return;
|
||||
}
|
||||
let sortedUploadables = this._getSortedUploadables();
|
||||
if (uploadable.order > 0) {
|
||||
uploadable.order--;
|
||||
@ -247,6 +267,9 @@ class PostUploadView extends events.EventTarget {
|
||||
|
||||
_evtMoveDownClick(e, uploadable) {
|
||||
e.preventDefault();
|
||||
if (this._uploading) {
|
||||
return;
|
||||
}
|
||||
let sortedUploadables = this._getSortedUploadables();
|
||||
if (uploadable.order + 1 < sortedUploadables.length) {
|
||||
uploadable.order++;
|
||||
@ -282,7 +305,10 @@ class PostUploadView extends events.EventTarget {
|
||||
this.dispatchEvent(
|
||||
new CustomEvent(
|
||||
eventType,
|
||||
{detail: {uploadables: this._getSortedUploadables()}}));
|
||||
{detail: {
|
||||
uploadables: this._getSortedUploadables(),
|
||||
skipDuplicates: this._skipDuplicatesCheckboxNode.checked,
|
||||
}}));
|
||||
}
|
||||
|
||||
_createRowNode(uploadable) {
|
||||
@ -318,6 +344,10 @@ class PostUploadView extends events.EventTarget {
|
||||
rowNode.querySelector('.thumbnail').childNodes);
|
||||
}
|
||||
|
||||
get _uploading() {
|
||||
return this._formNode.classList.contains('uploading');
|
||||
}
|
||||
|
||||
get _listNode() {
|
||||
return this._hostNode.querySelector('.uploadables-container');
|
||||
}
|
||||
@ -326,10 +356,18 @@ class PostUploadView extends events.EventTarget {
|
||||
return this._hostNode.querySelector('form');
|
||||
}
|
||||
|
||||
get _skipDuplicatesCheckboxNode() {
|
||||
return this._hostNode.querySelector('form [name=skip-duplicates]');
|
||||
}
|
||||
|
||||
get _submitButtonNode() {
|
||||
return this._hostNode.querySelector('form [type=submit]');
|
||||
}
|
||||
|
||||
get _cancelButtonNode() {
|
||||
return this._hostNode.querySelector('form .cancel');
|
||||
}
|
||||
|
||||
get _contentInputNode() {
|
||||
return this._formNode.querySelector('.dropper-container');
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user