Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ef48070eeb | |||
| ff50857071 | |||
| 8116854f74 | |||
| 05a69cd839 | |||
| a93e59069a | |||
| be55d3686a | |||
| f5f1136a1f | |||
| 90fbfb0e34 | |||
| a4716de4f5 | |||
| 08c5594622 | |||
| 3fa49b9ad6 | |||
| 3d8a443166 | |||
| 43b47e374f | |||
| 7199d5ecf4 | |||
| 1932e8910b | |||
| b97b8d718f | |||
| ad33f96a17 | |||
| 8ee3bca212 | |||
| 7565d46f01 | |||
| a5e3b74843 | |||
| 56c475c779 | |||
| aed2c2a9cb | |||
| e7d57c9d7a | |||
| 6d4d637585 | |||
| 0c3a608992 | |||
| f6a9d4c58d | |||
| 601a444da2 | |||
| a2888e2f37 | |||
| 1aa50cd661 | |||
| c021a2fa58 | |||
| f70ce23843 | |||
| 8bca6e5b1e | |||
| 05aad972d6 | |||
| b539919550 | |||
| 6b45b4d53d | |||
| e79910b915 | |||
| bb008bc0fa | |||
| 50b1274b98 | |||
| 9e2328bf73 | |||
| 99f99d39f7 | |||
| cb647745f4 | |||
| 6f7ad41591 | |||
| 486948ad6f | |||
| 1f3e49738e |
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
node_modules/
|
||||
/build/
|
||||
build.*
|
||||
*.log
|
||||
|
||||
4
.gitmodules
vendored
@@ -1,7 +1,3 @@
|
||||
[submodule "src/react-lazyload"]
|
||||
path = src/react-lazyload
|
||||
url = https://github.com/xmcp/react-lazyload
|
||||
|
||||
[submodule "src/infrastructure"]
|
||||
path = src/infrastructure
|
||||
url = https://github.com/thuhole/infrastructure
|
||||
|
||||
10
.travis.yml
@@ -1,10 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 12
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
|
||||
after_success:
|
||||
- chmod +x ./travis_deploy.sh
|
||||
- ./travis_deploy.sh
|
||||
856
LICENSE.txt
@@ -1,674 +1,182 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://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 <https://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
|
||||
<https://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
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are 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.
|
||||
|
||||
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.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
|
||||
|
||||
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 Affero 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. Remote Network Interaction; Use with the GNU General Public License.
|
||||
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
|
||||
|
||||
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 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 work with which it is combined will remain governed by version 3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU Affero 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 Affero 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 Affero 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 Affero 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
|
||||
|
||||
44
README.md
@@ -1,10 +1,16 @@
|
||||
网页版 T大树洞:[https://thuhole.com/](https://thuhole.com/)
|
||||
网页版 新T树洞:[https://hole.thu.monster](https://hole.thu.monster)
|
||||
|
||||
## 部署
|
||||
|
||||
推荐使用yarn
|
||||
|
||||
+ 本地调试 `yarn start`
|
||||
+ 打包部署 `yarn run build`
|
||||
|
||||

|
||||
|
||||
## 浏览器兼容
|
||||
|
||||
下表为当前 T大树洞 网页版的浏览器兼容目标:
|
||||
下表为当前 新T树洞 网页版的浏览器兼容目标:
|
||||
|
||||
| 平台 | Desktop | | | Windows | | macOS | iOS | | Android | |
|
||||
| -------- | ------- | -------------------------- | ------- | -------- | ---- | ------ | ------ | ------------------- | ------- | ----------------------- |
|
||||
@@ -22,24 +28,32 @@
|
||||
|
||||
`num+` 指符合版本号 `num` 的最新版本及后续所有版本。`最新版` 以 stable 分支为准。
|
||||
|
||||
## 接口
|
||||
|
||||
+ /\_login
|
||||
+ /\+api/v1/...
|
||||
|
||||
## 问题反馈
|
||||
|
||||
对 T大树洞 网页版的 bug 反馈请在相应仓库提交 Issue。
|
||||
对 新T树洞 网页版的 bug 反馈请在后端仓库提交 Issue。
|
||||
|
||||
欢迎提出功能和 UI 建议,但可能不会被采纳。根据 GPL,你有权自行实现你的想法。
|
||||
欢迎提出功能和 UI 建议,但可能不会被采纳。根据 AGPL,你有权自行实现你的想法。
|
||||
|
||||
不方便在 GitHub 上说明的问题可以邮件 thuhole at protonmail dot com。邮件内容可能会被公开。
|
||||
不方便在 GitHub 上说明的问题可以邮件联系。邮件内容不会被公开。
|
||||
|
||||
对 T大树洞 后端服务、客户端、账号、树洞内容的反馈请联系邮件 thuhole at protonmail dot com。
|
||||
|
||||
## branch说明:
|
||||
- master branch: 主分支
|
||||
- dev branch: 开发分支
|
||||
- gh-pages branch: dev分支的部署分支,用于测试
|
||||
- gh-pages-master branch: master分支的部署分支,用于jsdelivr CDN
|
||||
对 新T树洞 后端服务、客户端、账号、树洞内容的反馈请联系邮件。
|
||||
|
||||
## License
|
||||
|
||||
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 free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero 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](https://www.gnu.org/licenses/gpl-3.0.zh-cn.html) for more details.
|
||||
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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
14193
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "webhole",
|
||||
"version": "0.3.1",
|
||||
"version": "1.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"copy-to-clipboard": "^3.3.1",
|
||||
@@ -14,9 +14,10 @@
|
||||
"pressure": "^2.1.2",
|
||||
"react": "^16.13.1",
|
||||
"react-dom": "^16.13.0",
|
||||
"react-google-recaptcha-v3": "^1.5.2",
|
||||
"react-scripts": "^3.4.1",
|
||||
"react-timeago": "^4.4.0"
|
||||
"react-timeago": "^4.4.0",
|
||||
"typescript": "^4.0.2",
|
||||
"workbox-sw": "^5.1.3"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
dev.thuhole.com
|
||||
82
public/about.html
Normal file
@@ -0,0 +1,82 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh_cn">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta property="og:title" content="新T树洞 - 关于" />
|
||||
<meta property="og:description" content="我想要的不仅是一个树洞,而是一片森林" />
|
||||
<meta property="og:site_name" content="新T树洞" />
|
||||
<meta property="og:image" content="https://s1.ax1x.com/2020/09/07/wnrovV.png" />
|
||||
<title>新T树洞 - 关于</title>
|
||||
<style>
|
||||
body {
|
||||
background: #fafafa;
|
||||
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
color: #333;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.content {
|
||||
margin-left: 20px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
div.line {
|
||||
background-color: purple;
|
||||
height: 2px;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<span><a href="/">⬅️ 返回新T树洞</a></span>
|
||||
<h2 id="-t-">新T树洞与树洞族计划</h2>
|
||||
<p style="text-align:right"><i>——我想要的不仅是一个树洞,而是一片森林</i></p>
|
||||
<div class="line"></div>
|
||||
<p>
|
||||
重新搭建了一个树洞,一方面是因为对现有的树洞在<b>功能和安全性</b>上有一些不满而且一直看不到改进,另一方面是觉得总的来说树洞的存在仍然是好的,担心某一天树洞没了,希望设计一套“不死”的存在。
|
||||
</p>
|
||||
<br/>
|
||||
<p>
|
||||
新T树洞首先在安全性和匿名性上有显著加强,而且不搞虚假宣传欺骗用户。
|
||||
</p>
|
||||
<p>
|
||||
第一,采用第三方认证而非邮箱验证进行注册,从根源上避免新T树洞接触到敏感信息(如果你像某人一样担心树洞和认证提供方勾结,则安全性退化为了直接使用邮箱)。目前实际使用的是闭社,因为闭社提供了授权接口,而且支持匿名注册应用(<a href="https://docs.joinmastodon.org/client/token/#creating-our-application" taget="_blank">参考文档</a>)。
|
||||
候选方案还包括:T大树洞、未名BBS、清华统一身份认证。前两者的主要问题是没有授权接口,未来可能考虑使用一些特殊的方法,例如发布一段指定的随机内容到指定位置,以证明自己拥有这个帐号。清华统一身份认证的问题是似乎并不开放,没法申请,更不太可能匿名申请。(现已启用T大树洞登陆)
|
||||
</p>
|
||||
<p>
|
||||
第二,也是更核心的,采用随机盐哈希+不定期重置机制。不同于T大树洞使用一个“只有管理员知道”的盐对大家的邮箱进行哈希,新T树洞将在每次启动时随机生成一个盐,只存在于内存中。这意味着,即使是管理员也不可能通过正常手段获取该盐(会通过后端接口公示前三位和后三位,见系统日志栏)。用户所有有痕迹的操作,包括发布树洞、评论、关注、举报等,都只会记录这个随机哈希,而不会绑定到用户上。同时,每次重启就会重置这个随机盐,之前的洞将彻底和发布者失去联系(也许有军用手段可以对内存恢复历史信息?至少我没听说过)。当然,代价是如果你回复很早以前自己发布的洞,树洞也不知道你是洞主了,且每次重置后关注列表也会清空。(换言之,除了账号本身,你的一切都清零了)。
|
||||
</p>
|
||||
<br/>
|
||||
<p>
|
||||
功能上,新T树洞将秉持<b>自由、平等、透明</b>的原则,尽量给用户自主性,减少管理员不必要的介入,也不会由管理员预设什么分类等。
|
||||
</p>
|
||||
<p>
|
||||
新T树洞允许用户自己决定是否折叠、自己写折叠警告。用户也可以自己打任意想打的tag,不需要找管理员求tag。为了加强私密性,搜索时仅允许根据tag搜索,而非全文搜索(在关注列表中搜索除外),点击tag即可搜索所有相同tag。在设置中,可以设定展开特定的折叠警告,还可以选择直接忽略(而非折叠)所有带折叠警告的洞——这就相当于提供了两个新T树洞,想看纯净版的看纯净版,想看完整版的看完整版。同时,用户还可以删除自己的发布的回复和没有回复的洞。
|
||||
</p>
|
||||
<p>
|
||||
新T树洞不会有举报过多自动删除、口球X天、敏感词这些东西,取而代之的是所有举报、管理员删除记录、封禁记录都会在系统日志栏向所有人公示。
|
||||
</p>
|
||||
<br/>
|
||||
<p>
|
||||
这些是新T树洞的设计,但更重要的是我的<b>分布式清华树洞族计划</b>。新T树洞发布后,我希望尽快再会出现新新T树洞,新新新T树洞……。这并不是说希望越来越多的树洞因为割裂市场反而影响同学们的使用体验,而是希望联合起来互通数据。技术细节上,我会借鉴闭社的实现,通过activitypub协议。最终效果,登陆新新T树洞也能看到新T树洞的洞,也可以回复(可能显示为 Alice<sup>@newnew.com</sup>)。
|
||||
前面提到的随机盐哈希方案可以避免这种数据交换泄露任何发言者的实际信息。
|
||||
</p>
|
||||
<p>
|
||||
一方面,使用者可以依照自己的偏好选择从任意一个树洞登陆,看到的内容都是一样的(除了管理尺度的不同导致被删的洞可能有所不同)。另一方面,当清华树洞族中有了足够多的树洞,它将变成不死的存在——即使新T树洞被橄榄了,整个树洞族仍然存在,大家仍然可以通过新新T树洞等其他树洞进入这个分布式互联的网络,新T树洞上之前发过的内容因为在其他树洞上有缓存也不会丢失。
|
||||
</p>
|
||||
<p>
|
||||
这一部分目前还未实现,毕竟也还没有其他树洞可连。如果你愿意自己维护一个新新T树洞,一起打造清华树洞族,请邮件联系我!有新的树洞加入后,我们可以开始协商协议与实现细节。
|
||||
</p>
|
||||
<br/>
|
||||
<p>
|
||||
树洞内搜索 <a href="/#新手导引">#新手导引</a> 查看具体的使用帮助。使用中遇到任何问题请带上tag #产品反馈 提出,或联系邮箱/到github反馈。
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -6,8 +6,6 @@
|
||||
<link rel="icon" href="%PUBLIC_URL%/static/favicon/512.png">
|
||||
<meta name="format-detection" content="telephone=no">
|
||||
|
||||
<link rel="stylesheet" href="%PUBLIC_URL%/static/fonts_7/icomoon.css" />
|
||||
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<link rel="shortcut icon" href="%PUBLIC_URL%/static/favicon/512.png">
|
||||
<link rel="manifest" href="./static/manifest.json">
|
||||
@@ -23,10 +21,30 @@
|
||||
<link rel="apple-touch-startup-image" href="%PUBLIC_URL%/splash/1668x2388.png" media="(device-width: 834px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)"/>
|
||||
<link rel="apple-touch-startup-image" href="%PUBLIC_URL%/static/splash/2388x1668.png" media="(device-width: 834px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)"/>
|
||||
|
||||
<title>T大树洞</title>
|
||||
<title>新T树洞</title>
|
||||
</head>
|
||||
<script>
|
||||
function force_reload() {
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker
|
||||
.getRegistrations()
|
||||
.then((registrations) => {
|
||||
for (let registration of registrations) {
|
||||
console.log('unregister', registration);
|
||||
registration.unregister();
|
||||
}
|
||||
});
|
||||
}
|
||||
cache().clear();
|
||||
setTimeout(() => {
|
||||
window.location.reload(true);
|
||||
}, 200);
|
||||
}
|
||||
</script>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script src="stats.js" defer></script>
|
||||
<div id="root">
|
||||
请开启javascript,或 <a href="#" onClick="force_reload">强制刷新</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>"T大树洞"管理规范(试行)</title>
|
||||
<title>"新T树洞"管理规范(试行)</title>
|
||||
<style>
|
||||
body {
|
||||
background: #fafafa;
|
||||
@@ -30,68 +30,38 @@
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<h2 id="-t-">"T大树洞"管理规范(试行)</h2>
|
||||
<h2 id="-t-">"新T树洞"管理规范(试行)</h2>
|
||||
<div class="line"></div>
|
||||
<p>一、
|
||||
为规范“T大树洞”管理,维护社区秩序,保障使用者的合法权益;根据《最高人民法院关于审理侵害信息网络传播权民事纠纷案件适用法律若干问题的规定》《侵权责任法》第36条“关于网络侵权的规定”《中华人民共和国计算机信息网络国际联网管理规定》《中华人民共和国网络安全法》及《互联网信息服务管理办法》《互联网电子公告服务管理规定》《互联网论坛社区服务管理规定》《互联网跟帖评论服务管理规定》的规定,并结合普通高等学校相关管理规定,制定本规范,简称《规范》或《树洞条例》。</p>
|
||||
<p>二、 本规范适用于“T大树洞”全体用户。</p>
|
||||
<p>三、 T大树洞团队成立发展运营组,承担树洞管理具体职责,依据本规范对树洞进行管理。</p>
|
||||
<p>四、 本规范所指"内容"包括 T大树洞用户在使用树洞的过程中上传、发布、传播的任何内容,包括但不限于文字、图片、网页链接等发送、回复的内容。用户发表任何内容时,即确认:<br>
|
||||
为规范“新T树洞”管理,维护社区秩序,保障使用者的合法权益;根据《最高人民法院关于审理侵害信息网络传播权民事纠纷案件适用法律若干问题的规定》《侵权责任法》第36条“关于网络侵权的规定”《中华人民共和国计算机信息网络国际联网管理规定》《中华人民共和国网络安全法》及《互联网信息服务管理办法》《互联网电子公告服务管理规定》《互联网论坛社区服务管理规定》《互联网跟帖评论服务管理规定》的规定,并结合普通高等学校相关管理规定,制定本规范,简称《规范》或《树洞条例》。</p>
|
||||
<p>二、 本规范适用于“新T树洞”全体用户。</p>
|
||||
<p>三、 新T树洞团队依据本规范对树洞进行管理。</p>
|
||||
<p>四、 本规范所指"内容"包括 新T树洞用户在使用树洞的过程中上传、发布、传播的任何内容,包括但不限于文字、图片、网页链接等发送、回复的内容。用户发表任何内容时,即确认:<br>
|
||||
1. 该内容为用户所原创或享有相关版权,并为所发表的内容承担相关法律责任。<br>
|
||||
2. 用户向T大树洞团队永久许可其在T大树洞的发展、运营和维护期间储存及合理使用用户发布的内容。<br>
|
||||
3. 用户已阅读并承诺遵守本规范及未来修订的所有版本中的所有内容。<br>
|
||||
2. 用户向新T树洞团队永久许可其在新T树洞的发展、运营和维护期间储存用户发布的内容。<br>
|
||||
3. 用户已阅读并承诺遵守本规范中的所有内容。<br>
|
||||
</p>
|
||||
<p>五、 T大树洞账号仅供本人使用。使用T大树洞提供的任何网络服务即同意:<br>
|
||||
1. 用户不得以任何形式出借、出租、转让T大树洞账号;违者封禁账号T大树洞使用权限1个月。在此过程中发布违规信息造成不良影响经查实的,根据性质情节予以封禁账号T大树洞使用权限2个月以上至永久封禁。<br>
|
||||
2. 任何人未经T大树洞团队许可,不得擅自将T大树洞内容向校外人员或T大树洞用户以外的用户传播。违者造成恶劣影响的,T大树洞团队有权调查、封禁传播人账户,并追究法律责任。<br>
|
||||
<p>五、 新T树洞账号仅供本人使用。使用新T树洞提供的任何网络服务即同意:<br>
|
||||
1. 用户不得以任何形式出借、出租、转让新T树洞账号。<br>
|
||||
2. 任何人未经新T树洞团队许可,不得擅自将新T树洞内容向校外人员或新T树洞用户以外的用户传播。<br>
|
||||
3.
|
||||
不得使用T大树洞网页版和THUInfo(https://github.com/THUInfo/THUInfo)以外的客户端、脚本等访问方式,未经T大树洞团队明确许可,访问T大树洞的相关服务、下载T大树洞服务提供的相关内容;违者造成恶劣影响的,T大树洞团队有权调查、封禁传播人账户,并追究法律责任。<br>
|
||||
在不影响新T树洞正常运行、不导致内容泄漏的前提下,用户可以使用自己喜欢的任意方式访问新T树洞,
|
||||
包括但不限于网页版、脚本、自制客户端、桥接等。<br>
|
||||
</p>
|
||||
<p>
|
||||
六、 用户不得利用T大树洞上传、发布、传播如下法律、法规或政策规定禁止的内容(否则,自行承担所造成的法律后果):<br>
|
||||
1. 违反宪法所确定的基本原则,违反相关法律法规与政策规定,违反《普通高等学校学生管理规定》的;<br>
|
||||
2. 危害国家安全、荣誉和利益,泄露国家秘密,颠覆国家政权,破坏国家统一的;<br>
|
||||
3. 煽动民族矛盾、破坏民族团结,鼓动地域歧视的;<br>
|
||||
4. 公开传教、破坏国家宗教政策,宣扬邪教和封建迷信的;<br>
|
||||
5. 散布谣言,误导他人,扰乱社会和校园秩序的;<br>
|
||||
6. 含有任何淫秽色情、性暗示、赌博、传销、暴力、凶杀、恐怖或者教唆犯罪的;<br>
|
||||
7. 煽动非法游行集会,召集非法组织的;<br>
|
||||
8. 出租、出售学校提供的具有校园公益性质资源的,如免费演出入场券、校园卡、学生证、寝室床位等;<br>
|
||||
9. 与法律法规底线、社会主义制度底线、国家利益底线、公民合法权益底线、社会公共秩序底线、道德风尚底线和信息真实性底线相抵触的;<br>
|
||||
10. 其他不宜公开讨论的政治内容和含有法律、行政法规禁止的其他内容的信息。<br>
|
||||
六、 用户不得利用新T树洞上传、发布、传播违反法律、法规或政策规定禁止的内容。
|
||||
</p>
|
||||
<p>七、 用户不得利用T大树洞上传、发布、传播如下干扰T大树洞正常运营,或者侵害其他用户或第三方合法权益,或者经举报、申诉并核实准确的内容:<br>
|
||||
1. 引起其他用户不适并受到多次举报的;<br>
|
||||
2. 侵害他人肖像权、知识产权、商业秘密等合法权益的;<br>
|
||||
3. 侵害他人隐私,未经允许披露他人信息的;<br>
|
||||
4. 含有侮辱诽谤、人身攻击、虚假信息等内容,对他人或机构造成不良影响的;<br>
|
||||
5. 含有骚扰、垃圾广告、恶意信息、诱骗信息的;<br>
|
||||
6. 含有引起歧义的缩写、谐音或其他表达,诱导违规话题的;<br>
|
||||
7. 其他干扰T大树洞正常运营,以及侵害其他用户或第三方合法权益的内容。<br>
|
||||
<p>七、 用户不得利用新T树洞上传、发布、传播如下干扰新T树洞正常运营与用户正常使用,或者侵害其他用户/第三方合法权益的内容。
|
||||
</p>
|
||||
<p>八、 用户在使用过程中如发现违反本规范中所述各项管理规范的行为,可通过T大树洞内的举报按钮或通过邮箱 (thuhole@protonmail.com) 联系发展运营组进行举报。</p>
|
||||
<p>八、 用户在使用过程中如发现违反本规范中所述各项管理规范的行为,可通过新T树洞内的举报按钮或通过邮箱联系团队进行举报。</p>
|
||||
<p>九、 用户发布的主题帖或回复帖,经判定为违规所述管理规范的,予以删除。</p>
|
||||
<p>十、 被删帖用户将遭到“历史删帖总数(天)”的禁言处罚。 被删贴用户的 T大树洞 树洞相关操作权限有权被团队进行限制。其他 T大树洞 功能不受此限影响。T大树洞团队有权对具体情况进行裁定与调整。<br>
|
||||
1. 屡次违反树洞规范、超出一定累计封禁次数的用户,树洞管理运营组有权永久封禁该用户;<br>
|
||||
2. 严重违反树洞规范,大量发布违规信息的用户将被封禁1个月以上直至永久封禁。<br>
|
||||
</p>
|
||||
<p>十一、 用户账户受到处理后,将自动收到系统发来的违规情况说明。用户被封禁后在封禁期满前有权向T大树洞团队通过邮箱方式 (thuhole@protonmail.com) 书面提出申诉。</p>
|
||||
<p>十二、 包括用户在注册和使用中产生的身份信息,发展运营组未经用户允许,不主动查询、使用、透露、公开用户个人信息,如用户的访问IP等,但以下特定情形除外:<br>
|
||||
1. 用户转让、出租、出售个人账户或者个人账户导致的个人信息泄露;<br>
|
||||
2. 为维护社会公共利益、校园安全稳定以及个人人身安全;<br>
|
||||
3. 根据相关法律法规或政策的要求。<br>
|
||||
</p>
|
||||
<p>十三、 T大树洞发展运营组未经用户允许,不主动查询、使用、透露、公开用户邮箱哈希值,但以下特定情形除外:<br>
|
||||
1. 本规范第十二条所规定的各类情形<br>
|
||||
2. 依照本规范,需要被封禁的用户<br>
|
||||
</p>
|
||||
<p>十四、 T大树洞发展运营组未经用户允许,不主动尝试解密用户邮箱哈希值获取用户邮箱明文,但以下特定情形除外:<br>
|
||||
1. 本规范第十二条所规定的各类情形<br>
|
||||
</p>
|
||||
<p>十五、 本规范不构成对相关法律法规及相关高校管理制度的任何有效修改,如有冲突,应以相关法律法规与制度文件为准。</p>
|
||||
<p>十六、 T大树洞 团队有权对行为异常的用户账号加以技术性限制。</p>
|
||||
<p>十七、 本规范由T大树洞开发团队发展运营组负责解释。</p>
|
||||
<p>十八、 本规定自2020年7月12日起施行。</p>
|
||||
<p>十、 严重违反树洞规范,破坏树洞运营的用户将予以封禁,封禁到下一次重置自动失效。</p>
|
||||
<p>十一、新T树洞管理方承诺使用与开源代码一致的后台代码,且不会向第三方出售或提供用户信息。</p>
|
||||
<p>十二、在重置前,用户可自行删除回复帖及没有回复的主题帖。该删除是彻底、不可逆的。</p>
|
||||
<p>十三、 本规范不构成对相关法律法规及相关高校管理制度的任何有效修改,如有冲突,应以相关法律法规与制度文件为准。</p>
|
||||
<p>十四、 新T树洞团队有权对行为异常的用户账号加以技术性限制。</p>
|
||||
<p>十五、 本规范由新T树洞开发团队负责解释。</p>
|
||||
<p>十六、 本规定自2020年9月7日起施行。</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 79 KiB |
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"short_name": "树洞",
|
||||
"name": "T大树洞",
|
||||
"name": "新T树洞",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon/512.png",
|
||||
"src": "https://s1.ax1x.com/2020/09/07/wnnsOO.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "favicon/192.png",
|
||||
"src": "https://s1.ax1x.com/2020/09/07/wnrovV.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
var _czc = _czc || [];
|
||||
_czc.push(["_setAccount", "1279007496"]);
|
||||
_czc.push(["_setCustomVar", "has_token", localStorage['TOKEN'] ? 'yes' : 'no', 1]);
|
||||
_czc.push(["_setCustomVar", "standalone", ((window.matchMedia('(display-mode: standalone)').matches) || (window.navigator.standalone)) ? 'yes' : 'no', 1]);
|
||||
_czc.push(["_setCustomVar", "build_info", "%REACT_APP_BUILD_INFO%" || '---']);
|
||||
var cr_version = /Chrome\/(\d+)/.exec(navigator.userAgent);
|
||||
_czc.push(["_setCustomVar", "cr_version_test", cr_version ? cr_version[1] : '[null]', 2]);
|
||||
/*
|
||||
// track config
|
||||
try {
|
||||
var config=JSON.parse(localStorage['hole_config']||'{}');
|
||||
for(var key in config)
|
||||
if(config.hasOwnProperty(key))
|
||||
_czc.push(["_trackEvent",'config',key,encodeURIComponent(JSON.stringify(config[key])),0,'']);
|
||||
//_czc.push(["_setCustomVar","config_"+key,encodeURIComponent(JSON.stringify(config[key])),0]);
|
||||
} catch(e) {
|
||||
console.trace(e);
|
||||
}
|
||||
*/
|
||||
var cnzz_s_tag = document.createElement('script');
|
||||
cnzz_s_tag.type = 'text/javascript';
|
||||
cnzz_s_tag.async = true;
|
||||
cnzz_s_tag.charset = "utf-8";
|
||||
cnzz_s_tag.src = "https://w.cnzz.com/c.php?id=1279007496&async=1";
|
||||
document.head.appendChild(cnzz_s_tag);
|
||||
48
src/App.js
@@ -5,6 +5,7 @@ import { Sidebar } from './Sidebar';
|
||||
import { PressureHelper } from './PressureHelper';
|
||||
import { TokenCtx } from './UserAction';
|
||||
import { load_config, bgimg_style } from './Config';
|
||||
import { load_attentions } from './Attention.js';
|
||||
import { listen_darkmode } from './infrastructure/functions';
|
||||
import { LoginPopup, TitleLine } from './infrastructure/widgets';
|
||||
|
||||
@@ -18,6 +19,7 @@ class App extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
load_config();
|
||||
load_attentions();
|
||||
listen_darkmode(
|
||||
{ default: undefined, light: false, dark: true }[
|
||||
window.config.color_scheme
|
||||
@@ -33,12 +35,6 @@ class App extends Component {
|
||||
this.show_sidebar_bound = this.show_sidebar.bind(this);
|
||||
this.set_mode_bound = this.set_mode.bind(this);
|
||||
this.on_pressure_bound = this.on_pressure.bind(this);
|
||||
// a silly self-deceptive approach to ban guests, enough to fool those muggles
|
||||
// document cookie 'pku_ip_flag=yes'
|
||||
this.inthu_flag =
|
||||
window[atob('ZG9jdW1lbnQ')][atob('Y29va2ll')].indexOf(
|
||||
atob('dGh1X2lwX2ZsYWc9eWVz'),
|
||||
) !== -1;
|
||||
}
|
||||
|
||||
static is_darkmode() {
|
||||
@@ -102,6 +98,26 @@ class App extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (window.location.protocol === 'http:' &&
|
||||
window.location.hostname !== '127.0.0.1' && !window.location.hostname.endsWith('localhost')) {
|
||||
window.location.protocol = 'https:'; // 因为CDN的原因先在前端做下https跳转
|
||||
return;
|
||||
}
|
||||
let arg = window.location.search;
|
||||
console.log(arg);
|
||||
if (arg.startsWith('?token=')) {
|
||||
let token = arg.substr(7);
|
||||
if (token.endsWith(encodeURI('_任意自定义后缀'))) {
|
||||
let tmp_token_suf = localStorage['TOKEN_SUF'] || prompt('设置一个你专属的临时token后缀吧') || Math.random();
|
||||
localStorage['TOKEN_SUF'] = tmp_token_suf;
|
||||
token = `${token.split('_')[0]}_${tmp_token_suf}`;
|
||||
}
|
||||
localStorage['TOKEN'] = token;
|
||||
window.location.search = '';
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<TokenCtx.Provider
|
||||
@@ -129,20 +145,18 @@ class App extends Component {
|
||||
{!token.value && (
|
||||
<div className="flow-item-row aux-margin">
|
||||
<div className="box box-tip">
|
||||
<p>
|
||||
<LoginPopup token_callback={token.set_value}>
|
||||
{(do_popup) => (
|
||||
<a onClick={do_popup}>
|
||||
<span className="icon icon-login" />
|
||||
登录到 T大树洞
|
||||
</a>
|
||||
)}
|
||||
</LoginPopup>
|
||||
</p>
|
||||
<LoginPopup token_callback={token.set_value}>
|
||||
{(do_popup) => (
|
||||
<a onClick={do_popup}>
|
||||
<span className="icon icon-login" />
|
||||
登录到 新T树洞
|
||||
</a>
|
||||
)}
|
||||
</LoginPopup>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{this.inthu_flag || token.value ? (
|
||||
{token.value ? (
|
||||
<Flow
|
||||
key={this.state.flow_render_key}
|
||||
show_sidebar={this.show_sidebar_bound}
|
||||
|
||||
7
src/Attention.js
Normal file
@@ -0,0 +1,7 @@
|
||||
export function load_attentions() {
|
||||
window.saved_attentions = JSON.parse(localStorage['saved_attentions'] || '[]');
|
||||
}
|
||||
|
||||
export function save_attentions() {
|
||||
localStorage['saved_attentions'] = JSON.stringify(window.saved_attentions);
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
import load from 'load-script';
|
||||
|
||||
window.audio_cache = {};
|
||||
|
||||
function load_amrnb() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (window.AMR) resolve();
|
||||
else
|
||||
load('static/amr_all.min.js', (err) => {
|
||||
if (err) reject(err);
|
||||
else resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export class AudioWidget extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
url: this.props.src,
|
||||
state: 'waiting',
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
|
||||
load() {
|
||||
if (window.audio_cache[this.state.url]) {
|
||||
this.setState({
|
||||
state: 'loaded',
|
||||
data: window.audio_cache[this.state.url],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('fetching audio', this.state.url);
|
||||
this.setState({
|
||||
state: 'loading',
|
||||
});
|
||||
Promise.all([fetch(this.state.url), load_amrnb()]).then((res) => {
|
||||
res[0].blob().then((blob) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (event) => {
|
||||
const raw = new window.AMR().decode(event.target.result);
|
||||
if (!raw) {
|
||||
alert('audio decoding failed');
|
||||
return;
|
||||
}
|
||||
const wave = window.PCMData.encode({
|
||||
sampleRate: 8000,
|
||||
channelCount: 1,
|
||||
bytesPerSample: 2,
|
||||
data: raw,
|
||||
});
|
||||
const binary_wave = new Uint8Array(wave.length);
|
||||
for (let i = 0; i < wave.length; i++)
|
||||
binary_wave[i] = wave.charCodeAt(i);
|
||||
|
||||
const objurl = URL.createObjectURL(
|
||||
new Blob([binary_wave], { type: 'audio/wav' }),
|
||||
);
|
||||
window.audio_cache[this.state.url] = objurl;
|
||||
this.setState({
|
||||
state: 'loaded',
|
||||
data: objurl,
|
||||
});
|
||||
};
|
||||
reader.readAsBinaryString(blob);
|
||||
});
|
||||
this.setState({
|
||||
state: 'decoding',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.state === 'waiting')
|
||||
return (
|
||||
<p>
|
||||
<a onClick={this.load.bind(this)}>加载音频</a>
|
||||
</p>
|
||||
);
|
||||
if (this.state.state === 'loading') return <p>正在下载……</p>;
|
||||
else if (this.state.state === 'decoding') return <p>正在解码……</p>;
|
||||
else if (this.state.state === 'loaded')
|
||||
return (
|
||||
<p>
|
||||
<audio src={this.state.data} controls />
|
||||
</p>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -58,3 +58,20 @@
|
||||
padding: 0 .1rem;
|
||||
margin-left: .15rem;
|
||||
}
|
||||
|
||||
.ext-img {
|
||||
max-width: 100%;
|
||||
max-height: 2000px;
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.left-container .img-link img {
|
||||
max-height: 500px;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin-left: 8px;
|
||||
padding-left: 5px;
|
||||
border-left: 3px solid #cbcbcb;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React, { Component, PureComponent } from 'react';
|
||||
import { format_time, Time, TitleLine } from './infrastructure/widgets';
|
||||
import { THUHOLE_API_ROOT } from './flows_api';
|
||||
|
||||
import HtmlToReact from 'html-to-react';
|
||||
|
||||
@@ -10,6 +9,7 @@ import {
|
||||
URL_RE,
|
||||
PID_RE,
|
||||
NICKNAME_RE,
|
||||
TAG_RE,
|
||||
split_text,
|
||||
} from './text_splitter';
|
||||
|
||||
@@ -17,7 +17,7 @@ import renderMd from './Markdown';
|
||||
|
||||
export { format_time, Time, TitleLine };
|
||||
|
||||
export const API_BASE = THUHOLE_API_ROOT + 'services/thuhole';
|
||||
export const API_BASE = '/_api/v1';
|
||||
|
||||
// https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
|
||||
function escape_regex(string) {
|
||||
@@ -68,6 +68,7 @@ function normalize_url(url) {
|
||||
return /^https?:\/\//.test(url) ? url : 'http://' + url;
|
||||
}
|
||||
|
||||
/*
|
||||
export class HighlightedText extends PureComponent {
|
||||
render() {
|
||||
return (
|
||||
@@ -110,6 +111,7 @@ export class HighlightedText extends PureComponent {
|
||||
);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// props: text, show_pid, color_picker
|
||||
export class HighlightedMarkdown extends Component {
|
||||
@@ -117,12 +119,6 @@ export class HighlightedMarkdown extends Component {
|
||||
const props = this.props;
|
||||
const processDefs = new HtmlToReact.ProcessNodeDefinitions(React);
|
||||
const processInstructions = [
|
||||
{
|
||||
shouldProcessNode: (node) => node.name === 'img', // disable images
|
||||
processNode(node, children, index) {
|
||||
return <div key={index}>[图片]</div>;
|
||||
},
|
||||
},
|
||||
{
|
||||
shouldProcessNode: (node) => /^h[123456]$/.test(node.name),
|
||||
processNode(node, children, index) {
|
||||
@@ -132,6 +128,19 @@ export class HighlightedMarkdown extends Component {
|
||||
return <HeadingTag key={index}>{children}</HeadingTag>;
|
||||
},
|
||||
},
|
||||
{
|
||||
shouldProcessNode: (node) => node.name === 'img',
|
||||
processNode(node, index) {
|
||||
return (
|
||||
<img
|
||||
src={normalize_url(node.attribs.src)}
|
||||
alt={node.alt}
|
||||
className="ext-img"
|
||||
referrerPolicy="no-referrer"
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
shouldProcessNode: (node) => node.name === 'a',
|
||||
processNode(node, children, index) {
|
||||
@@ -165,6 +174,7 @@ export class HighlightedMarkdown extends Component {
|
||||
['url', URL_RE],
|
||||
['pid', PID_RE],
|
||||
['nickname', NICKNAME_RE],
|
||||
['tag', TAG_RE],
|
||||
]);
|
||||
|
||||
return (
|
||||
@@ -202,6 +212,12 @@ export class HighlightedMarkdown extends Component {
|
||||
</ColoredSpan>
|
||||
) : rule === 'search' ? (
|
||||
<span className="search-query-highlight">{p}</span>
|
||||
) : rule === 'tag' ? (
|
||||
<a
|
||||
href={p}
|
||||
>
|
||||
{p}
|
||||
</a>
|
||||
) : (
|
||||
p
|
||||
)}
|
||||
@@ -218,30 +234,15 @@ export class HighlightedMarkdown extends Component {
|
||||
},
|
||||
];
|
||||
const parser = new HtmlToReact.Parser();
|
||||
if (props.author && props.text.match(/^(?:#+ |>|```|\t|\s*-|\s*\d+\.)/)) {
|
||||
const renderedMarkdown = renderMd(props.text);
|
||||
return (
|
||||
<>
|
||||
{props.author}
|
||||
{parser.parseWithInstructions(
|
||||
renderedMarkdown,
|
||||
(node) => node.type !== 'script',
|
||||
processInstructions,
|
||||
) || ''}
|
||||
</>
|
||||
);
|
||||
} else {
|
||||
let rawMd = props.text;
|
||||
if (props.author) rawMd = props.author + ' ' + rawMd;
|
||||
const renderedMarkdown = renderMd(rawMd);
|
||||
return (
|
||||
parser.parseWithInstructions(
|
||||
renderedMarkdown,
|
||||
(node) => node.type !== 'script',
|
||||
processInstructions,
|
||||
) || null
|
||||
);
|
||||
}
|
||||
let rawMd = props.text;
|
||||
const renderedMarkdown = renderMd(rawMd);
|
||||
return (
|
||||
parser.parseWithInstructions(
|
||||
renderedMarkdown,
|
||||
(node) => node.type !== 'script',
|
||||
processInstructions,
|
||||
) || null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,6 +316,7 @@ export class SafeTextarea extends Component {
|
||||
onChange={this.on_change_bound}
|
||||
value={this.state.text}
|
||||
onKeyDown={this.on_keydown_bound}
|
||||
maxLength="4096"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,11 @@ import './Config.css';
|
||||
|
||||
const BUILTIN_IMGS = {
|
||||
'https://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages/static/bg/gbp.jpg':
|
||||
'寻觅繁星(默认)',
|
||||
'怀旧背景(默认)',
|
||||
'https://www.tsinghua.edu.cn/image/nav-bg.jpg':
|
||||
'清华紫',
|
||||
'https://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages/static/bg/gbp.jpg':
|
||||
'寻觅繁星',
|
||||
'https://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages/static/bg/eriri.jpg':
|
||||
'平成著名画师',
|
||||
'https://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages/static/bg/yurucamp.jpg':
|
||||
@@ -21,13 +25,15 @@ const BUILTIN_IMGS = {
|
||||
|
||||
const DEFAULT_CONFIG = {
|
||||
background_img:
|
||||
'https://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages/static/bg/gbp.jpg',
|
||||
'//cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages/static/bg/gbp.jpg',
|
||||
background_color: '#113366',
|
||||
pressure: false,
|
||||
easter_egg: true,
|
||||
color_scheme: 'default',
|
||||
fold: true,
|
||||
block_words: [],
|
||||
no_c_post: false,
|
||||
by_c: false,
|
||||
block_words_v2: ['#天火', '#桃花石'],
|
||||
whitelist_cw: []
|
||||
};
|
||||
|
||||
export function load_config() {
|
||||
@@ -46,6 +52,10 @@ export function load_config() {
|
||||
if (config[key] !== undefined) config[key] = loaded_config[key];
|
||||
});
|
||||
|
||||
if (loaded_config['block_words']) {
|
||||
config['block_words_v2'] = loaded_config['block_words'].concat(config['block_words_v2'])
|
||||
}
|
||||
|
||||
console.log('config loaded', config);
|
||||
window.config = config;
|
||||
}
|
||||
@@ -251,50 +261,6 @@ class ConfigTextArea extends PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
/* class ConfigBlockWords extends PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
block_words: window.config.block_words,
|
||||
};
|
||||
}
|
||||
|
||||
save_changes() {
|
||||
this.props.callback({
|
||||
block_words: this.state.block_words.filter((v) => v),
|
||||
});
|
||||
}
|
||||
|
||||
on_change(e) {
|
||||
// Filter out those blank lines
|
||||
let value = e.target.value.split('\n');
|
||||
this.setState(
|
||||
{
|
||||
block_words: value,
|
||||
},
|
||||
this.save_changes.bind(this),
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<p>
|
||||
{' '}
|
||||
<b>设置屏蔽词 </b>
|
||||
</p>
|
||||
<p>
|
||||
<textarea
|
||||
className="block-words"
|
||||
value={this.state.block_words.join('\n')}
|
||||
onChange={this.on_change.bind(this)}
|
||||
/>
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
} */
|
||||
|
||||
class ConfigSwitch extends PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@@ -370,7 +336,7 @@ export class ConfigUI extends PureComponent {
|
||||
</p>
|
||||
<p>
|
||||
<b>
|
||||
修改设置后{' '}
|
||||
部分设置修改后需要{' '}
|
||||
<a
|
||||
onClick={() => {
|
||||
window.location.reload();
|
||||
@@ -398,7 +364,7 @@ export class ConfigUI extends PureComponent {
|
||||
callback={this.save_changes_bound}
|
||||
/> */}
|
||||
<ConfigTextArea
|
||||
id="block_words"
|
||||
id="block_words_v2"
|
||||
callback={this.save_changes_bound}
|
||||
name="设置屏蔽词"
|
||||
description={'包含屏蔽词的树洞会被折叠,每行写一个屏蔽词'}
|
||||
@@ -407,6 +373,16 @@ export class ConfigUI extends PureComponent {
|
||||
parse={(string) => string.split('\n')}
|
||||
/>
|
||||
<hr />
|
||||
<ConfigTextArea
|
||||
id="whitelist_cw"
|
||||
callback={this.save_changes_bound}
|
||||
name="展开指定的折叠警告"
|
||||
description={'完全匹配的树洞不会被折叠,每行一个豁免词,也可使用一个星号("*")表示豁免所有'}
|
||||
display={(array) => array.join('\n')}
|
||||
sift={(array) => array.filter((v) => v)}
|
||||
parse={(string) => string.split('\n')}
|
||||
/>
|
||||
<hr />
|
||||
<ConfigSwitch
|
||||
callback={this.save_changes_bound}
|
||||
id="pressure"
|
||||
@@ -423,18 +399,25 @@ export class ConfigUI extends PureComponent {
|
||||
<hr />
|
||||
<ConfigSwitch
|
||||
callback={this.save_changes_bound}
|
||||
id="fold"
|
||||
name="折叠树洞"
|
||||
description="在时间线中折叠可能引起不适的树洞"
|
||||
id="no_c_post"
|
||||
name="忽略折叠的树洞"
|
||||
description="不获取所有带折叠警告的树洞,折叠警告豁免将不起作用"
|
||||
/>
|
||||
<hr />
|
||||
<ConfigSwitch
|
||||
callback={this.save_changes_bound}
|
||||
id="by_c"
|
||||
name="根据最新回复排序"
|
||||
description="有最新回复的洞在最上面"
|
||||
/>
|
||||
<hr />
|
||||
<p>
|
||||
新功能建议或问题反馈请在
|
||||
<a
|
||||
href="https://github.com/thuhole/thuhole-go-backend/issues"
|
||||
href="https://git.thu.monster/newthuhole/hole_thu_backend/issues"
|
||||
target="_blank"
|
||||
>
|
||||
GitHub <span className="icon icon-github" />
|
||||
Gitea
|
||||
</a>
|
||||
提出。
|
||||
</p>
|
||||
|
||||
@@ -254,7 +254,7 @@
|
||||
color: white;
|
||||
}
|
||||
|
||||
.box-header-tag {
|
||||
.box-header-cw {
|
||||
color: white;
|
||||
background-color: #00c;
|
||||
font-weight: bold;
|
||||
@@ -263,7 +263,36 @@
|
||||
padding: 0 .25em;
|
||||
}
|
||||
|
||||
.root-dark-mode .box-header-tag {
|
||||
.box-header-cw-edit {
|
||||
display: inline-block;
|
||||
background-color: #00c;
|
||||
border-radius: 5px;
|
||||
padding: 3px;
|
||||
margin:0 3px;
|
||||
}
|
||||
|
||||
.box-header-cw-edit input {
|
||||
font-size: .8em;
|
||||
width: 8em;
|
||||
padding: 0 3px;
|
||||
}
|
||||
|
||||
.box-header-cw-edit button {
|
||||
font-size: .8em;
|
||||
margin: 0 3px;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.box-header-name {
|
||||
color: white;
|
||||
background-color: #3338;
|
||||
font-weight: bold;
|
||||
border-radius: 5px;
|
||||
margin-right: .5em;
|
||||
padding: .1em .5em;
|
||||
}
|
||||
|
||||
.root-dark-mode .box-header-cw {
|
||||
background-color: #00a;
|
||||
}
|
||||
|
||||
@@ -283,3 +312,30 @@
|
||||
padding: 0 .5em;
|
||||
opacity: .4;
|
||||
}
|
||||
|
||||
.export-textarea {
|
||||
resize: none;
|
||||
width: 100%;
|
||||
height: 50vh;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.export-btn {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.flow-submode-choice {
|
||||
display: inline-block;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.flow-submode-choice a {
|
||||
margin: 10px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.flow-submode-choice a.choiced {
|
||||
margin: 10px;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
510
src/Flows.js
@@ -7,45 +7,33 @@ import {
|
||||
PID_RE,
|
||||
URL_RE,
|
||||
URL_PID_RE,
|
||||
TAG_RE,
|
||||
} from './text_splitter';
|
||||
import {
|
||||
format_time,
|
||||
build_highlight_re,
|
||||
Time,
|
||||
TitleLine,
|
||||
HighlightedText,
|
||||
ClickHandler,
|
||||
ColoredSpan,
|
||||
HighlightedMarkdown,
|
||||
} from './Common';
|
||||
import './Flows.css';
|
||||
import LazyLoad, { forceCheck } from './react-lazyload/src';
|
||||
import { AudioWidget } from './AudioWidget';
|
||||
import { TokenCtx, ReplyForm } from './UserAction';
|
||||
|
||||
import { API } from './flows_api';
|
||||
import { cache } from './cache';
|
||||
import { save_attentions } from './Attention'
|
||||
|
||||
/*
|
||||
const IMAGE_BASE = 'https://thimg.yecdn.com/';
|
||||
const IMAGE_BAK_BASE = 'https://img2.thuhole.com/';
|
||||
// const AUDIO_BASE=THUHOLE_API_ROOT+'services/thuhole/audios/';
|
||||
*/
|
||||
|
||||
const CLICKABLE_TAGS = { a: true, audio: true };
|
||||
const PREVIEW_REPLY_COUNT = 10;
|
||||
// const QUOTE_BLACKLIST=['23333','233333','66666','666666','10086','10000','100000','99999','999999','55555','555555'];
|
||||
const QUOTE_BLACKLIST = [];
|
||||
const FOLD_TAGS = [
|
||||
'性相关',
|
||||
'政治相关',
|
||||
'性话题',
|
||||
'政治话题',
|
||||
'折叠',
|
||||
'NSFW',
|
||||
'刷屏',
|
||||
'真实性可疑',
|
||||
'用户举报较多',
|
||||
'举报较多',
|
||||
'重复内容',
|
||||
];
|
||||
|
||||
window.LATEST_POST_ID = parseInt(localStorage['_LATEST_POST_ID'], 10) || 0;
|
||||
|
||||
@@ -107,47 +95,57 @@ class Reply extends PureComponent {
|
||||
}
|
||||
|
||||
render() {
|
||||
const replyContent = this.props.info.text;
|
||||
const splitIdx = replyContent.indexOf(']');
|
||||
|
||||
const author = replyContent.substr(0, splitIdx + 1),
|
||||
replyText = replyContent.substr(splitIdx + 2);
|
||||
const {info, color_picker, show_pid, do_filter_name, do_delete} = this.props;
|
||||
const author = info.name,
|
||||
replyText = info.text;
|
||||
return (
|
||||
<div
|
||||
className={'flow-reply box'}
|
||||
style={
|
||||
this.props.info._display_color
|
||||
info._display_color
|
||||
? {
|
||||
'--box-bgcolor-light': this.props.info._display_color[0],
|
||||
'--box-bgcolor-dark': this.props.info._display_color[1],
|
||||
'--box-bgcolor-light': info._display_color[0],
|
||||
'--box-bgcolor-dark': info._display_color[1],
|
||||
}
|
||||
: null
|
||||
}
|
||||
>
|
||||
<div className="box-header">
|
||||
<code className="box-id">#{this.props.info.cid}</code>
|
||||
{!!this.props.do_filter_name && (
|
||||
{!!do_filter_name && (
|
||||
<span
|
||||
className="reply-header-badge clickable"
|
||||
onClick={() => {
|
||||
this.props.do_filter_name(this.props.info.name);
|
||||
do_filter_name(info.name);
|
||||
}}
|
||||
>
|
||||
<span className="icon icon-locate" />
|
||||
</span>
|
||||
)}
|
||||
|
||||
{this.props.info.tag !== null && (
|
||||
<span className="box-header-tag">{this.props.info.tag}</span>
|
||||
{(
|
||||
<span className="box-header-name">{info.name}</span>
|
||||
)}
|
||||
<Time stamp={this.props.info.timestamp} short={false} />
|
||||
{!!do_delete && !!info.can_del && (
|
||||
<span
|
||||
className="clickable"
|
||||
onClick={() => {
|
||||
do_delete('cid', info.cid);
|
||||
}}
|
||||
>
|
||||
<span className="icon icon-trash" />
|
||||
</span>
|
||||
)}
|
||||
|
||||
<Time stamp={info.timestamp} short={false} />
|
||||
|
||||
<code className="box-id">{'$' + info.cid}</code>
|
||||
</div>
|
||||
<div className="box-content">
|
||||
<HighlightedMarkdown
|
||||
author={author}
|
||||
text={replyText}
|
||||
color_picker={this.props.color_picker}
|
||||
show_pid={this.props.show_pid}
|
||||
color_picker={color_picker}
|
||||
show_pid={show_pid}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -158,13 +156,17 @@ class Reply extends PureComponent {
|
||||
class FlowItem extends PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
hot_score: props.info.hot_score || 0,
|
||||
cw: props.info.cw || '',
|
||||
}
|
||||
}
|
||||
|
||||
copy_link(event) {
|
||||
event.preventDefault();
|
||||
copy(
|
||||
`${event.target.href}${
|
||||
this.props.info.tag ? ' 【' + this.props.info.tag + '】' : ''
|
||||
this.props.info.cw ? ' 【' + this.props.info.cw + '】' : ''
|
||||
}\n` +
|
||||
`${this.props.info.text}${
|
||||
this.props.info.type === 'image'
|
||||
@@ -177,16 +179,32 @@ class FlowItem extends PureComponent {
|
||||
this.props.info.likenum
|
||||
}关注 ${this.props.info.reply}回复)\n` +
|
||||
this.props.replies
|
||||
.map((r) => (r.tag ? '【' + r.tag + '】' : '') + r.text)
|
||||
.map((r) => (r.cw ? '【' + r.cw + '】' : '') + r.text)
|
||||
.join('\n'),
|
||||
);
|
||||
}
|
||||
|
||||
on_hot_score_change(event) {
|
||||
this.setState({
|
||||
hot_score: event.target.value
|
||||
});
|
||||
}
|
||||
|
||||
on_cw_change(event) {
|
||||
this.setState({
|
||||
cw: event.target.value,
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
let props = this.props;
|
||||
const {
|
||||
info, is_quote, cached, attention, can_del, do_filter_name, do_delete,
|
||||
do_edit_cw, do_edit_score, timestamp, img_clickable, color_picker, show_pid
|
||||
} = this.props;
|
||||
const { cw, hot_score } = this.state;
|
||||
return (
|
||||
<div className={'flow-item' + (props.is_quote ? ' flow-item-quote' : '')}>
|
||||
{!!props.is_quote && (
|
||||
<div className={'flow-item' + (is_quote ? ' flow-item-quote' : '')}>
|
||||
{!!is_quote && (
|
||||
<div className="quote-tip black-outline">
|
||||
<div>
|
||||
<span className="icon icon-quote" />
|
||||
@@ -198,96 +216,142 @@ class FlowItem extends PureComponent {
|
||||
)}
|
||||
<div className="box">
|
||||
{!!window.LATEST_POST_ID &&
|
||||
parseInt(props.info.pid, 10) > window.LATEST_POST_ID && (
|
||||
parseInt(info.pid, 10) > window.LATEST_POST_ID && (
|
||||
<div className="flow-item-dot" />
|
||||
)}
|
||||
{!!this.props.attention && !this.props.cached && (
|
||||
{!!attention && !cached && (
|
||||
<div className="flow-item-dot" />
|
||||
)}
|
||||
<div className="box-header">
|
||||
{!!this.props.do_filter_name && (
|
||||
{!!do_filter_name && (
|
||||
<span
|
||||
className="reply-header-badge clickable"
|
||||
onClick={() => {
|
||||
this.props.do_filter_name(DZ_NAME);
|
||||
do_filter_name(DZ_NAME);
|
||||
}}
|
||||
>
|
||||
<span className="icon icon-locate" />
|
||||
</span>
|
||||
)}
|
||||
{!!parseInt(props.info.likenum, 10) && (
|
||||
{!!parseInt(info.likenum, 10) && (
|
||||
<span className="box-header-badge">
|
||||
{props.info.likenum}
|
||||
{info.likenum}
|
||||
<span
|
||||
className={
|
||||
'icon icon-' + (props.attention ? 'star-ok' : 'star')
|
||||
'icon icon-' + (attention ? 'star-ok' : 'star')
|
||||
}
|
||||
/>
|
||||
</span>
|
||||
)}
|
||||
{!!parseInt(props.info.reply, 10) && (
|
||||
{!!parseInt(info.reply, 10) && (
|
||||
<span className="box-header-badge">
|
||||
{props.info.reply}
|
||||
{info.reply}
|
||||
<span className="icon icon-reply" />
|
||||
</span>
|
||||
)}
|
||||
<code className="box-id">
|
||||
<a
|
||||
href={'##' + props.info.pid}
|
||||
href={'##' + info.pid}
|
||||
onClick={this.copy_link.bind(this)}
|
||||
>
|
||||
#{props.info.pid}
|
||||
#{info.pid}
|
||||
</a>
|
||||
</code>
|
||||
|
||||
{props.info.tag !== null && props.info.tag !== '折叠' && (
|
||||
<span className="box-header-tag">{props.info.tag}</span>
|
||||
{!!do_delete && !!info.can_del && (
|
||||
<span
|
||||
className="clickable"
|
||||
onClick={() => {
|
||||
do_delete('pid', info.pid);
|
||||
}}
|
||||
>
|
||||
<span className="icon icon-trash" />
|
||||
</span>
|
||||
)}
|
||||
<Time stamp={props.info.timestamp} short={!props.img_clickable} />
|
||||
|
||||
{info.cw !== null &&
|
||||
(!do_edit_cw || !info.can_del) && (
|
||||
<span className="box-header-cw">{info.cw}</span>
|
||||
)}
|
||||
{
|
||||
!!do_edit_cw && !!info.can_del && (
|
||||
<div className="box-header-cw-edit clickable">
|
||||
<input
|
||||
type="text"
|
||||
value={cw}
|
||||
maxLength="32"
|
||||
placeholder="编辑折叠警告"
|
||||
onChange={this.on_cw_change.bind(this)}
|
||||
/>
|
||||
<button type="button"
|
||||
onClick={(e)=>do_edit_cw(cw, info.pid)}>
|
||||
更新
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
{
|
||||
info.allow_search && <span> 📢 </span>
|
||||
}
|
||||
<Time stamp={info.timestamp} short={!img_clickable} />
|
||||
</div>
|
||||
{info.hot_score !== undefined && (do_edit_score ? (
|
||||
<>
|
||||
<input
|
||||
type="text"
|
||||
value={hot_score}
|
||||
onChange={this.on_hot_score_change.bind(this)}
|
||||
/>
|
||||
<button type="button"
|
||||
onClick={(e)=>do_edit_score(hot_score, info.pid)}>
|
||||
更新
|
||||
</button>
|
||||
</>
|
||||
) : (
|
||||
<span className="box-header">hot score: {info.hot_score}</span>
|
||||
))}
|
||||
<div className="box-content">
|
||||
<HighlightedMarkdown
|
||||
text={props.info.text}
|
||||
color_picker={props.color_picker}
|
||||
show_pid={props.show_pid}
|
||||
text={info.text}
|
||||
color_picker={color_picker}
|
||||
show_pid={show_pid}
|
||||
/>
|
||||
{props.info.type === 'image' && (
|
||||
{info.type === 'image' && (
|
||||
<p className="img">
|
||||
{props.img_clickable ? (
|
||||
{img_clickable ? (
|
||||
<a
|
||||
className="no-underline"
|
||||
href={IMAGE_BASE + props.info.url}
|
||||
href={IMAGE_BASE + info.url}
|
||||
target="_blank"
|
||||
>
|
||||
<img
|
||||
src={IMAGE_BASE + props.info.url}
|
||||
src={IMAGE_BASE + info.url}
|
||||
onError={(e) => {
|
||||
if (e.target.src === IMAGE_BASE + props.info.url) {
|
||||
e.target.src = IMAGE_BAK_BASE + props.info.url;
|
||||
if (e.target.src === IMAGE_BASE + info.url) {
|
||||
e.target.src = IMAGE_BAK_BASE + info.url;
|
||||
}
|
||||
}}
|
||||
alt={IMAGE_BASE + props.info.url}
|
||||
alt={IMAGE_BASE + info.url}
|
||||
/>
|
||||
</a>
|
||||
) : (
|
||||
<img
|
||||
src={IMAGE_BASE + props.info.url}
|
||||
src={IMAGE_BASE + info.url}
|
||||
onError={(e) => {
|
||||
if (e.target.src === IMAGE_BASE + props.info.url) {
|
||||
e.target.src = IMAGE_BAK_BASE + props.info.url;
|
||||
if (e.target.src === IMAGE_BASE + info.url) {
|
||||
e.target.src = IMAGE_BAK_BASE + info.url;
|
||||
}
|
||||
}}
|
||||
alt={IMAGE_BASE + props.info.url}
|
||||
alt={IMAGE_BASE + info.url}
|
||||
/>
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
{/*{props.info.type==='audio' && <AudioWidget src={AUDIO_BASE+props.info.url} />}*/}
|
||||
{/*{info.type==='audio' && <AudioWidget src={AUDIO_BASE+info.url} />}*/}
|
||||
</div>
|
||||
{!!(props.attention && props.info.variant.latest_reply) && (
|
||||
{!!(attention && info.variant.latest_reply) && (
|
||||
<p className="box-footer">
|
||||
最新回复{' '}
|
||||
<Time stamp={props.info.variant.latest_reply} short={false} />
|
||||
<Time stamp={info.variant.latest_reply} short={false} />
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
@@ -360,6 +424,7 @@ class FlowSidebar extends PureComponent {
|
||||
info: update_count
|
||||
? Object.assign({}, prev.info, {
|
||||
reply: '' + json.data.length,
|
||||
likenum: ''+json.likenum,
|
||||
})
|
||||
: prev.info,
|
||||
attention: !!json.attention,
|
||||
@@ -396,22 +461,41 @@ class FlowSidebar extends PureComponent {
|
||||
this.setState({
|
||||
loading_status: 'loading',
|
||||
});
|
||||
const next_attention = !this.state.attention;
|
||||
API.set_attention(this.state.info.pid, next_attention, this.props.token)
|
||||
const prev_info = this.state.info;
|
||||
const pid = prev_info.pid;
|
||||
API.set_attention(pid, !this.state.attention, this.props.token)
|
||||
.then((json) => {
|
||||
this.setState({
|
||||
loading_status: 'done',
|
||||
attention: next_attention,
|
||||
attention: json.attention,
|
||||
info: Object.assign({}, prev_info, {
|
||||
likenum: ''+json.likenum,
|
||||
}),
|
||||
});
|
||||
console.log(json);
|
||||
|
||||
let saved_attentions = window.saved_attentions;
|
||||
if (json.attention && !saved_attentions.includes(pid)) {
|
||||
saved_attentions.unshift(pid)
|
||||
} else if (!json.attention && saved_attentions.includes(pid)) {
|
||||
const idx = saved_attentions.indexOf(pid);
|
||||
saved_attentions.splice(idx, 1)
|
||||
}
|
||||
window.saved_attentions = saved_attentions;
|
||||
save_attentions();
|
||||
|
||||
this.syncState({
|
||||
attention: next_attention,
|
||||
attention: json.attention,
|
||||
info: Object.assign({}, prev_info, {
|
||||
likenum: ''+json.likenum,
|
||||
}),
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
this.setState({
|
||||
loading_status: 'done',
|
||||
});
|
||||
alert('设置关注失败');
|
||||
alert('设置关注失败\n' + e);
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
@@ -457,6 +541,55 @@ class FlowSidebar extends PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
make_do_delete(token, on_complete=null) {
|
||||
const do_delete = (type, id) => {
|
||||
console.log('del', type, id, token);
|
||||
let note = prompt(`将删除${type}=${id}, 备注:`, '(无)');
|
||||
if (note !== null) {
|
||||
API.del(type, id, note, token)
|
||||
.then((json) => {
|
||||
alert('删除成功');
|
||||
on_complete();
|
||||
})
|
||||
.catch((e) => {
|
||||
alert('删除失败\n' + e);
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
}
|
||||
return do_delete;
|
||||
}
|
||||
|
||||
make_do_edit_cw(token) {
|
||||
const do_edit_cw = (cw, id) => {
|
||||
console.log('edit cw', cw);
|
||||
API.update_cw(cw, id, token)
|
||||
.then((json) => {
|
||||
alert('已更新\n刷新列表显示新版本');
|
||||
})
|
||||
.catch((e) => {
|
||||
alert('更新失败\n' + e);
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
return do_edit_cw;
|
||||
}
|
||||
|
||||
make_do_edit_score(token) {
|
||||
const do_edit_score = (score, id) => {
|
||||
console.log('edit score', score);
|
||||
API.update_score(score, id, token)
|
||||
.then((json) => {
|
||||
console.log('已更新');
|
||||
})
|
||||
.catch((e) => {
|
||||
alert('更新失败\n' + e);
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
return do_edit_score;
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.loading_status === 'loading')
|
||||
return <p className="box box-tip">加载中……</p>;
|
||||
@@ -500,6 +633,9 @@ class FlowSidebar extends PureComponent {
|
||||
do_filter_name={
|
||||
replies_cnt[DZ_NAME] > 1 ? this.set_filter_name.bind(this) : null
|
||||
}
|
||||
do_delete={this.make_do_delete(this.props.token, ()=>{window.location.reload();})}
|
||||
do_edit_cw={this.make_do_edit_cw(this.props.token)}
|
||||
do_edit_score={this.make_do_edit_score(this.props.token)}
|
||||
/>
|
||||
</ClickHandler>
|
||||
);
|
||||
@@ -614,6 +750,7 @@ class FlowSidebar extends PureComponent {
|
||||
? this.set_filter_name.bind(this)
|
||||
: null
|
||||
}
|
||||
do_delete={this.make_do_delete(this.props.token, this.load_replies.bind(this))}
|
||||
/>
|
||||
</ClickHandler>
|
||||
</LazyLoad>
|
||||
@@ -637,19 +774,18 @@ class FlowSidebar extends PureComponent {
|
||||
class FlowItemRow extends PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.needFold =
|
||||
FOLD_TAGS.indexOf(props.info.tag) > -1 &&
|
||||
(props.search_param === '热榜' || !props.search_param) &&
|
||||
window.config.fold &&
|
||||
this.needFold = props.info.cw &&
|
||||
!props.search_param &&
|
||||
(window.config.whitelist_cw.indexOf('*')==-1 && window.config.whitelist_cw.indexOf(props.info.cw)==-1) &&
|
||||
props.mode !== 'attention' && props.mode !== 'attention_finished';
|
||||
this.state = {
|
||||
replies: [],
|
||||
reply_status: 'done',
|
||||
reply_error: null,
|
||||
info: Object.assign({}, props.info, { variant: {} }),
|
||||
hidden: window.config.block_words.some((word) =>
|
||||
props.info.text.includes(word),
|
||||
) || this.needFold,
|
||||
hidden: window.config.block_words_v2.some((word) =>
|
||||
props.info.text.includes(word),
|
||||
) && !props.info.can_del || this.needFold,
|
||||
attention:
|
||||
props.attention_override === null ? false : props.attention_override,
|
||||
cached: true, // default no display anything
|
||||
@@ -658,7 +794,8 @@ class FlowItemRow extends PureComponent {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (parseInt(this.state.info.reply, 10)) {
|
||||
// cache from getlist, so always to this to update attention
|
||||
if (true || parseInt(this.state.info.reply, 10)) {
|
||||
this.load_replies(null, /*update_count=*/ false);
|
||||
}
|
||||
}
|
||||
@@ -668,7 +805,7 @@ class FlowItemRow extends PureComponent {
|
||||
// }
|
||||
|
||||
load_replies(callback, update_count = true) {
|
||||
console.log('fetching reply', this.state.info.pid);
|
||||
//console.log('fetching reply', this.state.info.pid);
|
||||
this.setState({
|
||||
reply_status: 'loading',
|
||||
reply_error: null,
|
||||
@@ -680,6 +817,7 @@ class FlowItemRow extends PureComponent {
|
||||
parseInt(this.state.info.reply),
|
||||
)
|
||||
.then(({ data: json, cached }) => {
|
||||
//console.log('>> update', json, json.attention);
|
||||
this.setState(
|
||||
(prev, props) => ({
|
||||
replies: json.data,
|
||||
@@ -742,6 +880,7 @@ class FlowItemRow extends PureComponent {
|
||||
['url', URL_RE],
|
||||
['pid', PID_RE],
|
||||
['nickname', NICKNAME_RE],
|
||||
['tag', TAG_RE],
|
||||
];
|
||||
if (this.props.search_param) {
|
||||
hl_rules.push([
|
||||
@@ -753,6 +892,8 @@ class FlowItemRow extends PureComponent {
|
||||
}
|
||||
let parts = split_text(this.state.info.text, hl_rules);
|
||||
|
||||
//console.log('hl:', parts,this.state.info.pid);
|
||||
|
||||
let quote_id = null;
|
||||
if (!this.props.is_quote)
|
||||
for (let [mode, content] of parts) {
|
||||
@@ -827,7 +968,7 @@ class FlowItemRow extends PureComponent {
|
||||
);
|
||||
|
||||
if (this.state.hidden) {
|
||||
return (
|
||||
return this.needFold && (
|
||||
<div
|
||||
className="flow-item-row flow-item-row-with-prompt"
|
||||
onClick={(event) => {
|
||||
@@ -864,11 +1005,13 @@ class FlowItemRow extends PureComponent {
|
||||
)}
|
||||
<code className="box-id">#{this.props.info.pid}</code>
|
||||
|
||||
{this.props.info.tag !== null && this.props.info.tag !== '折叠' && (
|
||||
<span className="box-header-tag">{this.props.info.tag}</span>
|
||||
{this.props.info.cw !== null && (
|
||||
<span className="box-header-cw">{this.props.info.cw}</span>
|
||||
)}
|
||||
<Time stamp={this.props.info.timestamp} short={true} />
|
||||
<span className="box-header-badge">{this.needFold ? '已隐藏' : '已屏蔽'}</span>
|
||||
<span className="box-header-badge">
|
||||
{this.needFold ? '已折叠' : '已屏蔽'}
|
||||
</span>
|
||||
<div style={{ clear: 'both' }} />
|
||||
</div>
|
||||
</div>
|
||||
@@ -1019,6 +1162,63 @@ function FlowChunk(props) {
|
||||
}
|
||||
|
||||
export class Flow extends PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
submode: this.props.mode == 'list' ? (window.config.by_c ? 1 : 0) : 0,
|
||||
subflow_render_key: +new Date(),
|
||||
}
|
||||
}
|
||||
|
||||
get_submode_names(mode) {
|
||||
switch(mode) {
|
||||
case('list'):
|
||||
return ['最新', '最近回复', '近期热门', '随机'];
|
||||
case('attention'):
|
||||
return ['线上', '本地']
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
set_submode(submode) {
|
||||
this.setState({
|
||||
submode: submode,
|
||||
subflow_render_key: +new Date(),
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { submode } = this.state;
|
||||
const submode_names = this.get_submode_names(this.props.mode)
|
||||
return (
|
||||
<>
|
||||
<div className="aux-margin flow-submode-choice">
|
||||
{submode_names.map((name, idx) => (
|
||||
<a
|
||||
key={idx}
|
||||
className={submode === idx ? 'choiced' : ''}
|
||||
onClick={this.set_submode.bind(this, idx)}
|
||||
>
|
||||
{name}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<SubFlow
|
||||
key={this.state.subflow_render_key}
|
||||
show_sidebar={this.props.show_sidebar}
|
||||
mode={this.props.mode}
|
||||
submode={this.state.submode}
|
||||
search_text={this.props.search_text}
|
||||
token={this.props.token}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SubFlow extends PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
@@ -1029,6 +1229,7 @@ export class Flow extends PureComponent {
|
||||
title: '',
|
||||
data: [],
|
||||
},
|
||||
export_text: '',
|
||||
loading_status: 'done',
|
||||
error_msg: null,
|
||||
};
|
||||
@@ -1039,27 +1240,40 @@ export class Flow extends PureComponent {
|
||||
load_page(page) {
|
||||
const failed = (err) => {
|
||||
console.error(err);
|
||||
console.log(err.to_string);
|
||||
this.setState((prev, props) => ({
|
||||
loaded_pages: prev.loaded_pages - 1,
|
||||
loading_status: 'failed',
|
||||
error_msg: '' + err,
|
||||
error_msg: prev.loaded_pages > 1 ? '找不到更多了' : '' + err,
|
||||
}));
|
||||
};
|
||||
|
||||
if (page > this.state.loaded_pages + 1) throw new Error('bad page');
|
||||
if (page === this.state.loaded_pages + 1) {
|
||||
console.log('fetching page', page);
|
||||
cache();
|
||||
if (this.state.mode === 'list') {
|
||||
API.get_list(page, this.props.token)
|
||||
API.get_list(page, this.props.token, this.props.submode)
|
||||
.then((json) => {
|
||||
if (page === 1 && json.data.length) {
|
||||
// update latest_post_id
|
||||
let max_id = -1;
|
||||
let max_id = window.LATEST_POST_ID || -1;
|
||||
json.data.forEach((x) => {
|
||||
if (parseInt(x.pid, 10) > max_id) max_id = parseInt(x.pid, 10);
|
||||
});
|
||||
localStorage['_LATEST_POST_ID'] = '' + max_id;
|
||||
}
|
||||
json.data.forEach((x) => {
|
||||
if (x.comments) {
|
||||
let comment_json = {
|
||||
code: 0,
|
||||
attention: x.attention,
|
||||
data: x.comments,
|
||||
};
|
||||
//console.log('My cache', comment_json, x.pid, x.reply)
|
||||
cache().put(x.pid, parseInt(x.reply, 10), comment_json);
|
||||
}
|
||||
});
|
||||
this.setState((prev, props) => ({
|
||||
chunks: {
|
||||
title: 'News Feed',
|
||||
@@ -1077,7 +1291,7 @@ export class Flow extends PureComponent {
|
||||
}));
|
||||
})
|
||||
.catch(failed);
|
||||
} else if (this.state.mode === 'search') {
|
||||
} else if (this.state.mode === 'search' && this.state.search_param) {
|
||||
API.get_search(page, this.state.search_param, this.props.token)
|
||||
.then((json) => {
|
||||
const finished = json.data.length === 0;
|
||||
@@ -1103,6 +1317,17 @@ export class Flow extends PureComponent {
|
||||
const pid = parseInt(this.state.search_param.substr(1), 10);
|
||||
API.get_single(pid, this.props.token)
|
||||
.then((json) => {
|
||||
let x = json.data;
|
||||
if (x.comments) {
|
||||
let comment_json = {
|
||||
code: 0,
|
||||
attention: x.attention,
|
||||
data: x.comments,
|
||||
};
|
||||
//console.log('My cache', comment_json, x.pid, x.reply)
|
||||
cache().put(x.pid, parseInt(x.reply, 10), comment_json);
|
||||
}
|
||||
|
||||
this.setState({
|
||||
chunks: {
|
||||
title: 'PID = ' + pid,
|
||||
@@ -1126,32 +1351,52 @@ export class Flow extends PureComponent {
|
||||
}
|
||||
}
|
||||
console.log(use_search, use_regex);
|
||||
API.get_attention(this.props.token)
|
||||
.then((json) => {
|
||||
this.setState({
|
||||
chunks: {
|
||||
title: `${
|
||||
use_search
|
||||
? use_regex
|
||||
? `Result for RegEx ${regex_search.toString()} in `
|
||||
: `Result for "${this.state.search_param}" in `
|
||||
: ''
|
||||
}Attention List`,
|
||||
data: !use_search
|
||||
? json.data
|
||||
: !use_regex
|
||||
? json.data.filter((post) => {
|
||||
return this.state.search_param
|
||||
|
||||
if (this.props.submode === 0) {
|
||||
API.get_attention(this.props.token)
|
||||
.then((json) => {
|
||||
this.setState({
|
||||
chunks: {
|
||||
title: `${
|
||||
use_search
|
||||
? use_regex
|
||||
? `Result for RegEx ${regex_search.toString()} in `
|
||||
: `Result for "${this.state.search_param}" in `
|
||||
: ''
|
||||
}Attention List`,
|
||||
data: !use_search
|
||||
? json.data
|
||||
: !use_regex
|
||||
? json.data.filter((post) => {
|
||||
return this.state.search_param
|
||||
.split(' ')
|
||||
.every((keyword) => post.text.includes(keyword));
|
||||
}) // Not using regex
|
||||
: json.data.filter((post) => !!post.text.match(regex_search)), // Using regex
|
||||
},
|
||||
mode: 'attention_finished',
|
||||
loading_status: 'done',
|
||||
});
|
||||
})
|
||||
.catch(failed);
|
||||
}) // Not using regex
|
||||
: json.data.filter((post) => !!post.text.match(regex_search)), // Using regex
|
||||
},
|
||||
mode: 'attention_finished',
|
||||
loading_status: 'done',
|
||||
});
|
||||
if (!use_search) {
|
||||
window.saved_attentions = Array.from(
|
||||
new Set([
|
||||
...window.saved_attentions,
|
||||
...json.data.map(post => post.pid)
|
||||
])
|
||||
).sort().reverse();
|
||||
save_attentions();
|
||||
}
|
||||
})
|
||||
.catch(failed);
|
||||
} else if (this.props.submode === 1) {
|
||||
this.setState({
|
||||
title: 'Attention List: Local',
|
||||
data: [],
|
||||
export_text: `以下是浏览器本地保存的关注列表,将在下个版本提供直接展示\n\n#${
|
||||
window.saved_attentions.join('\n#')
|
||||
}`
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log('nothing to load');
|
||||
return;
|
||||
@@ -1184,10 +1429,41 @@ export class Flow extends PureComponent {
|
||||
window.removeEventListener('resize', this.on_scroll_bound);
|
||||
}
|
||||
|
||||
trunc_string(s, max_len) {
|
||||
return s.substr(0, max_len) + (
|
||||
s.length > max_len ? '...' : ''
|
||||
)
|
||||
}
|
||||
|
||||
gen_export() {
|
||||
this.setState({
|
||||
can_export: false,
|
||||
export_text: "以下是你关注的洞及摘要,复制保存到本地吧。\n\n" + this.state.chunks.data.map(
|
||||
p => `#${p.pid}: ${
|
||||
this.trunc_string(p.text.replaceAll('\n', ' '), 50)
|
||||
}`).join('\n\n')
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const should_deletion_detect = localStorage['DELETION_DETECT'] === 'on';
|
||||
return (
|
||||
<div className="flow-container">
|
||||
|
||||
{this.state.mode === 'attention_finished' && this.props.submode == 0 && (
|
||||
<button className="export-btn" type="button" onClick={this.gen_export.bind(this)}>导出</button>
|
||||
)}
|
||||
|
||||
{this.state.export_text && (
|
||||
<div className="box">
|
||||
<textarea
|
||||
className="export-textarea"
|
||||
value={this.state.export_text}
|
||||
readOnly
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<FlowChunk
|
||||
title={this.state.chunks.title}
|
||||
list={this.state.chunks.data}
|
||||
@@ -1220,7 +1496,7 @@ export class Flow extends PureComponent {
|
||||
Loading...
|
||||
</span>
|
||||
) : (
|
||||
'© thuhole'
|
||||
'🄯 2020 copyleft: hole_thu'
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
19
src/Message.css
Normal file
@@ -0,0 +1,19 @@
|
||||
.input-prepend {
|
||||
display: inline-block;
|
||||
background-color: #c9cccf;
|
||||
border: 1px solid #ced4da;
|
||||
height: 28px;
|
||||
padding: 3px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.input-suf {
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
width: 90px;
|
||||
height: 28px;
|
||||
border: 1px solid #ced4da;
|
||||
vertical-align: top;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { THUHOLE_API_ROOT, get_json, API_VERSION_PARAM } from './flows_api';
|
||||
import { Time } from './Common';
|
||||
import { Time, API_BASE } from './Common';
|
||||
import { get_json } from './infrastructure/functions';
|
||||
|
||||
import './Message.css';
|
||||
|
||||
export class MessageViewer extends PureComponent {
|
||||
constructor(props) {
|
||||
@@ -9,6 +11,7 @@ export class MessageViewer extends PureComponent {
|
||||
loading_status: 'idle',
|
||||
msg: [],
|
||||
};
|
||||
this.input_suf_ref=React.createRef();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
@@ -23,19 +26,20 @@ export class MessageViewer extends PureComponent {
|
||||
},
|
||||
() => {
|
||||
fetch(
|
||||
THUHOLE_API_ROOT +
|
||||
'api_xmcp/hole/system_msg?user_token=' +
|
||||
encodeURIComponent(this.props.token) +
|
||||
API_VERSION_PARAM(),
|
||||
API_BASE + '/systemlog',
|
||||
{
|
||||
headers: {'User-Token': this.props.token},
|
||||
}
|
||||
)
|
||||
.then(get_json)
|
||||
.then((json) => {
|
||||
if (json.error) throw new Error(json.error);
|
||||
else
|
||||
this.setState({
|
||||
loading_status: 'done',
|
||||
msg: json.result,
|
||||
});
|
||||
this.setState({
|
||||
loading_status: 'done',
|
||||
msg: json.data,
|
||||
start_time: json.start_time,
|
||||
salt: json.salt,
|
||||
tmp_token: json.tmp_token,
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
@@ -48,6 +52,20 @@ export class MessageViewer extends PureComponent {
|
||||
);
|
||||
}
|
||||
|
||||
do_set_token() {
|
||||
if (this.state.loading_status==='loading')
|
||||
return;
|
||||
if (!this.input_suf_ref.current.value) {
|
||||
alert("不建议后缀为空");
|
||||
return;
|
||||
}
|
||||
let tt = this.state.tmp_token + '_' + this.input_suf_ref.current.value;
|
||||
console.log(tt);
|
||||
localStorage['TOKEN'] = tt;
|
||||
alert('已登录为临时用户,过期后需注销重新登陆');
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.loading_status === 'loading')
|
||||
return <p className="box box-tip">加载中……</p>;
|
||||
@@ -64,17 +82,42 @@ export class MessageViewer extends PureComponent {
|
||||
</div>
|
||||
);
|
||||
else if (this.state.loading_status === 'done')
|
||||
return this.state.msg.map((msg) => (
|
||||
<div className="box" key={msg.timestamp}>
|
||||
<div className="box-header">
|
||||
<Time stamp={msg.timestamp} short={false} />
|
||||
<b>{msg.title}</b>
|
||||
return (
|
||||
<>
|
||||
<br/>
|
||||
<p>
|
||||
最近一次重置 <Time stamp={this.state.start_time} short={false} />
|
||||
</p>
|
||||
<p>
|
||||
随机盐 <b>{this.state.salt}</b>
|
||||
</p>
|
||||
<br/>
|
||||
<div>
|
||||
<p>15分钟临时token:</p>
|
||||
<div className="input-prepend">{this.state.tmp_token}_ </div>
|
||||
<input type="text" className="input-suf" ref={this.input_suf_ref} placeholder="自定义后缀" maxLength={10}/>
|
||||
<button type="button" disabled={this.state.loading_status==='loading'}
|
||||
onClick={(e)=>this.do_set_token()}>
|
||||
使用
|
||||
</button>
|
||||
</div>
|
||||
<div className="box-content">
|
||||
<pre>{msg.content}</pre>
|
||||
</div>
|
||||
</div>
|
||||
));
|
||||
{this.state.msg.map((msg) => (
|
||||
<div className="box" key={msg.type + msg.timestamp}>
|
||||
<div className="box-header">
|
||||
<Time stamp={msg.timestamp} short={false} />
|
||||
|
||||
|
||||
<b>{msg.type}</b>
|
||||
|
||||
<span className="box-header-name">{msg.user}</span>
|
||||
</div>
|
||||
<div className="box-content">
|
||||
<pre>{msg.detail}</pre>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
)
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
|
||||
30
src/Title.js
@@ -35,6 +35,24 @@ class ControlBar extends PureComponent {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
window.addEventListener("hashchange",
|
||||
() => {
|
||||
let text = decodeURIComponent(window.location.hash).substr(1);
|
||||
if(text && text[0]!='#') {
|
||||
console.log('search', text);
|
||||
this.setState(
|
||||
{
|
||||
search_text: text,
|
||||
},
|
||||
() => {
|
||||
this.on_keypress({ key: 'Enter' });
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
on_change(event) {
|
||||
@@ -82,6 +100,7 @@ class ControlBar extends PureComponent {
|
||||
search_text: '',
|
||||
});
|
||||
this.set_mode('list', null);
|
||||
window.location.hash = '';
|
||||
}
|
||||
|
||||
do_attention() {
|
||||
@@ -116,9 +135,8 @@ class ControlBar extends PureComponent {
|
||||
<input
|
||||
className="control-search"
|
||||
value={this.state.search_text}
|
||||
placeholder={`${
|
||||
this.props.mode === 'attention' ? '在关注列表中' : ''
|
||||
}搜索 或 #树洞号`}
|
||||
placeholder={
|
||||
this.props.mode === 'attention' ? '在关注列表中搜索' : '关键词 / tag / #树洞号'}
|
||||
onChange={this.on_change_bound}
|
||||
onKeyPress={this.on_keypress_bound}
|
||||
/>
|
||||
@@ -126,7 +144,7 @@ class ControlBar extends PureComponent {
|
||||
className="no-underline control-btn"
|
||||
onClick={() => {
|
||||
this.props.show_sidebar(
|
||||
'T大树洞',
|
||||
'新T树洞',
|
||||
<InfoSidebar show_sidebar={this.props.show_sidebar} />,
|
||||
);
|
||||
}}
|
||||
@@ -173,12 +191,12 @@ export function Title(props) {
|
||||
<span
|
||||
onClick={() =>
|
||||
props.show_sidebar(
|
||||
'T大树洞',
|
||||
'新T树洞',
|
||||
<InfoSidebar show_sidebar={props.show_sidebar} />,
|
||||
)
|
||||
}
|
||||
>
|
||||
T大树洞
|
||||
新T树洞
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
text-align: center;
|
||||
}
|
||||
.login-form button {
|
||||
width: 6rem;
|
||||
min-width: 6rem;
|
||||
}
|
||||
|
||||
.reply-form {
|
||||
@@ -40,6 +40,7 @@
|
||||
|
||||
.post-form-bar label {
|
||||
flex: 1;
|
||||
margin: 0 0.5rem;
|
||||
}
|
||||
|
||||
.post-form-bar input[type=file] {
|
||||
@@ -109,3 +110,9 @@
|
||||
.life-info-error a {
|
||||
--var-link-color: hsl(25,100%,45%);
|
||||
}
|
||||
|
||||
.spoiler-input {
|
||||
width: 100%;
|
||||
margin-bottom: 5px;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
@@ -13,12 +13,10 @@ import fixOrientation from 'fix-orientation';
|
||||
import copy from 'copy-to-clipboard';
|
||||
import { cache } from './cache';
|
||||
import {
|
||||
API_VERSION_PARAM,
|
||||
THUHOLE_API_ROOT,
|
||||
API,
|
||||
get_json,
|
||||
token_param,
|
||||
} from './flows_api';
|
||||
import { save_attentions } from './Attention'
|
||||
|
||||
import './UserAction.css';
|
||||
|
||||
@@ -27,191 +25,25 @@ const MAX_IMG_DIAM = 8000;
|
||||
const MAX_IMG_PX = 5000000;
|
||||
const MAX_IMG_FILESIZE = 450000 * BASE64_RATE;
|
||||
|
||||
const REPOSITORY = 'https://git.thu.monster/newthuhole/';
|
||||
const EMAIL = 'hole_thu@riseup.net';
|
||||
|
||||
export const TokenCtx = React.createContext({
|
||||
value: null,
|
||||
set_value: () => {},
|
||||
});
|
||||
|
||||
// class LifeInfoBox extends Component {
|
||||
// constructor(props) {
|
||||
// super(props);
|
||||
// if(!window._life_info_cache)
|
||||
// window._life_info_cache={};
|
||||
// this.CACHE_TIMEOUT_S=15;
|
||||
// this.state={
|
||||
// today_info: this.cache_get('today_info'),
|
||||
// card_balance: this.cache_get('card_balance'),
|
||||
// net_balance: this.cache_get('net_balance'),
|
||||
// mail_count: this.cache_get('mail_count'),
|
||||
// };
|
||||
// this.INTERNAL_NETWORK_FAILURE='_network_failure';
|
||||
// this.API_NAME={
|
||||
// today_info: 'hole/today_info',
|
||||
// card_balance: 'isop/card_balance',
|
||||
// net_balance: 'isop/net_balance',
|
||||
// mail_count: 'isop/mail_count',
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// cache_get(key) {
|
||||
// let cache_item=window._life_info_cache[key];
|
||||
// if(!cache_item || (+new Date())-cache_item[0]>1000*this.CACHE_TIMEOUT_S)
|
||||
// return null;
|
||||
// else
|
||||
// return cache_item[1];
|
||||
// }
|
||||
// cache_set(key,value) {
|
||||
// if(!window._life_info_cache[key] || window._life_info_cache[key][1]!==value)
|
||||
// window._life_info_cache[key]=[+new Date(),value];
|
||||
// }
|
||||
//
|
||||
// load(state_key) {
|
||||
// this.setState({
|
||||
// [state_key]: null,
|
||||
// },()=>{
|
||||
// fetch(
|
||||
// PKUHELPER_ROOT+'api_xmcp/'+this.API_NAME[state_key]
|
||||
// +'?user_token='+encodeURIComponent(this.props.token)
|
||||
// +API_VERSION_PARAM()
|
||||
// )
|
||||
// .then(get_json)
|
||||
// .then((json)=>{
|
||||
// //console.log(json);
|
||||
// this.setState({
|
||||
// [state_key]: json,
|
||||
// });
|
||||
// })
|
||||
// .catch((e)=>{
|
||||
// this.setState({
|
||||
// [state_key]: {
|
||||
// errMsg: '网络错误 '+e,
|
||||
// errCode: this.INTERNAL_NETWORK_FAILURE,
|
||||
// success: false,
|
||||
// }
|
||||
// });
|
||||
// })
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// componentDidMount() {
|
||||
// ['today_info','card_balance','net_balance','mail_count'].forEach((k)=>{
|
||||
// if(!this.state[k])
|
||||
// this.load(k);
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// reload_all() {
|
||||
// ['today_info','card_balance','net_balance','mail_count'].forEach((k)=>{
|
||||
// this.load(k);
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// render_line(state_key,title,value_fn,action,url_fn,do_login) {
|
||||
// let s=this.state[state_key];
|
||||
// if(!s)
|
||||
// return (
|
||||
// <tr>
|
||||
// <td>{title}</td>
|
||||
// <td>加载中……</td>
|
||||
// <td />
|
||||
// </tr>
|
||||
// );
|
||||
// else if(!s.success) {
|
||||
// let type='加载失败';
|
||||
// if(s.errCode===this.INTERNAL_NETWORK_FAILURE)
|
||||
// type='网络错误';
|
||||
// else if(['E01','E02','E03'].indexOf(s.errCode)!==-1)
|
||||
// type='授权失效';
|
||||
//
|
||||
// let details=JSON.stringify(s);
|
||||
// if(s.errMsg)
|
||||
// details=s.errMsg;
|
||||
// else if(s.error)
|
||||
// details=s.error;
|
||||
//
|
||||
// return (
|
||||
// <tr>
|
||||
// <td>{title}</td>
|
||||
// <td className="life-info-error">
|
||||
// <a onClick={()=>alert(details)}>{type}</a>
|
||||
// </td>
|
||||
// <td>
|
||||
// {type==='授权失效' ?
|
||||
// <a onClick={do_login}>
|
||||
// <span className="icon icon-forward" /> 重新登录
|
||||
// </a> :
|
||||
// <a onClick={()=>this.load(state_key)}>
|
||||
// <span className="icon icon-forward" /> 重试
|
||||
// </a>
|
||||
// }
|
||||
// </td>
|
||||
// </tr>
|
||||
// )
|
||||
// }
|
||||
// else {
|
||||
// this.cache_set(state_key,s);
|
||||
//
|
||||
// return (
|
||||
// <tr>
|
||||
// <td>{title}</td>
|
||||
// <td>{value_fn(s)}</td>
|
||||
// <td>
|
||||
// <a href={url_fn(s)} target="_blank">
|
||||
// <span className="icon icon-forward" /> {action}
|
||||
// </a>
|
||||
// </td>
|
||||
// </tr>
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// render() {
|
||||
// return (
|
||||
// <LoginPopup token_callback={(t)=>{
|
||||
// this.props.set_token(t);
|
||||
// this.reload_all();
|
||||
// }}>{(do_login)=>(
|
||||
// <div className="box">
|
||||
// <table className="life-info-table">
|
||||
// <tbody>
|
||||
// {this.render_line(
|
||||
// 'today_info',
|
||||
// '今日',(s)=>s.info,
|
||||
// '校历',(s)=>s.schedule_url,
|
||||
// do_login,
|
||||
// )}
|
||||
// {this.render_line(
|
||||
// 'card_balance',
|
||||
// '校园卡',(s)=>`余额¥${s.balance.toFixed(2)}`,
|
||||
// '充值',()=>'https://virtualprod.alipay.com/educate/educatePcRecharge.htm?schoolCode=PKU&schoolName=',
|
||||
// do_login,
|
||||
// )}
|
||||
// {this.render_line(
|
||||
// 'net_balance',
|
||||
// '网费',(s)=>`余额¥${s.balance.toFixed(2)}`,
|
||||
// '充值',()=>'https://its.pku.edu.cn/epay.jsp',
|
||||
// do_login,
|
||||
// )}
|
||||
// {this.render_line(
|
||||
// 'mail_count',
|
||||
// '邮件',(s)=>`未读 ${s.count} 封`,
|
||||
// '查看',()=>'https://mail.pku.edu.cn/',
|
||||
// do_login,
|
||||
// )}
|
||||
// </tbody>
|
||||
// </table>
|
||||
// </div>
|
||||
// )}</LoginPopup>
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
|
||||
export function InfoSidebar(props) {
|
||||
return (
|
||||
<div>
|
||||
<PromotionBar />
|
||||
<LoginForm show_sidebar={props.show_sidebar} />
|
||||
<div className="box list-menu">
|
||||
<a href="/about.html" target="_blank">
|
||||
<span className="icon icon-about" />
|
||||
<label>关于</label>
|
||||
</a>
|
||||
|
||||
<a
|
||||
onClick={() => {
|
||||
props.show_sidebar('设置', <ConfigUI />);
|
||||
@@ -221,18 +53,11 @@ export function InfoSidebar(props) {
|
||||
<label>设置</label>
|
||||
</a>
|
||||
|
||||
<a href="https://thuhole.com/policy.html" target="_blank">
|
||||
<a href="/policy.html" target="_blank">
|
||||
<span className="icon icon-textfile" />
|
||||
<label>树洞规范(试行)</label>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://github.com/thuhole/thuhole-go-backend/issues"
|
||||
target="_blank"
|
||||
>
|
||||
<span className="icon icon-github" />
|
||||
<label>意见反馈</label>
|
||||
</a>
|
||||
<p><em>强烈建议开始使用前先看一遍所有设置选项</em></p>
|
||||
</div>
|
||||
<div className="box help-desc-box">
|
||||
<p>
|
||||
@@ -261,25 +86,26 @@ export function InfoSidebar(props) {
|
||||
</p>
|
||||
</div>
|
||||
<div className="box help-desc-box">
|
||||
<p>联系我们:thuhole at protonmail dot com</p>
|
||||
<p>意见反馈请加tag #意见反馈 或到github后端的issue区。</p>
|
||||
<p>新T树洞强烈期待有其他更多树洞的出现,一起分布式互联,构建清华树洞族。详情见 关于 中的描述。</p>
|
||||
<p>联系我们:<a href={"mailto:"+EMAIL}>{EMAIL}</a> 。</p>
|
||||
</div>
|
||||
<div className="box help-desc-box">
|
||||
<p>
|
||||
T大树洞 网页版 by @thuhole, 基于
|
||||
<a
|
||||
href="https://www.gnu.org/licenses/gpl-3.0.zh-cn.html"
|
||||
新T树洞 网页版 by @hole_thu,基于
|
||||
<a href="https://www.gnu.org/licenses/agpl-3.0.html"
|
||||
target="_blank"
|
||||
>
|
||||
GPLv3
|
||||
AGPLv3
|
||||
</a>
|
||||
协议在{' '}
|
||||
<a href="https://github.com/thuhole/webhole" target="_blank">
|
||||
GitHub
|
||||
协议在{' '}
|
||||
<a href={REPOSITORY} target="_blank">
|
||||
Gitea
|
||||
</a>{' '}
|
||||
开源
|
||||
开源。
|
||||
</p>
|
||||
<p>
|
||||
T大树洞 网页版的诞生离不开
|
||||
新T树洞 网页版基于
|
||||
<a
|
||||
href="https://github.com/pkuhelper-web/webhole"
|
||||
target="_blank"
|
||||
@@ -288,103 +114,27 @@ export function InfoSidebar(props) {
|
||||
P大树洞网页版 by @xmcp
|
||||
</a>
|
||||
、
|
||||
<a href="https://reactjs.org/" target="_blank" rel="noopener">
|
||||
<a
|
||||
href="https://github.com/thuhole/webhole"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>
|
||||
T大树洞网页版 by @thuhole
|
||||
</a>
|
||||
、 <a href="https://reactjs.org/" target="_blank" rel="noopener">
|
||||
React
|
||||
</a>
|
||||
、
|
||||
<a href="https://icomoon.io/#icons" target="_blank" rel="noopener">
|
||||
IcoMoon
|
||||
</a>
|
||||
等开源项目
|
||||
</p>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
<p>
|
||||
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
|
||||
<a
|
||||
href="https://www.gnu.org/licenses/gpl-3.0.zh-cn.html"
|
||||
target="_blank"
|
||||
>
|
||||
GNU General Public License
|
||||
</a>
|
||||
for more details.
|
||||
等开源项目。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
class ResetUsertokenWidget extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
loading_status: 'done',
|
||||
};
|
||||
}
|
||||
|
||||
do_reset() {
|
||||
if (
|
||||
window.confirm(
|
||||
'您正在重置 UserToken!\n您的账号将会在【所有设备】上注销,您需要手动重新登录!',
|
||||
)
|
||||
) {
|
||||
let uid = window.prompt(
|
||||
'您正在重置 UserToken!\n请输入您的学号以确认身份:',
|
||||
);
|
||||
if (uid)
|
||||
this.setState(
|
||||
{
|
||||
loading_status: 'loading',
|
||||
},
|
||||
() => {
|
||||
fetch(THUHOLE_API_ROOT + 'api_xmcp/hole/reset_usertoken', {
|
||||
method: 'post',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
user_token: this.props.token,
|
||||
uid: uid,
|
||||
}),
|
||||
})
|
||||
.then(get_json)
|
||||
.then((json) => {
|
||||
if (json.error) throw new Error(json.error);
|
||||
else alert('重置成功!您需要在所有设备上重新登录。');
|
||||
|
||||
this.setState({
|
||||
loading_status: 'done',
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
alert('重置失败:' + e);
|
||||
this.setState({
|
||||
loading_status: 'done',
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.loading_status === 'done')
|
||||
return <a onClick={this.do_reset.bind(this)}>重置</a>;
|
||||
else if (this.state.loading_status === 'loading')
|
||||
return (
|
||||
<a>
|
||||
<span className="icon icon-loading" />
|
||||
</a>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class LoginForm extends Component {
|
||||
copy_token(token) {
|
||||
if (copy(token)) alert('复制成功!\n请一定不要泄露哦');
|
||||
@@ -413,32 +163,26 @@ export class LoginForm extends Component {
|
||||
</button>
|
||||
<br />
|
||||
</p>
|
||||
{/*<p>*/}
|
||||
{/*根据计算中心要求,访问授权三个月内有效,过期需重新登录。*/}
|
||||
{/*T大树洞将会单向加密(i.e. 哈希散列)您的邮箱后再存入数据库,因此您的发帖具有较强的匿名性。具体可见我们的<a href="https://github.com/thuhole/thuhole-go-backend/blob/76f56e6b75257b59e552b6bdba77e114151fcad1/src/db.go#L184">后端开源代码</a>。*/}
|
||||
{/*</p>*/}
|
||||
<p>
|
||||
<a
|
||||
onClick={() => {
|
||||
this.props.show_sidebar(
|
||||
'系统消息',
|
||||
'系统日志',
|
||||
<MessageViewer token={token.value} />,
|
||||
);
|
||||
}}
|
||||
>
|
||||
查看系统消息
|
||||
查看系统日志
|
||||
</a>
|
||||
<br />
|
||||
当您发送的内容违规时,我们将用系统消息提示您
|
||||
举报记录、管理日志等都是公开的
|
||||
</p>
|
||||
<p>
|
||||
<a onClick={this.copy_token.bind(this, token.value)}>
|
||||
复制 User Token
|
||||
</a>
|
||||
<br />
|
||||
复制 User Token
|
||||
可以在新设备登录,切勿告知他人。若怀疑被盗号请重新邮箱验证码登录以重置Token。
|
||||
{/*,若怀疑被盗号请尽快 <ResetUsertokenWidget token={token.value} />*/}
|
||||
User Token仅用于开发bot,切勿告知他人。若怀疑被盗号请刷新Token(刷新功能即将上线)。
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
@@ -453,8 +197,8 @@ export class LoginForm extends Component {
|
||||
</p>
|
||||
<p>
|
||||
<small>
|
||||
T大树洞
|
||||
面向T大学生,通过T大邮箱验证您的身份并提供服务。
|
||||
新T树洞
|
||||
面向T大学生,通过已验证身份的第三方服务授权登陆。
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
@@ -517,20 +261,22 @@ export class ReplyForm extends Component {
|
||||
on_submit(event) {
|
||||
if (event) event.preventDefault();
|
||||
if (this.state.loading_status === 'loading') return;
|
||||
if (!this.state.text) return;
|
||||
this.setState({
|
||||
loading_status: 'loading',
|
||||
});
|
||||
|
||||
let data = new URLSearchParams();
|
||||
data.append('pid', this.props.pid);
|
||||
let pid = this.props.pid;
|
||||
data.append('pid', pid);
|
||||
data.append('text', this.state.text);
|
||||
data.append('user_token', this.props.token);
|
||||
fetch(
|
||||
API_BASE + '/api.php?action=docomment' + token_param(this.props.token),
|
||||
API_BASE + '/docomment',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'User-Token': this.props.token,
|
||||
},
|
||||
body: data,
|
||||
},
|
||||
@@ -542,6 +288,13 @@ export class ReplyForm extends Component {
|
||||
throw new Error(JSON.stringify(json));
|
||||
}
|
||||
|
||||
let saved_attentions = window.saved_attentions;
|
||||
if (!saved_attentions.includes(pid)) {
|
||||
saved_attentions.unshift(pid)
|
||||
window.saved_attentions = saved_attentions;
|
||||
save_attentions();
|
||||
}
|
||||
|
||||
this.setState({
|
||||
loading_status: 'done',
|
||||
text: '',
|
||||
@@ -552,7 +305,7 @@ export class ReplyForm extends Component {
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
alert('回复失败');
|
||||
alert('回复失败\n' + e);
|
||||
this.setState({
|
||||
loading_status: 'done',
|
||||
});
|
||||
@@ -618,6 +371,8 @@ export class PostForm extends Component {
|
||||
super(props);
|
||||
this.state = {
|
||||
text: '',
|
||||
cw: window.CW_BACKUP || '',
|
||||
allow_search: window.AS_BACKUP || false,
|
||||
loading_status: 'done',
|
||||
img_tip: null,
|
||||
preview: false,
|
||||
@@ -625,6 +380,8 @@ export class PostForm extends Component {
|
||||
this.img_ref = React.createRef();
|
||||
this.area_ref = React.createRef();
|
||||
this.on_change_bound = this.on_change.bind(this);
|
||||
this.on_allow_search_change_bound = this.on_allow_search_change.bind(this);
|
||||
this.on_cw_change_bound = this.on_cw_change.bind(this);
|
||||
this.on_img_change_bound = this.on_img_change.bind(this);
|
||||
this.color_picker = new ColorPicker();
|
||||
}
|
||||
@@ -633,6 +390,23 @@ export class PostForm extends Component {
|
||||
if (this.area_ref.current) this.area_ref.current.focus();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
window.CW_BACKUP = this.state.cw;
|
||||
window.AS_BACKUP = this.state.allow_search;
|
||||
}
|
||||
|
||||
on_allow_search_change(event) {
|
||||
this.setState({
|
||||
allow_search: event.target.checked,
|
||||
});
|
||||
}
|
||||
|
||||
on_cw_change(event) {
|
||||
this.setState({
|
||||
cw: event.target.value,
|
||||
});
|
||||
}
|
||||
|
||||
on_change(value) {
|
||||
this.setState({
|
||||
text: value,
|
||||
@@ -641,15 +415,17 @@ export class PostForm extends Component {
|
||||
|
||||
do_post(text, img) {
|
||||
let data = new URLSearchParams();
|
||||
data.append('cw', this.state.cw);
|
||||
data.append('text', this.state.text);
|
||||
data.append('allow_search', this.state.allow_search ? '1' : '');
|
||||
data.append('type', img ? 'image' : 'text');
|
||||
data.append('user_token', this.props.token);
|
||||
if (img) data.append('data', img);
|
||||
|
||||
fetch(API_BASE + '/api.php?action=dopost' + token_param(this.props.token), {
|
||||
fetch(API_BASE + '/dopost', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'User-Token': this.props.token,
|
||||
},
|
||||
body: data,
|
||||
})
|
||||
@@ -667,10 +443,11 @@ export class PostForm extends Component {
|
||||
});
|
||||
this.area_ref.current.clear();
|
||||
this.props.on_complete();
|
||||
window.CW_BACKUP = '';
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
alert('发表失败');
|
||||
alert('发表失败\n' + e);
|
||||
this.setState({
|
||||
loading_status: 'done',
|
||||
});
|
||||
@@ -795,6 +572,8 @@ export class PostForm extends Component {
|
||||
on_submit(event) {
|
||||
if (event) event.preventDefault();
|
||||
if (this.state.loading_status === 'loading') return;
|
||||
if (!this.state.text) return;
|
||||
/*
|
||||
if (this.img_ref.current.files.length) {
|
||||
this.setState({
|
||||
loading_status: 'processing',
|
||||
@@ -809,7 +588,8 @@ export class PostForm extends Component {
|
||||
.catch((e) => {
|
||||
alert(e);
|
||||
});
|
||||
} else {
|
||||
} else */
|
||||
{
|
||||
this.setState({
|
||||
loading_status: 'loading',
|
||||
});
|
||||
@@ -827,6 +607,7 @@ export class PostForm extends Component {
|
||||
return (
|
||||
<form onSubmit={this.on_submit.bind(this)} className="post-form box">
|
||||
<div className="post-form-bar">
|
||||
{/*
|
||||
<label>
|
||||
图片
|
||||
<input
|
||||
@@ -837,6 +618,7 @@ export class PostForm extends Component {
|
||||
onChange={this.on_img_change_bound}
|
||||
/>
|
||||
</label>
|
||||
*/}
|
||||
|
||||
{this.state.preview ? (
|
||||
<button
|
||||
@@ -872,6 +654,16 @@ export class PostForm extends Component {
|
||||
发表
|
||||
</button>
|
||||
)}
|
||||
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
onChange={this.on_allow_search_change_bound}
|
||||
checked={this.state.allow_search}
|
||||
/>
|
||||
允许被搜索
|
||||
</label>
|
||||
|
||||
</div>
|
||||
{!!this.state.img_tip && (
|
||||
<p className="post-form-img-tip">
|
||||
@@ -895,20 +687,52 @@ export class PostForm extends Component {
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<SafeTextarea
|
||||
ref={this.area_ref}
|
||||
id="new_post"
|
||||
on_change={this.on_change_bound}
|
||||
on_submit={this.on_submit.bind(this)}
|
||||
/>
|
||||
<>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="折叠警告(留空表示不折叠)"
|
||||
value={this.state.cw}
|
||||
id="post_cw"
|
||||
className="spoiler-input"
|
||||
onChange={this.on_cw_change_bound}
|
||||
maxLength="32"
|
||||
/>
|
||||
<SafeTextarea
|
||||
ref={this.area_ref}
|
||||
id="new_post"
|
||||
on_change={this.on_change_bound}
|
||||
on_submit={this.on_submit.bind(this)}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<p>
|
||||
<small>
|
||||
请遵守
|
||||
<a href="https://thuhole.com/policy.html" target="_blank">
|
||||
<a href="/policy.html" target="_blank">
|
||||
树洞管理规范(试行)
|
||||
</a>
|
||||
,文明发言
|
||||
,文明发言。
|
||||
</small>
|
||||
</p>
|
||||
<p>
|
||||
<small>
|
||||
插入图片请使用图片外链,Markdown格式 , 支持动图,支持多图。推荐的图床:
|
||||
<a href="https://imgchr.com/" target="_blank">
|
||||
路过图床
|
||||
</a>
|
||||
、
|
||||
<a href="https://sm.ms/" target="_blank">
|
||||
sm.ms
|
||||
</a>
|
||||
、
|
||||
<a href="https://bbs.pku.edu.cn/v2/post-read.php?bid=154&threadid=3743" target="_blank">
|
||||
未名BBS
|
||||
</a>
|
||||
、
|
||||
<a href="https://zhuanlan.zhihu.com/write" target="_blank">
|
||||
知乎
|
||||
</a>
|
||||
。
|
||||
</small>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
@@ -75,7 +75,7 @@ class Cache {
|
||||
resolve(null);
|
||||
} else if (target_version === res.version) {
|
||||
// hit
|
||||
console.log('comment cache hit', pid);
|
||||
//console.log('comment cache hit', pid);
|
||||
res.last_access = +new Date();
|
||||
store.put(res);
|
||||
let data = this.decrypt(pid, res.data_str);
|
||||
@@ -114,7 +114,7 @@ class Cache {
|
||||
data_str: this.encrypt(pid, data),
|
||||
last_access: +new Date(),
|
||||
});
|
||||
console.log('comment cache put', pid);
|
||||
//console.log('comment cache put', pid);
|
||||
if (++this.added_items_since_maintenance === MAINTENANCE_STEP)
|
||||
setTimeout(this.maintenance.bind(this), 1);
|
||||
});
|
||||
|
||||
112
src/flows_api.js
@@ -1,14 +1,7 @@
|
||||
import { get_json, API_VERSION_PARAM } from './infrastructure/functions';
|
||||
import { THUHOLE_API_ROOT } from './infrastructure/const';
|
||||
import { get_json, gen_name} from './infrastructure/functions';
|
||||
import { API_BASE } from './Common';
|
||||
import { cache } from './cache';
|
||||
|
||||
export { THUHOLE_API_ROOT, API_VERSION_PARAM };
|
||||
|
||||
export function token_param(token) {
|
||||
return API_VERSION_PARAM() + (token ? '&user_token=' + token : '');
|
||||
}
|
||||
|
||||
export { get_json };
|
||||
|
||||
const SEARCH_PAGESIZE = 50;
|
||||
@@ -28,6 +21,7 @@ const parse_replies = (replies, color_picker) =>
|
||||
replies
|
||||
.sort((a, b) => parseInt(a.cid, 10) - parseInt(b.cid, 10))
|
||||
.map((info) => {
|
||||
info.name = gen_name(info.name_id);
|
||||
info._display_color = color_picker.get(info.name);
|
||||
info.variant = {};
|
||||
return info;
|
||||
@@ -37,10 +31,16 @@ export const API = {
|
||||
load_replies: async (pid, token, color_picker, cache_version) => {
|
||||
pid = parseInt(pid);
|
||||
let response = await fetch(
|
||||
API_BASE + '/api.php?action=getcomment&pid=' + pid + token_param(token),
|
||||
API_BASE + '/getcomment?pid=' + pid ,
|
||||
{
|
||||
headers: {
|
||||
'User-Token': token,
|
||||
}
|
||||
}
|
||||
);
|
||||
let json = await handle_response(response);
|
||||
// Why delete then put ??
|
||||
//console.log('Put cache', json, pid, cache_version);
|
||||
cache().put(pid, cache_version, json);
|
||||
json.data = parse_replies(json.data, color_picker);
|
||||
return json;
|
||||
@@ -49,10 +49,13 @@ export const API = {
|
||||
load_replies_with_cache: async (pid, token, color_picker, cache_version) => {
|
||||
pid = parseInt(pid);
|
||||
let json = await cache().get(pid, cache_version);
|
||||
//console.log('Get Cache', json, pid, cache_version);
|
||||
if (json) {
|
||||
//console.log('cache.data', json.data);
|
||||
json.data = parse_replies(json.data, color_picker);
|
||||
return { data: json, cached: true };
|
||||
} else {
|
||||
//console.log('Cache fail, new fetch');
|
||||
json = await API.load_replies(pid, token, color_picker, cache_version);
|
||||
return { data: json, cached: !json };
|
||||
}
|
||||
@@ -60,15 +63,15 @@ export const API = {
|
||||
|
||||
set_attention: async (pid, attention, token) => {
|
||||
let data = new URLSearchParams();
|
||||
data.append('user_token', token);
|
||||
data.append('pid', pid);
|
||||
data.append('switch', attention ? '1' : '0');
|
||||
let response = await fetch(
|
||||
API_BASE + '/api.php?action=attention' + token_param(token),
|
||||
API_BASE + '/attention',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'User-Token': token,
|
||||
},
|
||||
body: data,
|
||||
},
|
||||
@@ -80,15 +83,15 @@ export const API = {
|
||||
|
||||
report: async (pid, reason, token) => {
|
||||
let data = new URLSearchParams();
|
||||
data.append('user_token', token);
|
||||
data.append('pid', pid);
|
||||
data.append('reason', reason);
|
||||
let response = await fetch(
|
||||
API_BASE + '/api.php?action=report' + token_param(token),
|
||||
API_BASE + '/report',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'User-Token': token,
|
||||
},
|
||||
body: data,
|
||||
},
|
||||
@@ -96,9 +99,69 @@ export const API = {
|
||||
return handle_response(response, true);
|
||||
},
|
||||
|
||||
get_list: async (page, token) => {
|
||||
del: async (type, id, note, token) => {
|
||||
let data = new URLSearchParams();
|
||||
data.append('type', type);
|
||||
data.append('id', id);
|
||||
data.append('note', note);
|
||||
let response = await fetch(
|
||||
API_BASE + '/api.php?action=getlist' + '&p=' + page + token_param(token),
|
||||
API_BASE + '/delete',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'User-Token': token,
|
||||
},
|
||||
body: data,
|
||||
},
|
||||
);
|
||||
return handle_response(response, true);
|
||||
},
|
||||
|
||||
update_cw: async (cw, id, token) => {
|
||||
let data = new URLSearchParams();
|
||||
data.append('cw', cw);
|
||||
data.append('pid', id);
|
||||
let response = await fetch(
|
||||
API_BASE + '/editcw',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'User-Token': token,
|
||||
},
|
||||
body: data,
|
||||
},
|
||||
);
|
||||
return handle_response(response, true);
|
||||
},
|
||||
|
||||
update_score: async (score, id, token) => {
|
||||
let data = new URLSearchParams();
|
||||
data.append('score', score);
|
||||
data.append('pid', id);
|
||||
let response = await fetch(
|
||||
API_BASE + '/update_score',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'User-Token': token,
|
||||
},
|
||||
body: data,
|
||||
},
|
||||
);
|
||||
return handle_response(response, true);
|
||||
},
|
||||
|
||||
get_list: async (page, token, submode) => {
|
||||
let response = await fetch(
|
||||
`${API_BASE}/getlist?p=${page}${
|
||||
window.config.no_c_post ? '&no_cw' : ''
|
||||
}&order_mode=${submode}`,
|
||||
{
|
||||
headers: {'User-Token': token},
|
||||
},
|
||||
);
|
||||
return handle_response(response);
|
||||
},
|
||||
@@ -106,28 +169,35 @@ export const API = {
|
||||
get_search: async (page, keyword, token) => {
|
||||
let response = await fetch(
|
||||
API_BASE +
|
||||
'/api.php?action=search' +
|
||||
'&pagesize=' +
|
||||
'/search?pagesize=' +
|
||||
SEARCH_PAGESIZE +
|
||||
'&page=' +
|
||||
page +
|
||||
'&keywords=' +
|
||||
encodeURIComponent(keyword) +
|
||||
token_param(token),
|
||||
encodeURIComponent(keyword),
|
||||
{
|
||||
headers: {'User-Token': token},
|
||||
}
|
||||
);
|
||||
return handle_response(response);
|
||||
},
|
||||
|
||||
get_single: async (pid, token) => {
|
||||
let response = await fetch(
|
||||
API_BASE + '/api.php?action=getone' + '&pid=' + pid + token_param(token),
|
||||
API_BASE + '/getone?pid=' + pid,
|
||||
{
|
||||
headers: {'User-Token': token},
|
||||
}
|
||||
);
|
||||
return handle_response(response);
|
||||
},
|
||||
|
||||
get_attention: async (token) => {
|
||||
let response = await fetch(
|
||||
API_BASE + '/api.php?action=getattention' + token_param(token),
|
||||
API_BASE + '/getattention',
|
||||
{
|
||||
headers: {'User-Token': token},
|
||||
}
|
||||
);
|
||||
return handle_response(response);
|
||||
},
|
||||
|
||||
@@ -108,3 +108,6 @@
|
||||
.icon-eye-blocked:before {
|
||||
content: "\e9d1";
|
||||
}
|
||||
.icon-trash:before {
|
||||
content: "\1f5d1";
|
||||
}
|
||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import './index.css';
|
||||
import './fonts_7/icomoon.css'
|
||||
import App from './App';
|
||||
//import {elevate} from './infrastructure/elevator';
|
||||
import registerServiceWorker from './registerServiceWorker';
|
||||
|
||||
78
src/infrastructure/functions.js
Normal file
@@ -0,0 +1,78 @@
|
||||
export function get_json(res) {
|
||||
if(!res.ok) {
|
||||
console.log('error:', res);
|
||||
throw Error(`${res.status} ${res.statusText}`);
|
||||
}
|
||||
return (
|
||||
res
|
||||
.text()
|
||||
.then((t)=>{
|
||||
try {
|
||||
return JSON.parse(t);
|
||||
} catch(e) {
|
||||
console.error('json parse error');
|
||||
console.trace(e);
|
||||
console.log(t);
|
||||
throw new SyntaxError('JSON Parse Error '+t.substr(0,50));
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export function listen_darkmode(override) { // override: true/false/undefined
|
||||
function update_color_scheme() {
|
||||
if(override===undefined ? window.matchMedia('(prefers-color-scheme: dark)').matches : override)
|
||||
document.body.classList.add('root-dark-mode');
|
||||
else
|
||||
document.body.classList.remove('root-dark-mode');
|
||||
}
|
||||
|
||||
update_color_scheme();
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addListener(()=>{
|
||||
update_color_scheme();
|
||||
});
|
||||
}
|
||||
|
||||
const NAMES = [
|
||||
'Alice',
|
||||
'Bob',
|
||||
'Carol',
|
||||
'Dave',
|
||||
'Eve',
|
||||
'Francis',
|
||||
'Grace',
|
||||
'Hans',
|
||||
'Isabella',
|
||||
'Jason',
|
||||
'Kate',
|
||||
'Louis',
|
||||
'Margaret',
|
||||
'Nathan',
|
||||
'Olivia',
|
||||
'Paul',
|
||||
'Queen',
|
||||
'Richard',
|
||||
'Susan',
|
||||
'Thomas',
|
||||
'Uma',
|
||||
'Vivian',
|
||||
'Winnie',
|
||||
'Xander',
|
||||
'Yasmine',
|
||||
'Zach'
|
||||
]
|
||||
|
||||
export function gen_name(name_id) {
|
||||
if (name_id == 0)
|
||||
return '洞主';
|
||||
|
||||
let r = name_id - 1;
|
||||
let name = '';
|
||||
do {
|
||||
name += ' ' + NAMES[r % 26];
|
||||
r = parseInt(r / 26);
|
||||
} while (r);
|
||||
|
||||
return name.substr(1);
|
||||
}
|
||||
|
||||
37
src/infrastructure/global.css
Normal file
@@ -0,0 +1,37 @@
|
||||
:root {
|
||||
--foreground-dark: hsl(0,0%,93%);
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow-x: hidden;
|
||||
text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
body, textarea, pre {
|
||||
font-family: 'Segoe UI', '微软雅黑', 'Microsoft YaHei', sans-serif;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
word-wrap: break-word;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
p, pre {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
pre {
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: Consolas, Courier, monospace;
|
||||
}
|
||||
324
src/infrastructure/widgets.css
Normal file
@@ -0,0 +1,324 @@
|
||||
.centered-line {
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.centered-line::before,
|
||||
.centered-line::after {
|
||||
background-color: #000;
|
||||
content: "";
|
||||
display: inline-block;
|
||||
height: 1px;
|
||||
position: relative;
|
||||
vertical-align: middle;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.root-dark-mode .centered-line {
|
||||
color: var(--foreground-dark);
|
||||
}
|
||||
.root-dark-mode .centered-line::before, .root-dark-mode .centered-line::after {
|
||||
background-color: var(--foreground-dark);
|
||||
}
|
||||
|
||||
.centered-line::before {
|
||||
right: 1em;
|
||||
margin-left: -50%;
|
||||
}
|
||||
|
||||
.centered-line::after {
|
||||
left: 1em;
|
||||
margin-right: -50%;
|
||||
}
|
||||
|
||||
.title-line {
|
||||
color: #fff;
|
||||
margin-top: 1em;
|
||||
}
|
||||
.title-line::before,
|
||||
.title-line::after {
|
||||
background-color: #fff;
|
||||
box-shadow: 0 1px 1px #000;
|
||||
}
|
||||
|
||||
.root-dark-mode .title-line {
|
||||
color: var(--foreground-dark);
|
||||
}
|
||||
.root-dark-mode .title-line::before, .root-dark-mode .title-line::after {
|
||||
background-color: var(--foreground-dark);
|
||||
}
|
||||
|
||||
.app-switcher {
|
||||
display: flex;
|
||||
height: 2em;
|
||||
text-align: center;
|
||||
margin: 0 .1em;
|
||||
user-select: none;
|
||||
}
|
||||
.app-switcher-desc {
|
||||
margin: 0 .5em;
|
||||
flex: 1 1 0;
|
||||
opacity: .5;
|
||||
height: 2em;
|
||||
line-height: 2rem;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
.root-dark-mode .app-switcher-desc {
|
||||
color: var(--foreground-dark);
|
||||
}
|
||||
|
||||
@media screen and (max-width: 570px) {
|
||||
.app-switcher-desc {
|
||||
flex: 1 1 0;
|
||||
display: none;
|
||||
}
|
||||
.app-switcher-item {
|
||||
flex: 1 1 0 !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
.app-switcher-dropdown-title {
|
||||
padding-left: 0 !important;
|
||||
padding-right: 0 !important;
|
||||
text-align: center !important;
|
||||
}
|
||||
.app-switcher-dropdown-item {
|
||||
margin-left: -2em !important;
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.app-switcher a:hover { /* reset underline from /hole style */
|
||||
border-bottom: unset;
|
||||
margin-bottom: unset;
|
||||
}
|
||||
|
||||
.app-switcher-desc a {
|
||||
color: unset;
|
||||
}
|
||||
|
||||
.app-switcher-left {
|
||||
text-align: right;
|
||||
}
|
||||
.app-switcher-right {
|
||||
text-align: left;
|
||||
}
|
||||
.app-switcher-item {
|
||||
flex: 0 0 auto;
|
||||
border-radius: 3px;
|
||||
height: 1.6em;
|
||||
line-height: 1.6em;
|
||||
margin: .2em .1em;
|
||||
padding: 0 .45em;
|
||||
}
|
||||
a.app-switcher-item, .app-switcher-item a {
|
||||
transition: unset; /* override ant design */
|
||||
color: black;
|
||||
}
|
||||
.app-switcher-item img {
|
||||
width: 1.2rem;
|
||||
height: 1.2rem;
|
||||
position: relative;
|
||||
top: .2rem;
|
||||
vertical-align: unset; /* override ant design */
|
||||
}
|
||||
.app-switcher-item span:not(:empty) {
|
||||
margin-left: .2rem;
|
||||
}
|
||||
.app-switcher-logo-hover {
|
||||
margin-left: -1.2rem;
|
||||
}
|
||||
|
||||
.app-switcher-item:hover {
|
||||
background-color: black;
|
||||
color: white !important;
|
||||
}
|
||||
.app-switcher-item:hover a {
|
||||
color: white !important;
|
||||
}
|
||||
.app-switcher-item-current {
|
||||
background-color: rgba(0,0,0,.4);
|
||||
text-shadow: 0 0 5px rgba(0,0,0,.5);
|
||||
color: white !important;
|
||||
}
|
||||
.app-switcher-item-current a {
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.root-dark-mode .app-switcher-item, .root-dark-mode .app-switcher-dropdown-title a {
|
||||
color: var(--foreground-dark);
|
||||
}
|
||||
.root-dark-mode .app-switcher-item:hover, .root-dark-mode .app-switcher-item-current, .root-dark-mode .app-switcher-dropdown-title:hover a {
|
||||
background-color: #555;
|
||||
color: var(--foreground-dark);
|
||||
}
|
||||
|
||||
.app-switcher-item:hover .app-switcher-logo-normal, .app-switcher-item-current .app-switcher-logo-normal {
|
||||
opacity: 0;
|
||||
}
|
||||
.app-switcher-item:not(.app-switcher-item-current):not(:hover) .app-switcher-logo-hover {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.root-dark-mode .app-switcher-logo-normal {
|
||||
opacity: 0 !important;
|
||||
}
|
||||
.root-dark-mode .app-switcher-logo-hover {
|
||||
opacity: 1 !important;
|
||||
}
|
||||
|
||||
.app-switcher-dropdown {
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.app-switcher-dropdown:not(:hover) {
|
||||
max-height: 1.6rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.app-switcher-dropdown-item {
|
||||
background-color: hsla(0,0%,35%,.9);
|
||||
padding: .125em .25em;
|
||||
margin-left: -.75em;
|
||||
margin-right: -.75em;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
cursor: pointer;
|
||||
}
|
||||
.app-switcher-dropdown-item:hover {
|
||||
background-color: rgba(0,0,0,.9);
|
||||
}
|
||||
.app-switcher-dropdown-item:nth-child(2) {
|
||||
border-top-left-radius: 3px;
|
||||
border-top-right-radius: 3px;
|
||||
}
|
||||
.app-switcher-dropdown-item:last-child {
|
||||
border-bottom-left-radius: 3px;
|
||||
border-bottom-right-radius: 3px;
|
||||
}
|
||||
|
||||
.app-switcher-dropdown-title {
|
||||
padding-bottom: .2em;
|
||||
padding-left: .5em;
|
||||
padding-right: .25em;
|
||||
}
|
||||
.app-switcher-dropdown-title a {
|
||||
cursor: unset;
|
||||
}
|
||||
|
||||
.thuhole-login-popup {
|
||||
font-size: 1rem;
|
||||
background-color: #f7f7f7;
|
||||
color: black;
|
||||
position: fixed;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
width: 320px;
|
||||
z-index: 114515;
|
||||
transform: translateX(-50%) translateY(-50%);
|
||||
border-radius: 5px;
|
||||
}
|
||||
.thuhole-login-popup a {
|
||||
color: #00c;
|
||||
}
|
||||
.thuhole-login-popup p {
|
||||
margin: 1.25em 0;
|
||||
text-align: center;
|
||||
}
|
||||
.thuhole-login-popup-info p {
|
||||
margin: .25em 1em;
|
||||
text-align: left;
|
||||
}
|
||||
.thuhole-login-popup-info ul {
|
||||
margin: .75em 1em;
|
||||
text-align: left;
|
||||
font-size: 75%;
|
||||
}
|
||||
/* override ant design */
|
||||
.thuhole-login-popup input, .thuhole-login-popup button {
|
||||
font-size: .85em;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.thuhole-login-popup input:not([type="checkbox"]) {
|
||||
width: 8rem;
|
||||
border-radius: 5px;
|
||||
border: 1px solid black;
|
||||
outline: none;
|
||||
margin: 0;
|
||||
padding: 0 .5em;
|
||||
line-height: 2em;
|
||||
}
|
||||
.thuhole-login-popup button {
|
||||
min-width: 6rem;
|
||||
color: black;
|
||||
background-color: rgba(235,235,235,.5);
|
||||
border-radius: 5px;
|
||||
text-align: center;
|
||||
border: 1px solid black;
|
||||
line-height: 2em;
|
||||
margin: 0 .5rem;
|
||||
}
|
||||
.thuhole-login-popup button:hover {
|
||||
background-color: rgba(255,255,255,.7);
|
||||
}
|
||||
.thuhole-login-popup button:disabled {
|
||||
background-color: rgba(128,128,128,.5);
|
||||
}
|
||||
.thuhole-login-type {
|
||||
display: inline-block;
|
||||
width: 6rem;
|
||||
margin: 0 .5rem;
|
||||
}
|
||||
.thuhole-login-popup-shadow {
|
||||
opacity: .5;
|
||||
background-color: black;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
z-index: 114514;
|
||||
}
|
||||
|
||||
.thuhole-login-popup label.perm-item {
|
||||
font-size: .8em;
|
||||
vertical-align: .1rem;
|
||||
margin-left: .5rem;
|
||||
}
|
||||
|
||||
.aux-margin {
|
||||
width: calc(100% - 2 * 50px);
|
||||
margin: 0 50px;
|
||||
}
|
||||
@media screen and (max-width: 1300px) {
|
||||
.aux-margin {
|
||||
width: calc(100% - 2 * 10px);
|
||||
margin: 0 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 1.5em;
|
||||
height: 4rem;
|
||||
padding-top: 1rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.time-str {
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
a.button {
|
||||
-webkit-appearance: button;
|
||||
-moz-appearance: button;
|
||||
appearance: button;
|
||||
|
||||
text-decoration: none;
|
||||
color: initial;
|
||||
|
||||
min-width: 6em;
|
||||
font-size: 0.85em;
|
||||
|
||||
padding: 5px;
|
||||
}
|
||||
171
src/infrastructure/widgets.js
Normal file
@@ -0,0 +1,171 @@
|
||||
import React, {Component, PureComponent} from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
import TimeAgo from 'react-timeago';
|
||||
import chineseStrings from 'react-timeago/lib/language-strings/zh-CN';
|
||||
import buildFormatter from 'react-timeago/lib/formatters/buildFormatter';
|
||||
|
||||
import './global.css';
|
||||
import './widgets.css';
|
||||
|
||||
import {get_json, API_VERSION_PARAM} from './functions';
|
||||
|
||||
function pad2(x) {
|
||||
return x<10 ? '0'+x : ''+x;
|
||||
}
|
||||
export function format_time(time) {
|
||||
return `${time.getMonth()+1}-${pad2(time.getDate())} ${time.getHours()}:${pad2(time.getMinutes())}:${pad2(time.getSeconds())}`;
|
||||
}
|
||||
const chinese_format=buildFormatter(chineseStrings);
|
||||
export function Time(props) {
|
||||
const time=new Date(props.stamp*1000);
|
||||
return (
|
||||
<span className={"time-str"}>
|
||||
<TimeAgo date={time} formatter={chinese_format} title={time.toLocaleString('zh-CN', {
|
||||
timeZone: 'Asia/Shanghai',
|
||||
hour12: false,
|
||||
})} />
|
||||
|
||||
{!props.short ? format_time(time) : null}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export function TitleLine(props) {
|
||||
return (
|
||||
<p className="centered-line title-line aux-margin">
|
||||
<span className="black-outline">{props.text}</span>
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
export function GlobalTitle(props) {
|
||||
return (
|
||||
<div className="aux-margin">
|
||||
<div className="title">
|
||||
<p className="centered-line">{props.text}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
class LoginPopupSelf extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state={
|
||||
loading_status: 'idle',
|
||||
}
|
||||
|
||||
this.input_token_ref=React.createRef();
|
||||
};
|
||||
|
||||
setThuhole(e, tar, ref) {
|
||||
console.log(tar);
|
||||
e.preventDefault();
|
||||
tar.href = '/_login?p=thuhole&token=' + ref.current.value;
|
||||
console.log(tar);
|
||||
alert('T大树洞已经没有啦😭');
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="thuhole-login-popup-shadow" />
|
||||
<div className="thuhole-login-popup">
|
||||
<p>
|
||||
<b>通过第三方验证登陆新T树洞</b>
|
||||
</p>
|
||||
<p>
|
||||
<a href="/_login?p=cs" target="_blank">
|
||||
<span className="icon icon-login" />
|
||||
闭社
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<input ref={this.input_token_ref} placeholder="T大树洞Token" />
|
||||
<br/>
|
||||
<a href="/_login?p=thuhole" target="_blank"
|
||||
onClick={(e) =>{this.setThuhole(e, e.target, this.input_token_ref)}}
|
||||
>
|
||||
<span className="icon icon-login" />
|
||||
T大树洞
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<small>前往Telegram群查询15分钟临时token</small>
|
||||
<br/>
|
||||
<a href="//t.me/THUChatBot" target="_blank"
|
||||
>
|
||||
<span className="icon icon-login" />
|
||||
清华大水群
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<button type="button" disabled
|
||||
>
|
||||
<span className="icon icon-login" />
|
||||
未名bbs
|
||||
</button>
|
||||
</p>
|
||||
<p>
|
||||
<button type="button" disabled
|
||||
>
|
||||
<span className="icon icon-login" />
|
||||
清华统一身份认证
|
||||
</button>
|
||||
</p>
|
||||
<hr />
|
||||
<p>
|
||||
<button onClick={this.props.on_close}>
|
||||
取消
|
||||
</button>
|
||||
</p>
|
||||
<hr/ >
|
||||
<div className="thuhole-login-popup-info">
|
||||
<p>提醒:
|
||||
</p>
|
||||
<ul>
|
||||
<li> 无论采用哪种方式注册,你后台记录的用户名都是本质实名的(除临时token),因为闭社/T大树洞的管理员可以根据你的闭社id/树洞评论区代号查到邮箱。但是这不影响新T树洞的安全性。新T树洞的匿名性来自隔离用户名与发布的内容,而非试图隔离用户名与真实身份。</li>
|
||||
<li> 由于T大树洞仍未提供授权接口,使用T大树洞方式登陆需要用你的token在特定洞发布一段随机内容以确定身份。这是否违反用户条例由T大树洞管理员决定,需自行承担相关风险。完成登陆后建议立即重置T大树洞token。 </li>
|
||||
<li> 目前一个人可能有两个帐号。</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class LoginPopup extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state={
|
||||
popup_show: false,
|
||||
};
|
||||
this.on_popup_bound=this.on_popup.bind(this);
|
||||
this.on_close_bound=this.on_close.bind(this);
|
||||
}
|
||||
|
||||
on_popup() {
|
||||
this.setState({
|
||||
popup_show: true,
|
||||
});
|
||||
}
|
||||
on_close() {
|
||||
this.setState({
|
||||
popup_show: false,
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<>
|
||||
{this.props.children(this.on_popup_bound)}
|
||||
{this.state.popup_show &&
|
||||
<LoginPopupSelf token_callback={this.props.token_callback} on_close={this.on_close_bound} />
|
||||
}
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,11 @@
|
||||
export const PID_RE = /(^|[^\d\u20e3\ufe0e\ufe0f])(#\d{1,7})(?![\d\u20e3\ufe0e\ufe0f])/g;
|
||||
// TODO: fix this re
|
||||
// export const URL_PID_RE=/((?:https?:\/\/)?thuhole\.com\/?#(?:#|%23)([2-9]\d{4,5}|1\d{4,6}))(?!\d|\u20e3|\ufe0e|\ufe0f)/g;
|
||||
export const URL_PID_RE = /((?:https?:\/\/)?thuhole\.com\/?#(?:#|%23)(\d{1,7}))(?!\d|\u20e3|\ufe0e|\ufe0f)/g;
|
||||
export const URL_PID_RE = /((?:https?:\/\/)?hole\.thu\.monster\/?#(?:#|%23)(\d{1,7}))(?!\d|\u20e3|\ufe0e|\ufe0f)/g;
|
||||
export const NICKNAME_RE = /(^|[^A-Za-z])((?:(?:Angry|Baby|Crazy|Diligent|Excited|Fat|Greedy|Hungry|Interesting|Jolly|Kind|Little|Magic|Naïve|Old|PKU|Quiet|Rich|Superman|Tough|Undefined|Valuable|Wifeless|Xiangbuchulai|Young|Zombie)\s)?(?:Alice|Bob|Carol|Dave|Eve|Francis|Grace|Hans|Isabella|Jason|Kate|Louis|Margaret|Nathan|Olivia|Paul|Queen|Richard|Susan|Thomas|Uma|Vivian|Winnie|Xander|Yasmine|Zach)|You Win(?: \d+)?|洞主)(?![A-Za-z])/gi;
|
||||
export const URL_RE = /(^|[^.@a-zA-Z0-9_])((?:https?:\/\/)?(?:(?:[\w-]+\.)+[a-zA-Z]{2,3}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?::\d{1,5})?(?:\/[\w~!@#$%^&*()\-_=+[\]{};:,./?|]*)?)(?![a-zA-Z0-9])/gi;
|
||||
export const URL_RE = /(^|[^.@a-zA-Z0-9_])((?:https?:\/\/)?(?:(?:[\w-]+\.)+[a-zA-Z]{2,7}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,5})(?::\d{1,5})?(?:\/[\w~!@#$%^&*()\-_=+[\]{};:,./?|]*)?)(?![a-zA-Z0-9])/gi;
|
||||
|
||||
export const TAG_RE = /(^|\s)(#[^#\s]{1,32})($|\s|#)/g;
|
||||
|
||||
export function split_text(txt, rules) {
|
||||
// rules: [['name',/regex/],...]
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#!/bin/bash
|
||||
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
||||
echo "skip deploy for pull request..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$TRAVIS_BRANCH" = "master" ]; then
|
||||
export DEPLOY_BRANCH="gh-pages-master"
|
||||
else
|
||||
export DEPLOY_BRANCH="gh-pages"
|
||||
fi
|
||||
|
||||
CDN_URL="https://cdn.jsdelivr.net/gh/thuhole/webhole@$DEPLOY_BRANCH"
|
||||
VERSION_NUMBER="v$(grep -oP '"version": "\K[^"]+' package.json | head -n1).$TRAVIS_BUILD_NUMBER"
|
||||
|
||||
echo "DEPLOY_BRANCH=$DEPLOY_BRANCH, VERSION_NUMBER=$VERSION_NUMBER, CDN_URL=$CDN_URL"
|
||||
git config --global user.name "thuhole"
|
||||
git config --global user.email "thuhole@users.noreply.github.com"
|
||||
git remote rm origin
|
||||
git remote add origin https://thuhole:"${GH_TOKEN}"@github.com/thuhole/webhole.git
|
||||
CI=false PUBLIC_URL=$CDN_URL REACT_APP_BUILD_INFO=$VERSION_NUMBER npm run build
|
||||
#额,这里用了个骚操作来修复Service Worker在Precache CDN内容的时候index.html返回content-type text/plain的问题
|
||||
sed -i 's|https://cdn.jsdelivr.net/gh/thuhole/webhole@'"$DEPLOY_BRANCH"'/index.html|./index.html|g' build/*-*
|
||||
sed -i 's|https://cdn.jsdelivr.net/gh/thuhole/webhole@'"$DEPLOY_BRANCH"'/service-worker.js|./service-worker.js|g' build/*-*
|
||||
sed -i 's|"https://cdn.jsdelivr.net/gh/thuhole/webhole@'"$DEPLOY_BRANCH"'","/service-worker.js"|".","/service-worker.js"|' build/static/js/*.js
|
||||
sed -i 's|storage.googleapis.com/workbox-cdn/releases/4.3.1|cdn.jsdelivr.net/npm/workbox-cdn@4.3.1/workbox|g' build/service-worker.js
|
||||
npm run deploy
|
||||