Initial commit.
This commit is contained in:
commit
f0c91b4e55
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
node_modules/
|
||||
package-lock.json
|
||||
663
LICENSE
Normal file
663
LICENSE
Normal file
|
|
@ -0,0 +1,663 @@
|
|||
All Original Canopy Code is Covered under the Gnu Affero General Public License v3 - 2024 Rainbownapkin
|
||||
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 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 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
|
||||
|
||||
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 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 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/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
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 AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
27
README.md
Normal file
27
README.md
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
Canopy - 0.1-INDEV
|
||||
======
|
||||
|
||||
Canopy - /ˈkæ.nə.pi/:
|
||||
- The upper layer of foliage and branches of a forest, containing the majority of animal life.
|
||||
|
||||
Canopy is a community chat & synced video embedding web application, intended to replace fore.st as the server software for ourfore.st.
|
||||
This new codebase intends to solve the following issues with the current CyTube based software:
|
||||
|
||||
- Unmaintained upstream codebase.
|
||||
- Different goals.
|
||||
- Different coding styles.
|
||||
- Obsolete Technology and Dependencies.
|
||||
- General Clunk
|
||||
- Less Unique Community Identity
|
||||
|
||||
Canopy intends to be a simple node/express.js app. It leverages yt-dlp and the internet archive cli utility for metadata gathering. Persistant storage is handled by mongodb, as it's document based nature inherintly works well for cleanly storing large config documents for user/channel settings, and the low use of inter-collection references within the canopy software. All hardcore security functions like session handling and password hashing are handled by industry-standard open source libraries such as express-sessions and bcrypt, however it IS hobbiest software, and it should be treated as such.
|
||||
|
||||
The Canopy codebase does not, and never will contain:
|
||||
- Advertisements (targetted or otherwise)
|
||||
- Proprietary Code
|
||||
- 'Analytics/Telemtry' spyware
|
||||
|
||||
Thirdparty media providers may or may not contain all of the above atrocities :P, always use an ad-blocker!
|
||||
|
||||
## License
|
||||
Canopy is written by the community, and provided under the GNU Affero General Public License v3 in order to prevent Canopy from being used in proprietary software.
|
||||
12
config.json
Normal file
12
config.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"instanceName": "Canopy",
|
||||
"port": 8080,
|
||||
"sessionSecret": "FatBitchesAndSmoke",
|
||||
"db":{
|
||||
"address": "127.0.0.1",
|
||||
"port": "27017",
|
||||
"database": "canopy",
|
||||
"user": "canopy",
|
||||
"pass": "8fE=8VdzTHfi2IsOOd4Lc"
|
||||
}
|
||||
}
|
||||
9
nodemon.json
Normal file
9
nodemon.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"watch": [
|
||||
"config.json",
|
||||
"nodemon.json",
|
||||
"package.json",
|
||||
"package-lock.json",
|
||||
"src/*"
|
||||
]
|
||||
}
|
||||
20
package.json
Normal file
20
package.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"name": "canopy-of",
|
||||
"version": "0.1",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"bcrypt": "^5.1.1",
|
||||
"bootstrap-icons": "^1.11.3",
|
||||
"connect-mongo": "^5.1.0",
|
||||
"ejs": "^3.1.10",
|
||||
"express": "^4.18.2",
|
||||
"express-session": "^1.18.0",
|
||||
"express-validator": "^7.2.0",
|
||||
"mongoose": "^8.4.3",
|
||||
"socket.io": "^4.8.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node ./src/server.js",
|
||||
"start:dev": "nodemon ./src/server.js"
|
||||
}
|
||||
}
|
||||
158
release_checklist.md
Normal file
158
release_checklist.md
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
Canopy - 0.1-INDEV Release Checklist
|
||||
======
|
||||
|
||||
This checklist serves as both a list of goals for this version, as well as a future patchnotes files.
|
||||
Canopy - 0.1-INDEV inteds to be near-feature-complete with the chat and account management parts of fore.st
|
||||
|
||||
- Accounts/Authentication ✓
|
||||
- single document collection in DB for instance statistics ✓
|
||||
- session management ✓
|
||||
- basic account system using bcrypt/mongoose/ferretdb (mongodb for now, mongo backend for express-session is currently incompatible) ✓
|
||||
- account creation/login frontend ✓
|
||||
- logout/kill session ✓
|
||||
- Setup basic config file ✓
|
||||
- XSS/Security check ✓
|
||||
|
||||
- Profile Info/Page ✓
|
||||
- profile display page layout ✓
|
||||
- display profile creation date ✓
|
||||
- display profile short-bio ✓
|
||||
- display profile bio ✓
|
||||
- display profile image (url based) ✓
|
||||
- display badges ✓
|
||||
- edit profile items ✓
|
||||
- password update (authenticated by old password) ✓
|
||||
- account deletion ✓
|
||||
- XSS/Security check
|
||||
- standardize account functions ✓
|
||||
- fix account id ✓
|
||||
- check password ✓
|
||||
- login ✓
|
||||
- logout ✓
|
||||
- session management features
|
||||
- add ip, auth date, and redundant seshid to authed sessions ✓
|
||||
- function to get authed sessions for specific user ✓
|
||||
- full logout (kill all sessions for specific user) ✓
|
||||
- password reset ✓
|
||||
- account deletion ✓
|
||||
- register ✓
|
||||
- XSS check ✓
|
||||
- navbar ✓
|
||||
- profile ✓
|
||||
|
||||
- Multi-Channel ✓
|
||||
- Channel Schema ✓
|
||||
- Channel Creation ✓
|
||||
- Channel List ✓
|
||||
- basic channel page layout (no scripted functionality) ✓
|
||||
- check layout scales proper ✓
|
||||
- try in chromium ✓
|
||||
- try on mobile (or at least browser-sim, getting this to work proper might req a little JS, so we might save it for a later touch up on UX :P) ✓
|
||||
- Channel Settings ✓
|
||||
- Channel Deletion ✓
|
||||
- Site-Wide Admin Channel Management Page ✓
|
||||
- XSS/Security check X
|
||||
- FAIL: XSS: index (channel description - to be fixed by express-validator)
|
||||
- FAIL: XSS: adminPanel (channel description - to be fixed by express-validator)
|
||||
|
||||
- Implement Express-Validator ✓
|
||||
- /api/ ✓
|
||||
- Account Logic ✓
|
||||
- Login ✓
|
||||
- Register ✓
|
||||
- Delete ✓
|
||||
- Update ✓
|
||||
- Channel Logic ✓
|
||||
- Register ✓
|
||||
- Settings ✓
|
||||
- Delete ✓
|
||||
- XSS Check
|
||||
- XSS: index ✓
|
||||
- XSS: adminPanel ✓
|
||||
|
||||
- Chat
|
||||
- duplex comms (socket.io) ✓
|
||||
- connected user-list ✓
|
||||
- simulatnious socket.io connections within same room for same user ✓
|
||||
- chat ✓
|
||||
- high-level ✓
|
||||
- random-multi-color usernames a-la TTN/OF/TZ (super important) ✓
|
||||
- XSS/Security check ✓
|
||||
- express-validator - Chat ✓
|
||||
|
||||
- Quiet Public Code Release
|
||||
- Prettify movie-night.css to make it at least kinda resemble TMN ✓
|
||||
- Responsive Channel Page JS
|
||||
- Click to Drag Video/Chat Split ✓
|
||||
- Lock Chat Split to Aspect Ratio (fake aspect ratio for now until media playback is implemented) ✓
|
||||
- Click to Drag Chat/Userlist Split ✓
|
||||
- Prevent chat from breaking during resize ✓
|
||||
- Prevent userlist from breaking during resize ✓
|
||||
- Auto hide/show media header bar ✓
|
||||
- Collapse Userlist ✓
|
||||
- Collapse Video ✓
|
||||
- Collapse Chat ✓
|
||||
- Cinema Mode ✓
|
||||
- AGPL v3 Notice check on all original files ✓
|
||||
- Move realease_checklist.md milestones to gitlab issue tracker
|
||||
|
||||
- Channel Page Multi-Pannel
|
||||
- Successor to fpanel from fore.st, that isn't so gross
|
||||
- Create blank panel element that pops open/closed over chat with matching class which can take a current panel page object and display it
|
||||
- Allow panel-pinning. Pinned panel opens next to chat, instead of over. Standard panel can be opened over pinned-panel/chat. Only one pinned-panel at a time.
|
||||
- Allow panel-popouts, allowing users to pop-panels out into a seperate window.
|
||||
- Allow dynamic resizing of both active and pinned panels via mouse click/drag.
|
||||
|
||||
- Rank/Authorization
|
||||
- account ranks (user, gold, mod, bot, admin)
|
||||
- session ranks (derived from account: anonymous, user, gold, mod, bot, admin)
|
||||
- Central DB Collection for documents containing global permissions and min rank for each
|
||||
- Global Permission Page
|
||||
- No direct rank checks, all rank checks must go through a Permission
|
||||
- Global Ban function
|
||||
- flair (some rank-locked) (super duper important)
|
||||
- Channel-Based Rank/Authorization
|
||||
- Channel Ban function (automatically list all global banned)
|
||||
- Channel Kick function
|
||||
- XSS/Security check
|
||||
|
||||
- Commands
|
||||
- Client-side command parser using '/'
|
||||
- /high # to set high level
|
||||
- Serverside command parser using '!'
|
||||
- !whisper for subscript
|
||||
- !announce for announcements
|
||||
- !clear <username> to clear all or a specific users chat
|
||||
- XSS/Security check
|
||||
|
||||
- Tokebot
|
||||
- Basic tokebot functionality with global !tokes
|
||||
- !toke commands stored in DB documents
|
||||
- !toke command management page
|
||||
- store use statistics for each !toke command within respective user account document
|
||||
- display toke statistics on user profile
|
||||
- store each toke as a document in toke history db collection
|
||||
- tokebot "profile" that displays site/channel toke statistics
|
||||
- XSS/Security check
|
||||
|
||||
- Link/Media Check/Embed (images/gif/webm in chat)
|
||||
- Seperate links from message client-side
|
||||
- Serverside media check
|
||||
- Re-assemble link/embed client-side
|
||||
- Site-wide Emotes
|
||||
- XSS/Security check
|
||||
|
||||
- Account Security Extra's
|
||||
- Email password reset
|
||||
- captcha requirement for registration
|
||||
|
||||
Near-Future Milestones Post v0.1:
|
||||
|
||||
- Announcement & Loud Public Code Release
|
||||
- Chat-only public test w/ bugfix sessions
|
||||
- v0.2:
|
||||
- Media Metadata Gathering (yt-dlp)
|
||||
- Basic video queue
|
||||
- Synced video embed based on current video from queue.
|
||||
- Channel Queue History
|
||||
- Video-Synced public test w/ bugfix sessions
|
||||
22
src/app/channel/activeChannel.js
Normal file
22
src/app/channel/activeChannel.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
module.exports = class{
|
||||
constructor(name){
|
||||
this.name = name;
|
||||
this.userList = new Map();
|
||||
}
|
||||
}
|
||||
112
src/app/channel/channelManager.js
Normal file
112
src/app/channel/channelManager.js
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//Local Imports
|
||||
const channelModel = require('../../schemas/channelSchema');
|
||||
const activeChannel = require('./activeChannel');
|
||||
const chatHandler = require('./chatHandler');
|
||||
|
||||
//local variables
|
||||
var activeChannels = new Map;
|
||||
|
||||
module.exports.handleConnection = async function(io, socket){
|
||||
//Prevent logged out connections and authenticate socket
|
||||
if(socket.request.session.user != null){
|
||||
try{
|
||||
//Set socket user and channel values
|
||||
socket.user = socket.request.session.user;
|
||||
socket.chanName = socket.handshake.headers.referer.split('/c/')[1];
|
||||
|
||||
//Check if channel exists
|
||||
if(await channelModel.findOne({name: socket.chanName}) == null){
|
||||
socket.disconnect("Channel does not exist!");
|
||||
return;
|
||||
}
|
||||
|
||||
//Check if current channel is active
|
||||
var activeChan = activeChannels.get(socket.chan);
|
||||
if(!activeChan){
|
||||
//If not, make it so
|
||||
activeChan = new activeChannel(socket.chan);
|
||||
activeChannels.set(socket.chan, activeChan);
|
||||
}
|
||||
|
||||
//Check if this user is already connected
|
||||
if(activeChan.userList.get(socket.user.user)){
|
||||
//get current list of socket connnections of selected user
|
||||
var socketList = activeChan.userList.get(socket.user.user);
|
||||
//Add this one on
|
||||
socketList.push(socket.id);
|
||||
//Set the user back socket list back
|
||||
activeChan.userList.set(socket.user.user, socketList);
|
||||
}else{
|
||||
//if this is the first connection, initialize the socket array for this user
|
||||
activeChan.userList.set(socket.user.user, [socket.id]);
|
||||
}
|
||||
|
||||
//if everything looks good, admit the connection to the channel
|
||||
socket.join(socket.chan);
|
||||
|
||||
//Send out the userlist
|
||||
module.exports.broadcastUserList(io, socket.chan);
|
||||
|
||||
}catch(err){
|
||||
socket.disconnect("Server Error During Channel Connection Initialization");
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
|
||||
}else{
|
||||
socket.disconnect("Unauthenticated");
|
||||
return;
|
||||
}
|
||||
|
||||
//Socket Listeners
|
||||
socket.conn.on("close", (reason) => {
|
||||
//Get active channel
|
||||
var activeChan = activeChannels.get(socket.chan);
|
||||
|
||||
//If we have more than one active connection
|
||||
if(activeChan.userList.get(socket.user.user).length > 1){
|
||||
//temporarily store list of active user sockets
|
||||
var socketList = activeChan.userList.get(socket.user.user);
|
||||
//Filter out disconnecting socket from socket list, and set as current socket list for user
|
||||
activeChan.userList.set(socket.user.user,socketList.filter((id) => {
|
||||
return id != socket.id;
|
||||
}))
|
||||
}else{
|
||||
activeChan.userList.delete(socket.user.user);
|
||||
}
|
||||
|
||||
//and send out the filtered list
|
||||
module.exports.broadcastUserList(io, socket.chan);
|
||||
});
|
||||
|
||||
//define chat listeners
|
||||
chatHandler.defineListeners(io, socket);
|
||||
|
||||
}
|
||||
|
||||
module.exports.broadcastUserList = function(io, chan){
|
||||
var activeChan = activeChannels.get(chan);
|
||||
var userList = [];
|
||||
|
||||
activeChan.userList.forEach((socketlist, user) => {
|
||||
userList.push(user);
|
||||
});
|
||||
|
||||
io.in(chan).emit("user-list", userList);
|
||||
}
|
||||
39
src/app/channel/chatHandler.js
Normal file
39
src/app/channel/chatHandler.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//NPM Imports
|
||||
const validator = require('validator');//No express here, so regular validator it is!
|
||||
|
||||
module.exports.defineListeners = function(io, socket){
|
||||
socket.on("chat-message", (data) => {
|
||||
//Trim and Sanatize for XSS
|
||||
const msg = validator.trim(validator.escape(data.msg));
|
||||
//make sure high is an int
|
||||
const high = validator.toInt(data.high);
|
||||
|
||||
//nuke the message if its empty or huge
|
||||
if(!validator.isLength(msg, {min: 1, max: 255})){
|
||||
return;
|
||||
}
|
||||
|
||||
//nuke the message if the high number is wrong
|
||||
if(high < 0 || high > 10){
|
||||
return;
|
||||
}
|
||||
|
||||
io.in(socket.chan).emit("chat-message", {user: socket.user.user, msg, high});
|
||||
});
|
||||
}
|
||||
30
src/controllers/adminPanelController.js
Normal file
30
src/controllers/adminPanelController.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//Config
|
||||
const config = require('../../config.json');
|
||||
const channelModel = require('../schemas/channelSchema');
|
||||
|
||||
//register page functions
|
||||
module.exports.get = async function(req, res){
|
||||
try{
|
||||
const chanGuide = await channelModel.getChannelList(true);
|
||||
return res.render('adminPanel', {instance: config.instanceName, user: req.session.user, chanGuide: chanGuide});
|
||||
}catch(err){
|
||||
res.status(500);
|
||||
return res.send("Error indexing channels!");
|
||||
}
|
||||
}
|
||||
60
src/controllers/api/account/deleteController.js
Normal file
60
src/controllers/api/account/deleteController.js
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//npm imports
|
||||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const userModel = require('../../../schemas/userSchema');
|
||||
const accountUtils = require('../../../utils/sessionUtils.js');
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils.js');
|
||||
|
||||
//api account functions
|
||||
module.exports.post = async function(req, res){
|
||||
try{
|
||||
const validResult = validationResult(req);
|
||||
|
||||
if(validResult.isEmpty()){
|
||||
//syntactic sugar :P
|
||||
const user = req.session.user;
|
||||
const data = matchedData(req);
|
||||
|
||||
//make sure we're not bullshitting ourselves here.
|
||||
if(user == null){
|
||||
res.status(400);
|
||||
return res.send('Invalid Session! Cannot delete account while logged out!');
|
||||
}
|
||||
|
||||
const userDB = await userModel.findOne(user);
|
||||
|
||||
|
||||
if(!userDB){
|
||||
res.status(400);
|
||||
return res.send('Invalid User! Account must exist in order to delete!');
|
||||
}
|
||||
|
||||
await userDB.nuke(data.pass);
|
||||
accountUtils.killSession(req.session);
|
||||
return res.sendStatus(200);
|
||||
}else{
|
||||
res.status(400);
|
||||
res.send({errors: validResult.array()})
|
||||
}
|
||||
}catch(err){
|
||||
exceptionHandler(res, err);
|
||||
}
|
||||
|
||||
}
|
||||
45
src/controllers/api/account/loginController.js
Normal file
45
src/controllers/api/account/loginController.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//npm imports
|
||||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const accountUtils = require('../../../utils/sessionUtils.js');
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils.js');
|
||||
|
||||
|
||||
//api account functions
|
||||
module.exports.post = async function(req, res){
|
||||
try{
|
||||
const validResult = validationResult(req);
|
||||
|
||||
if(validResult.isEmpty()){
|
||||
const data = matchedData(req);
|
||||
const {user, pass} = data;
|
||||
|
||||
//try to authenticate the session, and return a successful code if it works
|
||||
await accountUtils.authenticateSession(user, pass, req);
|
||||
return res.sendStatus(200);
|
||||
}else{
|
||||
res.status(400);
|
||||
res.send({errors: validResult.array()})
|
||||
}
|
||||
}catch(err){
|
||||
exceptionHandler(res, err);
|
||||
}
|
||||
|
||||
}
|
||||
33
src/controllers/api/account/logoutController.js
Normal file
33
src/controllers/api/account/logoutController.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//local imports
|
||||
const accountUtils = require('../../../utils/sessionUtils.js');
|
||||
|
||||
module.exports.get = async function(req, res){
|
||||
if(req.session.user){
|
||||
try{
|
||||
accountUtils.killSession(req.session);
|
||||
return res.sendStatus(200);
|
||||
}catch(err){
|
||||
res.status(400);
|
||||
return res.send(err.message)
|
||||
}
|
||||
}else{
|
||||
res.status(400);
|
||||
return res.send()
|
||||
}
|
||||
}
|
||||
39
src/controllers/api/account/registerController.js
Normal file
39
src/controllers/api/account/registerController.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//NPM Imports
|
||||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const userModel = require('../../../schemas/userSchema');
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils.js');
|
||||
|
||||
module.exports.post = async function(req, res){
|
||||
try{
|
||||
const validResult = validationResult(req);
|
||||
|
||||
if(validResult.isEmpty()){
|
||||
const user = matchedData(req);
|
||||
await userModel.register(user)
|
||||
return res.sendStatus(200);
|
||||
}else{
|
||||
res.status(400);
|
||||
res.send({errors: validResult.array()})
|
||||
}
|
||||
}catch(err){
|
||||
exceptionHandler(res, err);
|
||||
}
|
||||
}
|
||||
89
src/controllers/api/account/updateController.js
Normal file
89
src/controllers/api/account/updateController.js
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//NPM Imports
|
||||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const userModel = require('../../../schemas/userSchema');
|
||||
const accountUtils = require('../../../utils/sessionUtils.js');
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils.js');
|
||||
|
||||
module.exports.post = async function(req, res){
|
||||
const validResult = validationResult(req);
|
||||
const data = matchedData(req);
|
||||
var tempResult = [];
|
||||
|
||||
//if we're not chaning the password
|
||||
if(data.passChange == null){
|
||||
//go through validation errors
|
||||
validResult.errors.forEach(function(error, i){
|
||||
//remove irrelevant password validation errors (i know its gross but they need to be optional as a set, not individually)
|
||||
if(!error.path.startsWith("passChange.")){
|
||||
tempResult.push(error);
|
||||
}
|
||||
});
|
||||
|
||||
validResult.errors = tempResult;
|
||||
}
|
||||
|
||||
try{
|
||||
if(validResult.isEmpty()){
|
||||
const {field, change} = data;
|
||||
const {user} = req.session;
|
||||
|
||||
const userDB = await userModel.findOne(user);
|
||||
const update = {};
|
||||
|
||||
if(userDB){
|
||||
if(data.img){
|
||||
userDB.img = data.img;
|
||||
update.img = data.img;
|
||||
}
|
||||
|
||||
if(data.bio){
|
||||
userDB.bio = data.bio;
|
||||
update.bio = data.bio;
|
||||
}
|
||||
|
||||
if(data.signature){
|
||||
userDB.signature = data.signature;
|
||||
update.signature = data.signature;
|
||||
}
|
||||
|
||||
if(data.passChange){
|
||||
//kill active session to prevent connect-mongo from freaking out
|
||||
accountUtils.killSession(req.session);
|
||||
await userDB.passwordReset(data.passChange);
|
||||
}
|
||||
|
||||
await userDB.save();
|
||||
|
||||
res.status(200);
|
||||
return res.send(update);
|
||||
}else{
|
||||
res.status(400);
|
||||
return res.send({errors: [{msg:"User not found!"}]});
|
||||
}
|
||||
}else{
|
||||
res.status(400);
|
||||
res.send({errors: validResult.array()})
|
||||
}
|
||||
}catch(err){
|
||||
exceptionHandler(res, err);
|
||||
}
|
||||
|
||||
}
|
||||
48
src/controllers/api/channel/deleteController.js
Normal file
48
src/controllers/api/channel/deleteController.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//NPM imports
|
||||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils.js');
|
||||
const channelModel = require('../../../schemas/channelSchema');
|
||||
|
||||
//api account functions
|
||||
module.exports.post = async function(req, res){
|
||||
try{
|
||||
const validResult = validationResult(req);
|
||||
|
||||
if(validResult.isEmpty()){
|
||||
const data = matchedData(req);
|
||||
const channel = await channelModel.findOne({name: data.chanName});
|
||||
|
||||
if(channel == null){
|
||||
throw new Error("Chanenl does not exist!");
|
||||
}
|
||||
|
||||
await channel.nuke(data.confirm);
|
||||
return res.sendStatus(200);
|
||||
}else{
|
||||
res.status(400);
|
||||
res.send({errors: validResult.array()})
|
||||
}
|
||||
}catch(err){
|
||||
exceptionHandler(res, err);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
32
src/controllers/api/channel/listController.js
Normal file
32
src/controllers/api/channel/listController.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//local imports
|
||||
const channelModel = require('../../../schemas/channelSchema');
|
||||
|
||||
//api account functions
|
||||
module.exports.get = async function(req, res){
|
||||
try{
|
||||
//I'm not sanatizing this, it never gets processed...
|
||||
const chanGuide = await channelModel.getChannelList(req.query.showHidden || req.query.showHidden === '');
|
||||
|
||||
res.status(200);
|
||||
return res.send(chanGuide);
|
||||
}catch(err){
|
||||
res.status(400);
|
||||
return res.send(err.message);
|
||||
}
|
||||
}
|
||||
42
src/controllers/api/channel/registerController.js
Normal file
42
src/controllers/api/channel/registerController.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//NPM Imports
|
||||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils.js');
|
||||
const channelModel = require('../../../schemas/channelSchema');
|
||||
|
||||
//api account functions
|
||||
module.exports.post = async function(req, res){
|
||||
try{
|
||||
const validResult = validationResult(req);
|
||||
const channel = matchedData(req);
|
||||
|
||||
|
||||
if(validResult.isEmpty()){
|
||||
await channelModel.register(channel)
|
||||
return res.sendStatus(200);
|
||||
}else{
|
||||
res.status(400);
|
||||
res.send({errors: validResult.array()})
|
||||
}
|
||||
}catch(err){
|
||||
exceptionHandler(res, err);
|
||||
}
|
||||
|
||||
}
|
||||
72
src/controllers/api/channel/settingsController.js
Normal file
72
src/controllers/api/channel/settingsController.js
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//NPM imports
|
||||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils.js');
|
||||
const channelModel = require('../../../schemas/channelSchema');
|
||||
|
||||
//api account functions
|
||||
module.exports.get = async function(req, res){
|
||||
try{
|
||||
const validResult = validationResult(req);
|
||||
|
||||
if(validResult.isEmpty()){
|
||||
const data = matchedData(req);
|
||||
const channel = await channelModel.findOne({name: data.chanName});
|
||||
|
||||
if(channel == null){
|
||||
throw new Error("Channel not found.");
|
||||
}
|
||||
|
||||
res.status(200);
|
||||
return res.send(channel.settings);
|
||||
}else{
|
||||
res.status(400);
|
||||
res.send({errors: validResult.array()})
|
||||
}
|
||||
}catch(err){
|
||||
exceptionHandler(res, err);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports.post = async function(req, res){
|
||||
try{
|
||||
const validResult = validationResult(req);
|
||||
|
||||
if(validResult.isEmpty()){
|
||||
const data = matchedData(req);
|
||||
const channel = await channelModel.findOne({name: data.chanName});
|
||||
const settingsMap = new Map(Object.entries(data.settingsMap));
|
||||
|
||||
if(channel == null){
|
||||
throw new Error("Channel not found.");
|
||||
}
|
||||
|
||||
res.status(200);
|
||||
return res.send(await channel.updateSettings(settingsMap));
|
||||
}else{
|
||||
res.status(400);
|
||||
res.send({errors: validResult.array()})
|
||||
}
|
||||
}catch(err){
|
||||
exceptionHandler(res, err);
|
||||
}
|
||||
|
||||
}
|
||||
23
src/controllers/channelController.js
Normal file
23
src/controllers/channelController.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//Config
|
||||
const config = require('../../config.json');
|
||||
|
||||
//channel functions
|
||||
module.exports.get = function(req, res){
|
||||
res.render('channel', {instance: config.instanceName, user: req.session.user});
|
||||
}
|
||||
36
src/controllers/channelSettingsController.js
Normal file
36
src/controllers/channelSettingsController.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//Config
|
||||
const config = require('../../config.json');
|
||||
const channelModel = require('../schemas/channelSchema');
|
||||
|
||||
//root index functions
|
||||
module.exports.get = async function(req, res){
|
||||
try{
|
||||
const chanName = (req.url.slice(1).replace('/settings',''));
|
||||
const channel = await channelModel.findOne({name: chanName});
|
||||
|
||||
if(channel == null){
|
||||
throw new Error("Channel not found.");
|
||||
}
|
||||
|
||||
return res.render('channelSettings', {instance: config.instanceName, user: req.session.user, channel});
|
||||
}catch(err){
|
||||
res.status(500);
|
||||
res.send(err.message);
|
||||
}
|
||||
}
|
||||
30
src/controllers/indexController.js
Normal file
30
src/controllers/indexController.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//Config
|
||||
const config = require('../../config.json');
|
||||
const channelModel = require('../schemas/channelSchema');
|
||||
|
||||
//root index functions
|
||||
module.exports.get = async function(req, res){
|
||||
try{
|
||||
const chanGuide = await channelModel.getChannelList();
|
||||
return res.render('index', {instance: config.instanceName, user: req.session.user, chanGuide: chanGuide});
|
||||
}catch(err){
|
||||
res.status(500);
|
||||
return res.send("Error indexing channels!");
|
||||
}
|
||||
}
|
||||
23
src/controllers/newChannelController.js
Normal file
23
src/controllers/newChannelController.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//Config
|
||||
const config = require('../../config.json');
|
||||
|
||||
//root index functions
|
||||
module.exports.get = async function(req, res){
|
||||
res.render('newChannel', {instance: config.instanceName, user: req.session.user});
|
||||
}
|
||||
50
src/controllers/profileController.js
Normal file
50
src/controllers/profileController.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//Local Imports
|
||||
const userModel = require('../schemas/userSchema');
|
||||
|
||||
//Config
|
||||
const config = require('../../config.json');
|
||||
|
||||
|
||||
//profile functions
|
||||
module.exports.get = async function(req, res){
|
||||
|
||||
var profileName = req.url.slice(1) == '' ? (req.session.user ? req.session.user.user : null) : req.url.slice(1);
|
||||
|
||||
const userDB = await userModel.findOne({ user: profileName });
|
||||
|
||||
if(userDB){
|
||||
res.render('profile', {instance: config.instanceName,
|
||||
user: req.session.user,
|
||||
profile: {
|
||||
id: userDB.id,
|
||||
user: userDB.user,
|
||||
date: userDB.date,
|
||||
tokes: userDB.tokes,
|
||||
img: userDB.img,
|
||||
signature: userDB.signature,
|
||||
bio: userDB.bio
|
||||
}
|
||||
});
|
||||
}else{
|
||||
res.render('profile', {instance: config.instanceName,
|
||||
user: req.session.user,
|
||||
profile: null
|
||||
});
|
||||
}
|
||||
}
|
||||
23
src/controllers/registerController.js
Normal file
23
src/controllers/registerController.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//Config
|
||||
const config = require('../../config.json');
|
||||
|
||||
//register page functions
|
||||
module.exports.get = function(req, res){
|
||||
res.render('register', {instance: config.instanceName, user: req.session.user});
|
||||
}
|
||||
30
src/routers/adminPanelRouter.js
Normal file
30
src/routers/adminPanelRouter.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//npm imports
|
||||
const { Router } = require('express');
|
||||
|
||||
|
||||
//local imports
|
||||
const adminPanelController = require("../controllers/adminPanelController");
|
||||
|
||||
//globals
|
||||
const router = Router();
|
||||
|
||||
//routing functions
|
||||
router.get('/', adminPanelController.get);
|
||||
|
||||
module.exports = router;
|
||||
50
src/routers/api/accountRouter.js
Normal file
50
src/routers/api/accountRouter.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//npm imports
|
||||
const { Router } = require('express');
|
||||
|
||||
//local imports
|
||||
const {accountValidator} = require("../../utils/validators");
|
||||
const loginController = require("../../controllers/api/account/loginController");
|
||||
const logoutController = require("../../controllers/api/account/logoutController");
|
||||
const registerController = require("../../controllers/api/account/registerController");
|
||||
const updateController = require("../../controllers/api/account/updateController");
|
||||
const deleteController = require("../../controllers/api/account/deleteController");
|
||||
|
||||
//globals
|
||||
const router = Router();
|
||||
|
||||
//routing functions
|
||||
router.post('/login', accountValidator.user(), accountValidator.pass(), loginController.post);
|
||||
|
||||
router.get('/logout', logoutController.get);
|
||||
|
||||
router.post('/register', accountValidator.user(),
|
||||
accountValidator.pass(),
|
||||
accountValidator.pass('passConfirm'),
|
||||
accountValidator.email(), registerController.post);
|
||||
|
||||
router.post('/update', accountValidator.img(),
|
||||
accountValidator.bio(),
|
||||
accountValidator.signature(),
|
||||
accountValidator.pass('passChange.oldPass'),
|
||||
accountValidator.securePass('passChange.newPass'),
|
||||
accountValidator.pass('passChange.confirmPass'), updateController.post);
|
||||
|
||||
router.post('/delete', accountValidator.pass(), deleteController.post);
|
||||
|
||||
module.exports = router;
|
||||
37
src/routers/api/channelRouter.js
Normal file
37
src/routers/api/channelRouter.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//npm imports
|
||||
const { Router } = require('express');
|
||||
|
||||
//local imports
|
||||
const {channelValidator} = require("../../utils/validators");
|
||||
const registerController = require("../../controllers/api/channel/registerController");
|
||||
const listController = require("../../controllers/api/channel/listController");
|
||||
const settingsController = require("../../controllers/api/channel/settingsController");
|
||||
const deleteController = require("../../controllers/api/channel/deleteController");
|
||||
|
||||
//globals
|
||||
const router = Router();
|
||||
|
||||
//routing functions
|
||||
router.post('/register', channelValidator.name(), channelValidator.description(), channelValidator.thumbnail(), registerController.post);
|
||||
router.get('/list', listController.get);
|
||||
router.get('/settings', channelValidator.name('chanName'), settingsController.get);
|
||||
router.post('/settings', channelValidator.name('chanName'), channelValidator.settingsMap(), settingsController.post);
|
||||
router.post('/delete', channelValidator.name('chanName'), channelValidator.name('confirm'),deleteController.post);
|
||||
|
||||
module.exports = router;
|
||||
31
src/routers/apiRouter.js
Normal file
31
src/routers/apiRouter.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//npm imports
|
||||
const { Router } = require('express');
|
||||
|
||||
//local imports
|
||||
const accountRouter = require("./api/accountRouter");
|
||||
const channelRouter = require("./api/channelRouter");
|
||||
|
||||
//globals
|
||||
const router = Router();
|
||||
|
||||
//routing functions
|
||||
router.use('/account', accountRouter);
|
||||
router.use('/channel', channelRouter);
|
||||
|
||||
module.exports = router;
|
||||
32
src/routers/channelRouter.js
Normal file
32
src/routers/channelRouter.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//npm imports
|
||||
const { Router } = require('express');
|
||||
|
||||
|
||||
//local imports
|
||||
const channelController = require("../controllers/channelController");
|
||||
const channelSettingsController = require("../controllers/channelSettingsController");
|
||||
|
||||
//globals
|
||||
const router = Router();
|
||||
|
||||
//routing functions
|
||||
router.get('/*/settings', channelSettingsController.get);
|
||||
router.get('/*/', channelController.get);
|
||||
|
||||
module.exports = router;
|
||||
30
src/routers/indexRouter.js
Normal file
30
src/routers/indexRouter.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//npm imports
|
||||
const { Router } = require('express');
|
||||
|
||||
|
||||
//local imports
|
||||
const indexController = require("../controllers/indexController");
|
||||
|
||||
//globals
|
||||
const router = Router();
|
||||
|
||||
//routing functions
|
||||
router.get('/', indexController.get);
|
||||
|
||||
module.exports = router;
|
||||
30
src/routers/newChannelRouter.js
Normal file
30
src/routers/newChannelRouter.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//npm imports
|
||||
const { Router } = require('express');
|
||||
|
||||
|
||||
//local imports
|
||||
const newChannelController = require("../controllers/newChannelController");
|
||||
|
||||
//globals
|
||||
const router = Router();
|
||||
|
||||
//routing functions
|
||||
router.get('/', newChannelController.get);
|
||||
|
||||
module.exports = router;
|
||||
30
src/routers/profileRouter.js
Normal file
30
src/routers/profileRouter.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//npm imports
|
||||
const { Router } = require('express');
|
||||
|
||||
|
||||
//local imports
|
||||
const profileController = require("../controllers/profileController");
|
||||
|
||||
//globals
|
||||
const router = Router();
|
||||
|
||||
//routing functions
|
||||
router.get('/*', profileController.get);
|
||||
|
||||
module.exports = router;
|
||||
30
src/routers/registerRouter.js
Normal file
30
src/routers/registerRouter.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//npm imports
|
||||
const { Router } = require('express');
|
||||
|
||||
|
||||
//local imports
|
||||
const registerController = require("../controllers/registerController");
|
||||
|
||||
//globals
|
||||
const router = Router();
|
||||
|
||||
//routing functions
|
||||
router.get('/', registerController.get);
|
||||
|
||||
module.exports = router;
|
||||
127
src/schemas/channelSchema.js
Normal file
127
src/schemas/channelSchema.js
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//NPM Imports
|
||||
const {mongoose} = require('mongoose');
|
||||
|
||||
//Local Imports
|
||||
const statSchema = require('./statSchema.js');
|
||||
|
||||
const channelSchema = new mongoose.Schema({
|
||||
id: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
required: true
|
||||
},
|
||||
name: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true,
|
||||
default: 0
|
||||
},
|
||||
description: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true,
|
||||
default: 0
|
||||
},
|
||||
thumbnail: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true,
|
||||
default: "img/johnny.png"
|
||||
},
|
||||
settings: {
|
||||
hidden: {
|
||||
type: mongoose.SchemaTypes.Boolean,
|
||||
required: true,
|
||||
default: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
channelSchema.pre('save', async function (next){
|
||||
if(this.isModified("name")){
|
||||
if(this.name.match(/^[a-z0-9_\-.]+$/i) == null){
|
||||
throw new Error("Username must only contain alpha-numerics and the following symbols: '-_.'");
|
||||
}
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
//statics
|
||||
channelSchema.statics.register = async function(channelObj){
|
||||
const {name, description, thumbnail} = channelObj;
|
||||
|
||||
const chanDB = await this.findOne({ name });
|
||||
|
||||
if(chanDB){
|
||||
throw new Error("Channel name already taken!");
|
||||
}else{
|
||||
const id = await statSchema.incrementChannelCount();
|
||||
const newChannel = await this.create((thumbnail ? {id, name, description, thumbnail} : {id, name, description}));
|
||||
}
|
||||
}
|
||||
|
||||
channelSchema.statics.getChannelList = async function(includeHidden = false){
|
||||
const chanDB = await this.find({});
|
||||
var chanGuide = [];
|
||||
|
||||
//crawl through channels
|
||||
chanDB.forEach((channel) => {
|
||||
//For each channel, push an object with only the information we need to the channel guide
|
||||
if(!channel.settings.hidden || includeHidden){
|
||||
chanGuide.push({
|
||||
id: channel.id,
|
||||
name: channel.name,
|
||||
description: channel.description,
|
||||
thumbnail: channel.thumbnail
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//return the channel guide
|
||||
return chanGuide;
|
||||
}
|
||||
|
||||
//methods
|
||||
channelSchema.methods.updateSettings = async function(settingsMap){
|
||||
settingsMap.forEach((value, key) => {
|
||||
if(this.settings[key] == null){
|
||||
throw new Error("Invalid channel setting.");
|
||||
}
|
||||
|
||||
this.settings[key] = value;
|
||||
})
|
||||
|
||||
await this.save();
|
||||
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
channelSchema.methods.nuke = async function(confirm){
|
||||
if(confirm == "" || confirm == null){
|
||||
throw new Error("Empty Confirmation String!");
|
||||
}else if(confirm != this.name){
|
||||
throw new Error("Bad Confirmation String!");
|
||||
}
|
||||
|
||||
//Annoyingly there isnt a good way to do this from 'this'
|
||||
var oldUser = await module.exports.deleteOne(this);
|
||||
|
||||
if(oldUser == null){
|
||||
throw new Error("Server Error: Unable to delete channel! Please report this error to your server administrator, and with timestamp.");
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = mongoose.model("channel", channelSchema);
|
||||
104
src/schemas/statSchema.js
Normal file
104
src/schemas/statSchema.js
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//NPM Imports
|
||||
const {mongoose} = require('mongoose');
|
||||
|
||||
//Local Imports
|
||||
const config = require('./../../config.json');
|
||||
|
||||
const statSchema = new mongoose.Schema({
|
||||
//This does NOT handle deleted accounts/channels. Use userModel.estimatedDocumentCount() for number of active users.
|
||||
userCount: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
required: true,
|
||||
default: 0
|
||||
},
|
||||
channelCount: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
required: true,
|
||||
default: 0
|
||||
},
|
||||
launchCount: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
required: true,
|
||||
default: 0
|
||||
}
|
||||
});
|
||||
|
||||
//statics
|
||||
statSchema.statics.getStats = async function(){
|
||||
//Get the first document we find
|
||||
var stats = await this.findOne({});
|
||||
|
||||
if(stats){
|
||||
//If we found something then the statistics document exist and this is it,
|
||||
//So long as no one else has fucked with the database it should be the only one. (is this forshadowing for a future bug?)
|
||||
return stats;
|
||||
}else{
|
||||
//Otherwise this is the first launch of the install, say hello
|
||||
console.log("First launch detected! Initializing statistics document in Database!");
|
||||
|
||||
//create and save the statistics document
|
||||
stats = await this.create({});
|
||||
await stats.save();
|
||||
|
||||
//live up to the name of the function
|
||||
return stats;
|
||||
}
|
||||
}
|
||||
|
||||
statSchema.statics.incrementLaunchCount = async function(){
|
||||
//get our statistics document
|
||||
const stats = await this.getStats();
|
||||
|
||||
//increment counter and save
|
||||
stats.launchCount++;
|
||||
stats.save();
|
||||
|
||||
//print bootup message to console.
|
||||
console.log(`${config.instanceName}(Powered by Canopy) initialized. This server has booted ${stats.launchCount} time${stats.launchCount == 1 ? '' : 's'}.`)
|
||||
}
|
||||
|
||||
statSchema.statics.incrementUserCount = async function(){
|
||||
//get our statistics document
|
||||
const stats = await this.getStats();
|
||||
//temporarily keep old count so we can return it for the users ID
|
||||
const oldCount = stats.userCount;
|
||||
|
||||
//increment counter and save
|
||||
stats.userCount++;
|
||||
stats.save();
|
||||
|
||||
//return the count from beggining of function for user ID
|
||||
return oldCount;
|
||||
}
|
||||
|
||||
statSchema.statics.incrementChannelCount = async function(){
|
||||
//get our statistics document
|
||||
const stats = await this.getStats();
|
||||
//temporarily keep old count so we can return it for the channel ID
|
||||
const oldCount = stats.channelCount;
|
||||
|
||||
//increment counter and save
|
||||
stats.channelCount++;
|
||||
stats.save();
|
||||
|
||||
//return the count from beggining of function for channel ID
|
||||
return oldCount;
|
||||
}
|
||||
|
||||
module.exports = mongoose.model("statistics", statSchema);
|
||||
210
src/schemas/userSchema.js
Normal file
210
src/schemas/userSchema.js
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//NPM Imports
|
||||
const {mongoose} = require('mongoose');
|
||||
|
||||
//local imports
|
||||
const server = require('../server.js');
|
||||
const statSchema = require('./statSchema.js');
|
||||
const hashUtil = require('../utils/hashUtils');
|
||||
|
||||
|
||||
const userSchema = new mongoose.Schema({
|
||||
id: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
required: true
|
||||
},
|
||||
user: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true,
|
||||
},
|
||||
pass: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true
|
||||
},
|
||||
email: {
|
||||
type: mongoose.SchemaTypes.String
|
||||
},
|
||||
date: {
|
||||
type: mongoose.SchemaTypes.Date,
|
||||
required: true,
|
||||
default: new Date()
|
||||
},
|
||||
tokes: {
|
||||
type: mongoose.SchemaTypes.Map,
|
||||
required: true,
|
||||
default: new Map()
|
||||
},
|
||||
img: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true,
|
||||
default: "img/johnny.png"
|
||||
},
|
||||
bio: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true,
|
||||
default: "Bio not set!"
|
||||
},
|
||||
signature: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true,
|
||||
default: "Signature not set!"
|
||||
}
|
||||
});
|
||||
|
||||
//This is one of those places where you really DON'T want to use an arrow function over an anonymous one!
|
||||
userSchema.pre('save', async function (next){
|
||||
if(this.isModified("pass")){
|
||||
this.pass = hashUtil.hashPassword(this.pass);
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
//statics
|
||||
userSchema.statics.register = async function(userObj){
|
||||
const {user, pass, passConfirm, email} = userObj;
|
||||
|
||||
if(pass == passConfirm){
|
||||
const userDB = await this.findOne({$or: email ? [{user}, {email}] : [{user}]});
|
||||
|
||||
if(userDB){
|
||||
throw new Error("User name/email already taken!");
|
||||
}else{
|
||||
const id = await statSchema.incrementUserCount();
|
||||
const newUser = await this.create({id, user, pass, email});
|
||||
}
|
||||
}else{
|
||||
throw new Error("Confirmation password doesn't match!");
|
||||
}
|
||||
}
|
||||
|
||||
userSchema.statics.authenticate = async function(user, pass){
|
||||
//check for missing pass
|
||||
if(!user || !pass){
|
||||
throw new Error("Missing user/pass.");
|
||||
}
|
||||
|
||||
//get the user if it exists
|
||||
const userDB = await this.findOne({ user });
|
||||
|
||||
//if not scream and shout
|
||||
if(!userDB){
|
||||
badLogin();
|
||||
}
|
||||
|
||||
//Check our password is correct
|
||||
if(userDB.checkPass(pass)){
|
||||
return userDB;
|
||||
}else{
|
||||
//if not scream and shout
|
||||
badLogin();
|
||||
}
|
||||
|
||||
//standardize bad login response so it's unknowin which is bad for security reasons.
|
||||
function badLogin(){
|
||||
throw new Error("Bad Username or Password.");
|
||||
}
|
||||
}
|
||||
|
||||
//methods
|
||||
userSchema.methods.checkPass = function(pass){
|
||||
return hashUtil.comparePassword(pass, this.pass);
|
||||
}
|
||||
|
||||
userSchema.methods.getAuthenticatedSessions = async function(){
|
||||
var returnArr = [];
|
||||
|
||||
//retrieve active sessions (they really need to implement this shit async already)
|
||||
return new Promise((resolve) => {
|
||||
server.store.all((err, sessions) => {
|
||||
//You guys ever hear of a 'not my' problem? Fucking y33tskies lmao, better use a try/catch
|
||||
if(err){
|
||||
throw err;
|
||||
|
||||
}
|
||||
|
||||
//crawl through active sessions
|
||||
sessions.forEach((session) => {
|
||||
//if a session matches the current user
|
||||
if(session.user.id == this.id){
|
||||
//we return it
|
||||
returnArr.push(session);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
resolve(returnArr);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//note: if you gotta call this from a request authenticated by it's user, make sure to kill that session first!
|
||||
userSchema.methods.killAllSessions = async function(){
|
||||
//get authenticated sessions
|
||||
var sessions = await this.getAuthenticatedSessions();
|
||||
|
||||
//crawl through and kill all sessions
|
||||
sessions.forEach((session) => {
|
||||
server.store.destroy(session.seshid);
|
||||
});
|
||||
}
|
||||
|
||||
userSchema.methods.passwordReset = async function(passChange){
|
||||
if(this.checkPass(passChange.oldPass)){
|
||||
if(passChange.newPass == passChange.confirmPass){
|
||||
//Note: We don't have to worry about hashing here because the schema is written to do it auto-magically
|
||||
this.pass = passChange.newPass;
|
||||
|
||||
//Save our password
|
||||
await this.save();
|
||||
|
||||
//Kill all authed sessions for security purposes
|
||||
await this.killAllSessions();
|
||||
}else{
|
||||
//confirmation pass doesn't match
|
||||
throw new Error("Mismatched confirmation password!");
|
||||
}
|
||||
}else{
|
||||
//Old password wrong
|
||||
throw new Error("Incorrect Password!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
userSchema.methods.nuke = async function(pass){
|
||||
if(pass == "" || pass == null){
|
||||
throw new Error("No confirmation password!");
|
||||
}
|
||||
|
||||
if(this.checkPass(pass)){
|
||||
//Annoyingly there isnt a good way to do this from 'this'
|
||||
var oldUser = await module.exports.deleteOne(this);
|
||||
|
||||
if(oldUser){
|
||||
await this.killAllSessions();
|
||||
}else{
|
||||
throw new Error("Server Error: Unable to delete account! Please report this error to your server administrator, and with timestamp.");
|
||||
}
|
||||
}else{
|
||||
throw new Error("Bad pass.");
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = mongoose.model("user", userSchema);
|
||||
111
src/server.js
Normal file
111
src/server.js
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//Define NPM imports
|
||||
const express = require('express');
|
||||
const session = require('express-session');
|
||||
const {createServer } = require('http');
|
||||
const { Server } = require('socket.io');
|
||||
const path = require('path');
|
||||
const mongoStore = require('connect-mongo');
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
//Define Local Imports
|
||||
const statModel = require('./schemas/statSchema');
|
||||
const channelManager = require('./app/channel/channelManager');
|
||||
const indexRouter = require('./routers/indexRouter');
|
||||
const registerRouter = require('./routers/registerRouter');
|
||||
const profileRouter = require('./routers/profileRouter');
|
||||
const adminPanelRouter = require('./routers/adminPanelRouter');
|
||||
const channelRouter = require('./routers/channelRouter');
|
||||
const newChannelRouter = require('./routers/newChannelRouter');
|
||||
const apiRouter = require('./routers/apiRouter');
|
||||
|
||||
//Define Config
|
||||
const config = require('../config.json');
|
||||
const port = config.port;
|
||||
const dbUrl = `mongodb://${config.db.user}:${config.db.pass}@${config.db.address}:${config.db.port}/${config.db.database}`;
|
||||
|
||||
//Define Node JS
|
||||
const app = express();
|
||||
|
||||
//Define session-store (exported so we can kill sessions from user schema)
|
||||
module.exports.store = mongoStore.create({mongoUrl: dbUrl});
|
||||
|
||||
//define sessionMiddleware
|
||||
const sessionMiddleware = session({
|
||||
secret: config.sessionSecret,
|
||||
resave: false,
|
||||
saveUninitialized: false,
|
||||
store: module.exports.store
|
||||
});
|
||||
|
||||
//Define http and socket.io servers
|
||||
const httpServer = createServer(app);
|
||||
const io = new Server(httpServer, {});
|
||||
|
||||
//Connect mongoose to the database
|
||||
mongoose.set("sanitizeFilter", true).connect(dbUrl).then(() => {
|
||||
console.log("Connected to DB");
|
||||
}).catch((err) => {
|
||||
console.error("Unable to connecto to DB: ");
|
||||
console.error(err);
|
||||
process.exit();
|
||||
});
|
||||
|
||||
//Set View Engine
|
||||
app.set('view engine', 'ejs');
|
||||
app.set('views', __dirname + '/views');
|
||||
|
||||
//Middlware
|
||||
//Enable Express
|
||||
app.use(express.json());
|
||||
|
||||
//Enable Express-Sessions
|
||||
app.use(sessionMiddleware);
|
||||
|
||||
//Enable Express-Session w/ Socket.IO
|
||||
io.engine.use(sessionMiddleware);
|
||||
|
||||
//Routes
|
||||
//Humie-Friendly
|
||||
app.use('/', indexRouter);
|
||||
app.use('/register', registerRouter);
|
||||
app.use('/profile', profileRouter);
|
||||
app.use('/adminPanel', adminPanelRouter);
|
||||
app.use('/c', channelRouter);
|
||||
app.use('/newChannel', newChannelRouter);
|
||||
//Bot-Ready
|
||||
app.use('/api', apiRouter);
|
||||
|
||||
//3rd-Party Browser-Side Libraries
|
||||
app.use('/lib/bootstrap-icons',express.static(path.join(__dirname, '../node_modules/bootstrap-icons')));
|
||||
app.use('/lib/socket.io',express.static(path.join(__dirname, '../node_modules/socket.io/client-dist')));
|
||||
app.use('/lib/validator',express.static(path.join(__dirname, '../node_modules/validator')));
|
||||
|
||||
//Static File Server
|
||||
app.use(express.static(path.join(__dirname, '../www')));
|
||||
|
||||
//Increment launch counter
|
||||
statModel.incrementLaunchCount();
|
||||
|
||||
//Hand over general-namespace socket.io connections to the channel manager
|
||||
io.on("connection", (socket) => {channelManager.handleConnection(io, socket)} );
|
||||
|
||||
//Listen Function
|
||||
httpServer.listen(port, () => {
|
||||
console.log(`Opening port ${port}`);
|
||||
});
|
||||
26
src/utils/hashUtils.js
Normal file
26
src/utils/hashUtils.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
const bcrypt = require('bcrypt');
|
||||
|
||||
module.exports.hashPassword = function(pass){
|
||||
const salt = bcrypt.genSaltSync();
|
||||
return bcrypt.hashSync(pass, salt);
|
||||
}
|
||||
|
||||
module.exports.comparePassword = function(pass, hash){
|
||||
return bcrypt.compareSync(pass, hash);
|
||||
}
|
||||
22
src/utils/loggerUtils.js
Normal file
22
src/utils/loggerUtils.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//At some point this will be a bit more advanced, right now it's just a placeholder :P
|
||||
module.exports.exceptionHandler = function(res, err){
|
||||
//if not yell at the browser for fucking up, and tell it what it did wrong.
|
||||
res.status(400);
|
||||
return res.send({errors: [{type: "Caught Exception", msg: err.message, date: new Date()}]});
|
||||
}
|
||||
48
src/utils/sessionUtils.js
Normal file
48
src/utils/sessionUtils.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//local imports
|
||||
const userModel = require('../schemas/userSchema.js');
|
||||
|
||||
//this module is good for keeping wrappers for userModel and other shit in that does more session handling than database access/modification.
|
||||
|
||||
module.exports.authenticateSession = async function(user, pass, req){
|
||||
|
||||
//Authenticate the session
|
||||
userDB = await userModel.authenticate(user, pass);
|
||||
|
||||
//Tattoo the session with user and metadata
|
||||
//unfortunately store.all() does not return sessions w/ their ID so we had to improvise...
|
||||
//Not sure if this is just how connect-mongo is implemented or if it's an express issue, but connect-mongodb-session seems to not implement the all() function what so ever...
|
||||
req.session.seshid = req.session.id;
|
||||
req.session.authdate = new Date();
|
||||
req.session.authip = req.ip;
|
||||
req.session.user = {
|
||||
user: userDB.user,
|
||||
id: userDB.id
|
||||
}
|
||||
|
||||
|
||||
//userDB.activeSessions.push(sessionData);
|
||||
await userDB.save();
|
||||
|
||||
//return user
|
||||
return userDB.user;
|
||||
}
|
||||
|
||||
module.exports.killSession = async function(session){
|
||||
session.destroy();
|
||||
}
|
||||
50
src/utils/validators.js
Normal file
50
src/utils/validators.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//NPM Imports
|
||||
const { check, body, checkSchema, checkExact} = require('express-validator');
|
||||
|
||||
module.exports.accountValidator = {
|
||||
user: (field = 'user') => body(field).escape().trim().isLength({min: 1, max: 22}),
|
||||
|
||||
//Password security requirements may change over time, therefore we should only validate against strongPassword() when creating new accounts
|
||||
//that way we don't break old ones upon change
|
||||
pass: (field = 'pass') => body(field).notEmpty().escape().trim(),
|
||||
securePass: (field) => this.accountValidator.pass(field).isStrongPassword({minLength: 8, minLowercase: 1, minUppercase: 1, minNumbers: 1, minSymbols: 1}),
|
||||
|
||||
email: (field = 'email') => body(field).optional().isEmail().normalizeEmail(),
|
||||
|
||||
img: (field = 'img') => body(field).optional().isURL({require_tld: false}).trim(),
|
||||
|
||||
signature: (field = 'signature') => body(field).optional().escape().trim().isLength({min: 1, max: 150}),
|
||||
|
||||
bio: (field = 'bio') => body(field).optional().escape().trim().isLength({min: 1, max: 1000}),
|
||||
}
|
||||
|
||||
module.exports.channelValidator = {
|
||||
name: (field = 'name') => check(field).escape().trim().isLength({min: 1, max: 50}),
|
||||
|
||||
description: (field = 'description') => body(field).escape().trim().isLength({min: 1, max: 1000}),
|
||||
|
||||
thumbnail: (field = 'thumbnail') => this.accountValidator.img(field),
|
||||
|
||||
settingsMap: () => checkExact(checkSchema({
|
||||
'settingsMap.hidden': {
|
||||
optional: true,
|
||||
isBoolean: true,
|
||||
}
|
||||
}))
|
||||
}
|
||||
63
src/views/adminPanel.ejs
Normal file
63
src/views/adminPanel.ejs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<!--Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%- include('partial/styles', {instance, user}); %>
|
||||
<link rel="stylesheet" type="text/css" href="/css/adminPanel.css">
|
||||
<title><%= instance %> - Admin Panel</title>
|
||||
</head>
|
||||
<body>
|
||||
<%- include('partial/navbar', {user}); %>
|
||||
<div id="admin-channel-list-div" class="admin-channel-list">
|
||||
<h3>Channel List:</h3>
|
||||
<table id="admin-channel-list-table" class="admin-channel-list">
|
||||
<tr id="admin-channel-list-entry-title" class="admin-channel-list-entry">
|
||||
<td id="admin-channel-list-entry-img-title" class="admin-channel-list-entry admin-channel-list-entry-title admin-channel-list-entry-item admin-channel-list-entry-img-row">
|
||||
<h3>Img</h3>
|
||||
</td>
|
||||
<td id="admin-channel-list-entry-name-title" class="admin-channel-list-entry admin-channel-list-entry-title admin-channel-list-entry-item admin-channel-list-entry-name-row">
|
||||
<h3>Name</h3>
|
||||
</td>
|
||||
<td id="admin-channel-list-entry-description-title" class="admin-channel-list-entry admin-channel-list-entry-title admin-channel-list-entry-item">
|
||||
<h3>Description</h3>
|
||||
</td>
|
||||
</tr>
|
||||
<% chanGuide.forEach((channel) => { %>
|
||||
<tr id="admin-channel-list-entry-<%- channel.name %>" class="admin-channel-list-entry">
|
||||
<td id="admin-channel-list-entry-img-<%- channel.name %>" class="admin-channel-list-entry admin-channel-list-entry-item admin-channel-list-entry-img-row">
|
||||
<a href="/c/<%- channel.name %>" class="admin-channel-list-entry admin-channel-list-entry-item">
|
||||
<img id="admin-channel-list-entry-img-<%- channel.name %>" class="admin-channel-list-entry admin-channel-list-entry-item" src="<%- channel.thumbnail %>">
|
||||
</a>
|
||||
</td>
|
||||
<td id="admin-channel-list-entry-name-<%- channel.name %>" class="admin-channel-list-entry admin-channel-list-entry-item admin-channel-list-entry-name-row">
|
||||
<a href="/c/<%- channel.name %>" class="admin-channel-list-entry admin-channel-list-entry-item">
|
||||
<%- channel.name %>
|
||||
</a>
|
||||
</td>
|
||||
<td id="admin-channel-list-entry-description-<%- channel.name %>" class="admin-channel-list-entry admin-channel-list-entry-item">
|
||||
<p><%- channel.description %></p>
|
||||
</td>
|
||||
</tr>
|
||||
<% }); %>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
<footer>
|
||||
<%- include('partial/scripts', {user}); %>
|
||||
<script src="js/adminPanel.js"></script>
|
||||
</footer>
|
||||
</html>
|
||||
101
src/views/channel.ejs
Normal file
101
src/views/channel.ejs
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<!--Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%- include('partial/styles', {instance, user}); %>
|
||||
<link rel="stylesheet" type="text/css" href="/css/channel.css">
|
||||
<title><%= instance %> - *DISCONNECTED*</title>
|
||||
</head>
|
||||
<body>
|
||||
<%- include('partial/navbar', {user}); %>
|
||||
<div class="channel" id="channel-flexbox">
|
||||
<div class="media-panel" id="media-panel-div">
|
||||
<div class="media-panel panel-head-div" id="media-panel-head-div">
|
||||
<i class="media-panel panel-head-element bi-caret-down-fill" id="media-panel-div-toggle-icon"></i>
|
||||
<p class="media-panel panel-head-element" id="media-panel-title-paragraph">Currently Playing: NULL</p>
|
||||
<span class="media-panel panel-head-spacer-span" id="media-panel-head-spacer-span"></span>
|
||||
<i class="media-panel panel-head-element bi-arrow-repeat" id="media-panel-sync-icon"></i>
|
||||
<i class="media-panel panel-head-element bi-aspect-ratio-fill" id="media-panel-aspect-lock-icon"></i>
|
||||
<i class="media-panel panel-head-element bi-film" id="media-panel-cinema-mode-icon"></i>
|
||||
<i class="media-panel panel-head-element bi-arrows-vertical" id="media-panel-flip-vertical-icon"></i>
|
||||
<i class="media-panel panel-head-element bi-arrows" id="media-panel-flip-horizontal-icon"></i>
|
||||
<i class="media-panel panel-head-element bi-arrow-clockwise" id="media-panel-reload-icon"></i>
|
||||
<i class="media-panel panel-head-element bi-chat-right-dots-fill" id="media-panel-show-chat-icon"></i>
|
||||
</div>
|
||||
<video src="/video/static.webm" class="media-panel" id="media-panel-video" muted loop autoplay></video>
|
||||
</div>
|
||||
<div class="chat-panel" id="chat-panel-div">
|
||||
<div class="drag-handle" id="chat-panel-drag-handle">
|
||||
</div>
|
||||
<div class="chat-panel panel-head-div" id="chat-panel-head-div">
|
||||
<i class="chat-panel panel-head-element bi-film" id="chat-panel-show-video-icon"></i>
|
||||
<i class="chat-panel panel-head-element bi-caret-down-fill" id="chat-panel-div-hide"></i>
|
||||
<select class="chat-panel panel-head-element" id="chat-panel-high-level-select">
|
||||
<option value="0">0</option>
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
<option value="4">4</option>
|
||||
<option value="5">5</option>
|
||||
<option value="6">6</option>
|
||||
<option value="7">7</option>
|
||||
<option value="8">8</option>
|
||||
<option value="9">9</option>
|
||||
<option value="10">10</option>
|
||||
</select>
|
||||
<p class="chat-panel panel-head-element" id="chat-panel-high-level-paragraph">/10</p>
|
||||
<select class="chat-panel panel-head-element" id="chat-panel-flair-select">
|
||||
<option>Flair</option>
|
||||
</select>
|
||||
<span class="chat-panel panel-head-spacer-span" id="chat-panel-head-spacer-span"></span>
|
||||
<p class="chat-panel panel-head-element" id="chat-panel-user-count">NULL Users</p>
|
||||
<i class="chat-panel panel-head-element bi-caret-down-fill" id="chat-panel-users-toggle"></i>
|
||||
</div>
|
||||
<div class="chat-panel" id="chat-panel-main-div">
|
||||
<div class="chat-panel" id="chat-panel-multipanel-div">
|
||||
</div>
|
||||
<div class="chat-panel" id="chat-area">
|
||||
<div class="chat-panel" id="chat-panel-buffer-div">
|
||||
</div>
|
||||
<div class="chat-panel" id="chat-panel-control-div">
|
||||
<i class="chat-panel chat-panel-control bi-gear-fill" id="chat-panel-settings-icon"></i>
|
||||
<i class="chat-panel chat-panel-control bi-magic" id="chat-panel-admin-icon"></i>
|
||||
<i class="chat-panel chat-panel-control bi-images" id="chat-panel-emote-icon"></i>
|
||||
<input class="chat-panel chat-panel-control" id="chat-panel-prompt" placeholder="Chat...">
|
||||
<button class="chat-panel chat-panel-control" id="chat-panel-send-button">Send</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-panel" id="chat-panel-users-div">
|
||||
<div class="drag-handle" id="chat-panel-users-drag-handle">
|
||||
</div>
|
||||
<div class="chat-panel" id="chat-panel-users-list-div">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<footer>
|
||||
<%- include('partial/scripts', {user}); %>
|
||||
<script src="/lib/socket.io/socket.io.min.js"></script>
|
||||
<script src="/js/channel/chat.js"></script>
|
||||
<script src="/js/channel/userlist.js"></script>
|
||||
<script src="/js/channel/player.js"></script>
|
||||
<script src="/js/channel/channel.js"></script>
|
||||
</footer>
|
||||
</html>
|
||||
37
src/views/channelSettings.ejs
Normal file
37
src/views/channelSettings.ejs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<!--Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%- include('partial/styles', {instance, user}); %>
|
||||
<link rel="stylesheet" type="text/css" href="/css/newChannel.css">
|
||||
<title><%= instance %> - Channel Settings: <%= channel.name %></title>
|
||||
</head>
|
||||
<body>
|
||||
<%- include('partial/navbar', {user}); %>
|
||||
<form action="javascript:">
|
||||
<span>
|
||||
<label>Hidden:</label>
|
||||
<input id="channel-hidden" type="checkbox" <% if(channel.settings.hidden){ %> checked <% } %>>
|
||||
</span>
|
||||
</form>
|
||||
<a href="javascript:" id="channel-delete">Delete Channel</a>
|
||||
<footer>
|
||||
<%- include('partial/scripts', {user}); %>
|
||||
<script src="/js/channelSettings.js"></script>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
41
src/views/index.ejs
Normal file
41
src/views/index.ejs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<!--Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%- include('partial/styles', {instance, user}); %>
|
||||
<link rel="stylesheet" type="text/css" href="css/index.css">
|
||||
<title><%= instance %></title>
|
||||
</head>
|
||||
<body>
|
||||
<%- include('partial/navbar', {user}); %>
|
||||
<h3><a href="/newchannel">Start a new channel...</a></h3>
|
||||
<div id="channel-guide-div" class="channel-guide">
|
||||
<% chanGuide.forEach((channel) => { %>
|
||||
<div id="channel-guide-entry-<%- channel.name %>" class="channel-guide-entry">
|
||||
<a href="/c/<%- channel.name %>" class="channel-guide-entry channel-guide-entry-item"><img id="channel-guide-entry-img-<%- channel.name %>" class="channel-guide-entry channel-guide-entry-item" src="<%- channel.thumbnail %>"></a>
|
||||
<h3 id="channel-guide-entry-name-<%- channel.name %>" class="channel-guide-entry channel-guide-entry-item"><a href="/c/<%- channel.name %>" class="channel-guide-entry channel-guide-entry-item"><%- channel.name %></a></h3>
|
||||
<span id="channel-guide-entry-description-span-<%- channel.name %>" class="channel-guide-entry channel-guide-entry-item">
|
||||
<p id="channel-guide-entry-description-<%- channel.name %>" class="channel-guide-entry channel-guide-entry-item"><%- channel.description %></h3>
|
||||
</span>
|
||||
</div>
|
||||
<% }); %>
|
||||
</div>
|
||||
</body>
|
||||
<footer>
|
||||
<%- include('partial/scripts', {user}); %>
|
||||
</footer>
|
||||
</html>
|
||||
38
src/views/newChannel.ejs
Normal file
38
src/views/newChannel.ejs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<!--Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%- include('partial/styles', {instance, user}); %>
|
||||
<link rel="stylesheet" type="text/css" href="/css/newChannel.css">
|
||||
<title><%= instance %> - New Channel</title>
|
||||
</head>
|
||||
<body>
|
||||
<%- include('partial/navbar', {user}); %>
|
||||
<form action="javascript:">
|
||||
<label>Channel Name:</label>
|
||||
<input id="register-channel-name" placeholder="Required">
|
||||
<label>Description:</label>
|
||||
<input id="register-description" placeholder="Required">
|
||||
<label>Thumbnail:</label>
|
||||
<input id="register-thumbnail" placeholder="Required">
|
||||
</form>
|
||||
</body>
|
||||
<footer>
|
||||
<%- include('partial/scripts', {user}); %>
|
||||
<script src="js/newChannel.js"></script>
|
||||
</footer>
|
||||
</html>
|
||||
27
src/views/partial/navbar.ejs
Normal file
27
src/views/partial/navbar.ejs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<!--Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.-->
|
||||
<div id="navbar">
|
||||
<p class="navbar-item" id="instance-title"><a href="/" class="navbar-item"><%= instance %></a></p>
|
||||
<span class="navbar-item" id="right-controls">
|
||||
<% if(user){ %>
|
||||
<p class="navbar-item">Welcome, <a class="navbar-item" href="/profile"><%= user.user %></a> - <a href="/adminPanel" title="Admin Panel" class="bi bi-server navbar-item"></a> <a class="navbar-item" href="javascript:" id="logout-button">logout</a></p>
|
||||
<% }else{ %>
|
||||
<input class="navbar-item login-prompt" id="username-prompt" placeholder="username">
|
||||
<input class="navbar-item login-prompt" id="password-prompt" placeholder="password" type="password">
|
||||
<p class="navbar-item"><a class="navbar-item" href="javascript:" id="login-button">Login</a> - <a class="navbar-item" href="/register">Register</a></p>
|
||||
<% } %>
|
||||
</span>
|
||||
</div>
|
||||
17
src/views/partial/scripts.ejs
Normal file
17
src/views/partial/scripts.ejs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<!--Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.-->
|
||||
<script src="/js/utils.js"></script>
|
||||
<script src="/js/navbar.js"></script>
|
||||
18
src/views/partial/styles.ejs
Normal file
18
src/views/partial/styles.ejs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<!--Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.-->
|
||||
<link rel="stylesheet" href="/lib/bootstrap-icons/font/bootstrap-icons.css">
|
||||
<link rel="stylesheet" type="text/css" href="/css/global.css">
|
||||
<link rel="stylesheet" type="text/css" href="/css/theme/movie-night.css">
|
||||
83
src/views/profile.ejs
Normal file
83
src/views/profile.ejs
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<!--Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%- include('partial/styles', {instance, user}); %>
|
||||
<% var selfProfile = user ? profile ? profile.user == user.user : false : false %>
|
||||
<link rel="stylesheet" type="text/css" href="/css/profile.css">
|
||||
<% if(profile){ %>
|
||||
<title><%= instance %> - Profile: <%= profile.user %></title>
|
||||
<% } else { %>
|
||||
<title><%= instance %> - Profile: Logged Out</title>
|
||||
<% } %>
|
||||
</head>
|
||||
<body>
|
||||
<%- include('partial/navbar', {user}); %>
|
||||
<% if(profile){ %>
|
||||
<div class="profile" id="profile-div">
|
||||
<h1 class="profile-item" id="profile-username"><%= profile.user %></h1>
|
||||
<img class="profile-item" id="profile-img" src="<%= profile.img %>">
|
||||
<% if(selfProfile){ %>
|
||||
<p class="profile-item-edit">(<a class="profile-item-edit" id="profile-img-edit" href="javascript:">edit</a>)</p>
|
||||
<% } %>
|
||||
<p class="profile-item" id="profile-tokes">tokes: <%= profile.tokes %> (Not yet implemented)</p>
|
||||
|
||||
<span class="profile-item" id="profile-signature">
|
||||
<p class="profile-item profile-item-label" id="profile-signature-label">Signature: <span class="profile-content" id="profile-signature-content"><%= profile.signature %></span></p>
|
||||
<% if(selfProfile){ %>
|
||||
<p class="profile-item-edit">(<a class="profile-item-edit" id="profile-signature-edit" href="javascript:">edit</a>)</p>
|
||||
<% } %>
|
||||
</span>
|
||||
|
||||
<span class="profile-item" id="profile-bio">
|
||||
<p class="profile-item profile-item-label" id="profile-bio-label">Bio: <span class="profile-content" id="profile-bio-content"><%= profile.bio %></span></p>
|
||||
<% if(selfProfile){ %>
|
||||
<p class="profile-item-edit">(<a class="profile-item-edit" id="profile-bio-edit" href="javascript:">edit</a>)</p>
|
||||
<% } %>
|
||||
</span>
|
||||
|
||||
<p class="profile-item" id="profile-creation-date">Joined: <%= profile.date %></p>
|
||||
<div class="profile-item" id="profile-badge-shelf">
|
||||
<h3 class="profile-item" id="no-badge-label">Badgeless?</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if(selfProfile){ %>
|
||||
<div class="account-settings" id="account-settings-div">
|
||||
<h3 class="account-settings" id="account-settings-label">Account Settings</h3>
|
||||
<span class="account-settings-password-reset" id="account-settings-password-reset-div">
|
||||
<h4 class="account-settings-password-reset" id="account-settings-password-reset-label">Password Reset:</h4>
|
||||
<input class="account-settings-password-reset" id="account-settings-password-reset-old" placeholder="Current Password" type="password">
|
||||
<input class="account-settings-password-reset" id="account-settings-password-reset-new" placeholder="New Password" type="password">
|
||||
<input class="account-settings-password-reset" id="account-settings-password-reset-confirm" placeholder="Confirm New Password" type="password">
|
||||
</span>
|
||||
<span class="account-settings" id="account-settings-delete">
|
||||
<a href="javascript:" class="account-settings" id="account-settings-delete-link">Delete Account</a>
|
||||
</span>
|
||||
</div>
|
||||
<% } %>
|
||||
<% }else if(user){ %>
|
||||
<h1 class="profile-item" id="profile-error-label">Profile not found!</h1>
|
||||
<% } else {%>
|
||||
<h1 class="profile-item" id="profile-error-label">Please login to view your profile!</h1>
|
||||
<% } %>
|
||||
</body>
|
||||
<footer>
|
||||
<%- include('partial/scripts', {user}); %>
|
||||
<script src="/js/profile.js"></script>
|
||||
</footer>
|
||||
</html>
|
||||
41
src/views/register.ejs
Normal file
41
src/views/register.ejs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<!--Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.-->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%- include('partial/styles', {instance, user}); %>
|
||||
<link rel="stylesheet" type="text/css" href="/css/register.css">
|
||||
<title><%= instance %> - Account Registration</title>
|
||||
</head>
|
||||
<body>
|
||||
<%- include('partial/navbar', {user}); %>
|
||||
<form action="javascript:">
|
||||
<label>Username:</label>
|
||||
<input id="register-username" placeholder="Required">
|
||||
<label>Password:</label>
|
||||
<input id="register-password" placeholder="Required" type="password">
|
||||
<label>Confirm Password:</label>
|
||||
<input id="register-password-confirm" placeholder="Required" type="password">
|
||||
<label>Account Recovery Email:</label>
|
||||
<input id="register-email" placeholder="Optional">
|
||||
</form>
|
||||
</body>
|
||||
<footer>
|
||||
<%- include('partial/scripts', {user}); %>
|
||||
<script src="js/register.js"></script>
|
||||
</footer>
|
||||
</html>
|
||||
1
state.json
Normal file
1
state.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"uuid":"76e8b3ab-1c1c-49a2-af14-7d70288aebcc","telemetry":false}
|
||||
47
www/css/adminPanel.css
Normal file
47
www/css/adminPanel.css
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
#admin-channel-list-div{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 0 30%;
|
||||
}
|
||||
|
||||
|
||||
#admin-channel-list-table{
|
||||
border-spacing: 0px;
|
||||
}
|
||||
|
||||
td.admin-channel-list-entry{
|
||||
padding: 0 1em;
|
||||
}
|
||||
|
||||
|
||||
.admin-channel-list-entry-title{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.admin-channel-list-entry-img-row{
|
||||
width: 1.5em;
|
||||
}
|
||||
|
||||
img.admin-channel-list-entry-item{
|
||||
height: 2em;
|
||||
}
|
||||
|
||||
.admin-channel-list-entry-name-row{
|
||||
width: 15%;
|
||||
}
|
||||
213
www/css/channel.css
Normal file
213
www/css/channel.css
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
div#channel-flexbox{
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
div.panel-head-div{
|
||||
height: 1.2em;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.panel-head-element{
|
||||
margin: 0 0.2em 0 0.2em;
|
||||
}
|
||||
|
||||
i.panel-head-element{
|
||||
height: 1.2em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
span.panel-head-spacer-span{
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
div#media-panel-div{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#media-panel-head-div{
|
||||
position: absolute;
|
||||
height: 3em;
|
||||
right: 0;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
video#media-panel-video{
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
#media-panel-sync-button{
|
||||
height: 1.5em;
|
||||
}
|
||||
|
||||
#media-panel-title-paragraph{
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
div#chat-panel-div{
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height:100%;
|
||||
}
|
||||
|
||||
div#chat-panel-main-div{
|
||||
display: flex;
|
||||
flex: 1;
|
||||
height: 1%;
|
||||
}
|
||||
|
||||
.drag-handle{
|
||||
position: absolute;
|
||||
cursor: ew-resize;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 0.4em;
|
||||
}
|
||||
|
||||
#chat-panel-multipanel-div{
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#chat-panel-buffer-div{
|
||||
height: 100%;
|
||||
flex: 1;
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
#chat-panel-users-div{
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
#chat-area{
|
||||
height: 100%;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
div#chat-panel-control-div{
|
||||
height: 2em;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin: 0.5em;
|
||||
}
|
||||
|
||||
i.chat-panel-control{
|
||||
height: 1em;
|
||||
margin: auto;
|
||||
margin-left: 0.5em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#chat-panel-settings-icon{
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
#chat-panel-prompt{
|
||||
margin-left: 0.5em;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
p#chat-panel-high-level-paragraph{
|
||||
margin: auto;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
p.panel-head-element{
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
#chat-panel-flair-select{
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
input#chat-panel-prompt{
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
#chat-panel-send-button{
|
||||
margin: auto;
|
||||
margin-right: 1em;
|
||||
margin-left: 0.5em;
|
||||
height: 1.5em;
|
||||
}
|
||||
|
||||
.chat-entry{
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.chat-entry-username{
|
||||
margin: 0.2em;
|
||||
}
|
||||
|
||||
.chat-entry-body{
|
||||
margin: 0.2em;
|
||||
}
|
||||
|
||||
.chat-entry-high-level{
|
||||
margin: 0.2em;
|
||||
z-index: 2;
|
||||
background-image: url("/img/sweet_leaf_simple.png");
|
||||
background-size: 1.3em;
|
||||
background-repeat: no-repeat;
|
||||
background-position-x: center;
|
||||
background-position-y: top;
|
||||
width: 1.5em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.chat-entry-high-level-img{
|
||||
position: absolute;
|
||||
height: 1.7em;
|
||||
}
|
||||
|
||||
.user-entry{
|
||||
margin: 0.2em;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
#media-panel-aspect-lock-icon{
|
||||
display: none;
|
||||
}
|
||||
|
||||
#chat-panel-user-count{
|
||||
white-space: nowrap;
|
||||
user-select: none;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
#media-panel-show-chat-icon{
|
||||
display: none;
|
||||
}
|
||||
|
||||
#chat-panel-show-video-icon{
|
||||
display: none;
|
||||
}
|
||||
51
www/css/global.css
Normal file
51
www/css/global.css
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
html{
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body{
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
}
|
||||
|
||||
#navbar{
|
||||
display: flex;
|
||||
padding: 0.5em;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.navbar-item{
|
||||
display: inline;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#instance-title{
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
p.navbar-item, input.navbar-item{
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.navbar-item input{
|
||||
padding: 0.2em;
|
||||
}
|
||||
60
www/css/index.css
Normal file
60
www/css/index.css
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
@media (orientation: landscape){
|
||||
#channel-guide-div{
|
||||
max-width: 100vh;
|
||||
}
|
||||
}
|
||||
|
||||
@media (orientation: portrait){
|
||||
#channel-guide-div{
|
||||
max-width: 80vw;
|
||||
}
|
||||
}
|
||||
|
||||
#channel-guide-div{
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(11em, 1fr));
|
||||
margin: 0 auto 0 auto;
|
||||
}
|
||||
|
||||
div.channel-guide-entry{
|
||||
overflow: hidden;
|
||||
width: 10em;
|
||||
margin: 0.5em;
|
||||
}
|
||||
|
||||
.channel-guide-entry{
|
||||
margin: 0.5em auto 0.5em auto;
|
||||
padding: 0.2em;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.channel-guide-entry-item{
|
||||
margin: 0.1em auto 0.1em auto;
|
||||
}
|
||||
|
||||
span.channel-guide-entry-item{
|
||||
overflow: scroll;
|
||||
height: 2em;
|
||||
}
|
||||
|
||||
p.channel-guide-entry{
|
||||
font-size: 0.8em;
|
||||
margin-left: 0;
|
||||
}
|
||||
25
www/css/newChannel.css
Normal file
25
www/css/newChannel.css
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
form{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 5% 17%;
|
||||
}
|
||||
|
||||
input{
|
||||
margin: 0 0 2em;
|
||||
}
|
||||
43
www/css/profile.css
Normal file
43
www/css/profile.css
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
p.profile-item-edit{
|
||||
display: inline;
|
||||
}
|
||||
|
||||
span.profile-item{
|
||||
display: block;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
p.profile-item-label{
|
||||
display: inline;
|
||||
}
|
||||
|
||||
span.account-settings{
|
||||
display: block;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
input.account-settings-password-reset{
|
||||
display: block;
|
||||
}
|
||||
|
||||
a#account-settings-delete-link{
|
||||
font-weight: bold;
|
||||
}
|
||||
24
www/css/register.css
Normal file
24
www/css/register.css
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
form{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 5% 17%;
|
||||
}
|
||||
|
||||
input{
|
||||
margin: 0 0 2em;
|
||||
}
|
||||
245
www/css/theme/movie-night.css
Normal file
245
www/css/theme/movie-night.css
Normal file
|
|
@ -0,0 +1,245 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
:root{
|
||||
--main-font: "open-sans", sans-serif;
|
||||
--bg0: rgb(158, 158, 158);
|
||||
--bg1: rgb(70, 70, 70);
|
||||
--bg2: rgb(220, 220, 220);
|
||||
--bg1-alt0: rgb(30, 30, 30);
|
||||
--bg2-alt0: rgb(200, 200, 200);
|
||||
--bg2-alt1: rgb(180, 180, 180);
|
||||
|
||||
--accent0: rgb(48, 47, 47);
|
||||
--accent0-alt0: rgb(34, 34, 34);
|
||||
--accent0-warning: firebrick;
|
||||
--accent1: rgb(245, 245, 245);
|
||||
--accent1-alt0: rgb(185, 185, 185);
|
||||
--accent2: var(--accent0-alt0);
|
||||
|
||||
--focus0: rgb(51, 153, 51);
|
||||
|
||||
--userlist-color0:rgb(87, 145, 97);
|
||||
--userlist-color1:rgb(143, 46, 26);
|
||||
--userlist-color2:rgb(51, 101, 161);
|
||||
--userlist-color3:rgb(110, 94, 13);
|
||||
--userlist-color4:rgb(129, 43, 43);
|
||||
--userlist-color5:rgb(150, 64, 6);
|
||||
--userlist-color6:rgb(111, 61, 204);
|
||||
|
||||
--media-header-gradient: linear-gradient(180deg, var(--bg1-alt0) 0%, #FFFFFF00 76%);
|
||||
}
|
||||
|
||||
body{
|
||||
background-color: var(--bg0);
|
||||
font-family: var(--main-font);
|
||||
color: var(--accent0);
|
||||
}
|
||||
|
||||
a{
|
||||
text-decoration: none;
|
||||
color: var(--accent0);
|
||||
}
|
||||
|
||||
select{
|
||||
background-color: var(--bg2);
|
||||
border-radius: 0.5em;
|
||||
border: none;
|
||||
}
|
||||
|
||||
button{
|
||||
border-radius: 0.5em;
|
||||
}
|
||||
|
||||
a:hover{
|
||||
color: var(--accent0-alt0);
|
||||
}
|
||||
|
||||
button{
|
||||
background-color: var(--bg0);
|
||||
color: var(--accent0);
|
||||
border: none;
|
||||
}
|
||||
|
||||
#navbar{
|
||||
background-color: var(--bg1);
|
||||
}
|
||||
|
||||
.navbar-item{
|
||||
color: var(--accent1);
|
||||
border: hidden;
|
||||
}
|
||||
|
||||
a:hover.navbar-item{
|
||||
color: var(--accent1-alt0);
|
||||
}
|
||||
|
||||
.navbar-item input{
|
||||
background-color: var(--bg1-alt0);
|
||||
}
|
||||
|
||||
.channel-guide-entry{
|
||||
background-color: var(--bg1);
|
||||
color: var(--accent1);
|
||||
}
|
||||
|
||||
div.channel-guide-entry{
|
||||
border-radius: 0.3em;
|
||||
box-shadow: 0.2em 0.2em 0.1em var(--bg1-alt0) inset;
|
||||
}
|
||||
|
||||
a.channel-guide-entry-item{
|
||||
color: var(--accent1);
|
||||
}
|
||||
|
||||
a:hover.channel-guide-entry-item{
|
||||
color: var(--accent1-alt0);
|
||||
}
|
||||
|
||||
span.channel-guide-entry-item{
|
||||
background-color: var(--bg1-alt0);
|
||||
box-shadow: 0.2em 0.2em 0.1em black inset;
|
||||
border-radius: 0.3em;
|
||||
margin: 0 0.1em 0 0.1em;
|
||||
}
|
||||
|
||||
|
||||
p.channel-guide-entry-item{
|
||||
background-color: var(--bg1-alt0);
|
||||
}
|
||||
|
||||
a#account-settings-delete-link{
|
||||
color: var(--accent0-warning);
|
||||
}
|
||||
|
||||
#channel-delete{
|
||||
color: var(--accent0-warning);
|
||||
}
|
||||
|
||||
#admin-channel-list-table{
|
||||
background-color: var(--bg1);
|
||||
color: var(--accent1);
|
||||
}
|
||||
|
||||
tr.admin-channel-list-entry{
|
||||
box-shadow: var(--accent1) 0px 1em 1px -1em, var(--accent1) 0px -1em 1px -1em;
|
||||
}
|
||||
|
||||
td.admin-channel-list-entry-name-row{
|
||||
box-shadow: var(--accent1) 1em 0px 1px -1em, var(--accent1) -1em 0px 1px -1em;
|
||||
}
|
||||
|
||||
a.admin-channel-list-entry-item{
|
||||
color: var(--accent1);
|
||||
}
|
||||
|
||||
a:hover.admin-channel-list-entry-item{
|
||||
color: var(--accent1-alt0);
|
||||
}
|
||||
|
||||
#media-panel-div{
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
#chat-panel-buffer-div{
|
||||
background-color: var(--bg2);
|
||||
}
|
||||
|
||||
#chat-panel-control-div{
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
#chat-panel-control-div:focus-within{
|
||||
box-shadow: 2px 2px 3px var(--focus0), -2px 2px 3px var(--focus0), 2px -2px 3px var(--focus0), -2px -2px 3px var(--focus0);
|
||||
}
|
||||
|
||||
#chat-area{
|
||||
background-color: var(--bg2);
|
||||
}
|
||||
|
||||
div#chat-panel-control-div{
|
||||
border-radius: 1em;
|
||||
}
|
||||
|
||||
#chat-panel-prompt{
|
||||
border: none;
|
||||
}
|
||||
|
||||
#chat-panel-prompt:focus{
|
||||
border: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.chat-entry{
|
||||
background-color: var(--bg2);
|
||||
border-bottom: 1px solid var(--bg2-alt1);
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.userlist-color0{/*green0*/
|
||||
color: var(--userlist-color0);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color1{/*red0*/
|
||||
color: var(--userlist-color1);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color2{/*blue0*/
|
||||
color: var(--userlist-color2);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color3{/*tan0*/
|
||||
color: var(--userlist-color3);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color4{/*pink0*/
|
||||
color: var(--userlist-color4);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color5{/*orange*/
|
||||
color: var(--userlist-color5);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color6{/*violet*/
|
||||
color: var(--userlist-color6);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.chat-entry-high-level{
|
||||
text-shadow: 1px 1px 1px white, -1px -1px 1px white, 1px 1px 1px white, -1px 1px 1px white, 1px -1px 1px white;
|
||||
}
|
||||
|
||||
#media-panel-head-div{
|
||||
background: rgb(2,0,36);
|
||||
background: var(--media-header-gradient);
|
||||
color: var(--accent1-alt0);
|
||||
}
|
||||
|
||||
#chat-panel-send-button{
|
||||
background-color: var(--focus0);
|
||||
color: white;
|
||||
}
|
||||
|
||||
select.panel-head-element{
|
||||
height: 1.2em;
|
||||
margin: auto;
|
||||
}
|
||||
190
www/css/theme/the_network_classic.css
Normal file
190
www/css/theme/the_network_classic.css
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
:root{
|
||||
--main-font: "open-sans", sans-serif;
|
||||
--bg0: rgb(158, 158, 158);
|
||||
--bg1: rgb(70, 70, 70);
|
||||
--bg2: rgb(220, 220, 220);
|
||||
--bg1-alt0: rgb(30, 30, 30);
|
||||
--bg2-alt0: rgb(200, 200, 200);
|
||||
--bg2-alt1: rgb(180, 180, 180);
|
||||
|
||||
--accent0: rgb(48, 47, 47);
|
||||
--accent0-alt0: rgb(34, 34, 34);
|
||||
--accent0-warning: firebrick;
|
||||
--accent1: rgb(245, 245, 245);
|
||||
--accent1-alt0: rgb(185, 185, 185);
|
||||
--accent2: var(--accent0-alt0);
|
||||
|
||||
|
||||
--userlist-color0:rgb(122, 199, 135);
|
||||
--userlist-color1:rgb(242, 104, 77);
|
||||
--userlist-color2:rgb(77, 150, 239);
|
||||
--userlist-color3:rgb(247, 241, 212);
|
||||
--userlist-color4:rgb(255, 173, 173);
|
||||
--userlist-color5:rgb(254, 151, 82);
|
||||
--userlist-color6:rgb(209, 167, 246);
|
||||
}
|
||||
|
||||
body{
|
||||
background-color: var(--bg0);
|
||||
font-family: var(--main-font);
|
||||
color: var(--accent0);
|
||||
}
|
||||
|
||||
a{
|
||||
text-decoration: none;
|
||||
color: var(--accent0);
|
||||
}
|
||||
|
||||
a:hover{
|
||||
color: var(--accent0-alt0);
|
||||
}
|
||||
|
||||
#navbar{
|
||||
background-color: var(--bg1);
|
||||
}
|
||||
|
||||
.navbar-item{
|
||||
color: var(--accent1);
|
||||
border: hidden;
|
||||
}
|
||||
|
||||
a:hover.navbar-item{
|
||||
color: var(--accent1-alt0);
|
||||
}
|
||||
|
||||
.navbar-item input{
|
||||
background-color: var(--bg1-alt0);
|
||||
}
|
||||
|
||||
.channel-guide-entry{
|
||||
background-color: var(--bg1);
|
||||
color: var(--accent1);
|
||||
}
|
||||
|
||||
div.channel-guide-entry{
|
||||
border-radius: 0.3em;
|
||||
box-shadow: 0.2em 0.2em 0.1em var(--bg1-alt0) inset;
|
||||
}
|
||||
|
||||
a.channel-guide-entry-item{
|
||||
color: var(--accent1);
|
||||
}
|
||||
|
||||
a:hover.channel-guide-entry-item{
|
||||
color: var(--accent1-alt0);
|
||||
}
|
||||
|
||||
span.channel-guide-entry-item{
|
||||
background-color: var(--bg1-alt0);
|
||||
box-shadow: 0.2em 0.2em 0.1em black inset;
|
||||
border-radius: 0.3em;
|
||||
margin: 0 0.1em 0 0.1em;
|
||||
}
|
||||
|
||||
|
||||
p.channel-guide-entry-item{
|
||||
background-color: var(--bg1-alt0);
|
||||
}
|
||||
|
||||
a#account-settings-delete-link{
|
||||
color: var(--accent0-warning);
|
||||
}
|
||||
|
||||
#channel-delete{
|
||||
color: var(--accent0-warning);
|
||||
}
|
||||
|
||||
#admin-channel-list-table{
|
||||
background-color: var(--bg1);
|
||||
color: var(--accent1);
|
||||
}
|
||||
|
||||
tr.admin-channel-list-entry{
|
||||
box-shadow: var(--accent1) 0px 1em 1px -1em, var(--accent1) 0px -1em 1px -1em;
|
||||
}
|
||||
|
||||
td.admin-channel-list-entry-name-row{
|
||||
box-shadow: var(--accent1) 1em 0px 1px -1em, var(--accent1) -1em 0px 1px -1em;
|
||||
}
|
||||
|
||||
a.admin-channel-list-entry-item{
|
||||
color: var(--accent1);
|
||||
}
|
||||
|
||||
a:hover.admin-channel-list-entry-item{
|
||||
color: var(--accent1-alt0);
|
||||
}
|
||||
|
||||
#media-panel-div{
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
#chat-panel-buffer-div{
|
||||
background-color: var(--bg2);
|
||||
}
|
||||
|
||||
.chat-entry{
|
||||
display: flex;
|
||||
background-color: var(--bg2);
|
||||
border-bottom: 1px solid var(--bg2-alt1);
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.chat-entry-username{
|
||||
margin: 0.2em;
|
||||
}
|
||||
|
||||
.chat-entry-body{
|
||||
margin: 0.2em;
|
||||
}
|
||||
|
||||
.userlist-color0{/*green0*/
|
||||
color: var(--userlist-color0);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color1{/*red0*/
|
||||
color: var(--userlist-color1);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color2{/*blue0*/
|
||||
color: var(--userlist-color2);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color3{/*tan0*/
|
||||
color: var(--userlist-color3);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color4{/*pink0*/
|
||||
color: var(--userlist-color4);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color5{/*orange*/
|
||||
color: var(--userlist-color5);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color6{/*violet*/
|
||||
color: var(--userlist-color6);
|
||||
text-shadow: none;
|
||||
}
|
||||
BIN
www/img/frst.jpg
Normal file
BIN
www/img/frst.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.2 MiB |
BIN
www/img/frstdusk.png
Normal file
BIN
www/img/frstdusk.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 MiB |
BIN
www/img/johnny.png
Normal file
BIN
www/img/johnny.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
www/img/sweet_leaf_simple.png
Normal file
BIN
www/img/sweet_leaf_simple.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
47
www/js/channel/channel.js
Normal file
47
www/js/channel/channel.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
class channel{
|
||||
constructor(){
|
||||
//Establish connetion to the server via socket.io
|
||||
this.connect();
|
||||
//Define socket listeners
|
||||
this.defineListeners();
|
||||
|
||||
//Scrape channel name off URL
|
||||
this.channelName = window.location.pathname.split('/c/')[`1`];
|
||||
|
||||
//Create the Video Player Object
|
||||
this.player = new player(this);
|
||||
//Create the Chat Box Object
|
||||
this.chatBox = new chatBox(this);
|
||||
//Create the User List Object
|
||||
this.userList = new userList(this);
|
||||
}
|
||||
|
||||
connect(){
|
||||
this.socket = io();
|
||||
}
|
||||
|
||||
defineListeners(){
|
||||
//This function should serve mostly to glue functions from channel and it's children to it's socket's listeners.
|
||||
this.socket.on("connect", () => {
|
||||
document.title = `${this.channelName} - Connected`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const client = new channel();
|
||||
149
www/js/channel/chat.js
Normal file
149
www/js/channel/chat.js
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
class chatBox{
|
||||
constructor(client){
|
||||
//Client Object
|
||||
this.client = client
|
||||
|
||||
//Booleans
|
||||
this.aspectLock = true;
|
||||
|
||||
//clickDragger object
|
||||
this.clickDragger = new canopyUXUtils.clickDragger("#chat-panel-drag-handle", "#chat-panel-div", "#chat-panel-user-count");
|
||||
|
||||
//Element Nodes
|
||||
this.chatPanel = document.querySelector("#chat-panel-div");
|
||||
this.chatBuffer = document.querySelector("#chat-panel-buffer-div");
|
||||
this.chatPrompt = document.querySelector("#chat-panel-prompt");
|
||||
this.sendButton = document.querySelector("#chat-panel-send-button");
|
||||
this.highLevel = document.querySelector("#chat-panel-high-level-select");
|
||||
//Seems weird to stick this in here, but the split is dictated by chat width :P
|
||||
this.aspectLockIcon = document.querySelector("#media-panel-aspect-lock-icon");
|
||||
this.hideChatIcon = document.querySelector("#chat-panel-div-hide");
|
||||
this.showChatIcon = document.querySelector("#media-panel-show-chat-icon");
|
||||
|
||||
//Setup functions
|
||||
this.setupInput();
|
||||
this.defineListeners();
|
||||
this.sizeToAspect();
|
||||
}
|
||||
|
||||
setupInput(){
|
||||
//Chat bar
|
||||
this.chatPrompt.addEventListener("keydown", this.send.bind(this));
|
||||
this.sendButton.addEventListener("click", this.send.bind(this));
|
||||
|
||||
//Header icons
|
||||
this.aspectLockIcon.addEventListener("click", this.lockAspect.bind(this));
|
||||
this.showChatIcon.addEventListener("click", ()=>{this.toggleUI()});
|
||||
this.hideChatIcon.addEventListener("click", ()=>{this.toggleUI()});
|
||||
|
||||
//Clickdragger/Resize
|
||||
this.clickDragger.handle.addEventListener("mousedown", this.unlockAspect.bind(this));
|
||||
window.addEventListener("resize", this.resizeAspect.bind(this));
|
||||
}
|
||||
|
||||
defineListeners(){
|
||||
this.client.socket.on("chat-message", (data) => {
|
||||
this.displayChat(data);
|
||||
});
|
||||
}
|
||||
|
||||
lockAspect(event){
|
||||
//prevent the user from breaking shit :P
|
||||
if(this.chatPanel.style.display != "none"){
|
||||
this.aspectLock = true;
|
||||
this.aspectLockIcon.style.display = "none";
|
||||
this.sizeToAspect();
|
||||
}
|
||||
}
|
||||
|
||||
unlockAspect(event){
|
||||
this.aspectLock = false;
|
||||
this.aspectLockIcon.style.display = "inline";
|
||||
}
|
||||
|
||||
resizeAspect(event){
|
||||
if(this.aspectLock){
|
||||
this.sizeToAspect();
|
||||
}
|
||||
}
|
||||
|
||||
sizeToAspect(){
|
||||
if(this.chatPanel.style.display != "none"){
|
||||
var targetVidWidth = this.client.player.getRatio() * this.chatPanel.getBoundingClientRect().height;
|
||||
|
||||
this.chatPanel.style.width = `${(document.body.getBoundingClientRect().width - targetVidWidth)}px`;
|
||||
|
||||
//Fix busted layout
|
||||
var pageBreak = document.body.scrollWidth - document.body.getBoundingClientRect().width;
|
||||
this.chatPanel.style.width = `${this.chatPanel.getBoundingClientRect().width + pageBreak}px`;
|
||||
}
|
||||
}
|
||||
|
||||
toggleUI(show = this.chatPanel.style.display == "none"){
|
||||
if(show){
|
||||
this.chatPanel.style.display = "flex";
|
||||
this.showChatIcon.style.display = "none";
|
||||
this.client.player.hideVideoIcon.style.display = "flex";
|
||||
}else{
|
||||
this.chatPanel.style.display = "none";
|
||||
this.showChatIcon.style.display = "flex";
|
||||
this.client.player.hideVideoIcon.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
displayChat(chat){
|
||||
//Create chat-entry span
|
||||
var chatEntry = document.createElement('span');
|
||||
chatEntry.classList.add("chat-panel-buffer","chat-entry",`chat-entry-${chat.user}`);
|
||||
|
||||
//Create high-level label
|
||||
var highLevel = document.createElement('p');
|
||||
highLevel.classList.add("chat-panel-buffer","chat-entry-high-level");
|
||||
highLevel.innerHTML = `${chat.high}`;
|
||||
chatEntry.appendChild(highLevel);
|
||||
|
||||
//Create username label
|
||||
var userLabel = document.createElement('p');
|
||||
userLabel.classList.add("chat-panel-buffer","chat-entry-username");
|
||||
|
||||
//Create color span
|
||||
var colorSpan = document.createElement('span');
|
||||
colorSpan.classList.add(this.client.userList.colorMap.get(chat.user));
|
||||
colorSpan.innerHTML = `${chat.user}`;
|
||||
userLabel.innerHTML = `${colorSpan.outerHTML}: `;
|
||||
|
||||
chatEntry.appendChild(userLabel);
|
||||
|
||||
//Create chat body
|
||||
var chatBody = document.createElement('p');
|
||||
chatBody.classList.add("chat-panel-buffer","chat-entry-body");
|
||||
chatBody.innerHTML = chat.msg;
|
||||
chatEntry.appendChild(chatBody);
|
||||
|
||||
this.chatBuffer.appendChild(chatEntry);
|
||||
}
|
||||
|
||||
async send(event){
|
||||
if((!event || !event.key || event.key == "Enter") && this.chatPrompt.value){
|
||||
this.client.socket.emit("chat-message",{msg: this.chatPrompt.value, high: this.highLevel.value});
|
||||
this.chatPrompt.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
97
www/js/channel/player.js
Normal file
97
www/js/channel/player.js
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
class player{
|
||||
constructor (client){
|
||||
//client obj
|
||||
this.client = client;
|
||||
|
||||
//booleans
|
||||
this.onUI = false;
|
||||
|
||||
//timers
|
||||
this.uiTimer = setTimeout(this.toggleUI.bind(this), 1500, false);
|
||||
|
||||
//elements
|
||||
this.playerDiv = document.querySelector("#media-panel-div");
|
||||
this.navBar = document.querySelector("#navbar");
|
||||
this.video = document.querySelector("#media-panel-video");
|
||||
this.uiBar = document.querySelector("#media-panel-head-div");
|
||||
this.showVideoIcon = document.querySelector("#chat-panel-show-video-icon");
|
||||
this.hideVideoIcon = document.querySelector("#media-panel-div-toggle-icon");
|
||||
this.cinemaModeIcon = document.querySelector("#media-panel-cinema-mode-icon");
|
||||
|
||||
//run setup functions
|
||||
this.setupInput();
|
||||
}
|
||||
|
||||
setupInput(){
|
||||
//UIBar Movement Detection
|
||||
this.playerDiv.addEventListener("mousemove", this.popUI.bind(this));
|
||||
this.uiBar.addEventListener("mouseenter", ()=>{this.setOnUI(true)});
|
||||
this.uiBar.addEventListener("mouseleave", ()=>{this.setOnUI(false)});
|
||||
|
||||
//UIBar/header icons
|
||||
this.showVideoIcon.addEventListener("click", ()=>{this.toggleVideo()});
|
||||
this.hideVideoIcon.addEventListener("click", ()=>{this.toggleVideo()});
|
||||
this.cinemaModeIcon.addEventListener("click", ()=>{this.toggleCinemaMode()});
|
||||
}
|
||||
|
||||
popUI(event){
|
||||
this.toggleUI(true);
|
||||
clearTimeout(this.uiTimer);
|
||||
if(!this.onUI){
|
||||
this.uiTimer = setTimeout(this.toggleUI.bind(this), 1500, false);
|
||||
}
|
||||
}
|
||||
|
||||
toggleUI(show = this.uiBar.style.display == "none"){
|
||||
this.uiBar.style.display = show ? "flex" : "none";
|
||||
}
|
||||
|
||||
toggleVideo(show = this.playerDiv.style.display == "none"){
|
||||
if(show){
|
||||
this.playerDiv.style.display = "flex";
|
||||
this.showVideoIcon.style.display = "none";
|
||||
this.client.chatBox.hideChatIcon.style.display = "flex";
|
||||
//Lock the chat to aspect ratio of the video, to make sure the chat width isn't breaking shit
|
||||
this.client.chatBox.lockAspect();
|
||||
}else{
|
||||
this.playerDiv.style.display = "none";
|
||||
this.showVideoIcon.style.display = "flex";
|
||||
this.client.chatBox.hideChatIcon.style.display = "none";
|
||||
//Need to clear the width from the split, or else it doesn't display properly
|
||||
this.client.chatBox.chatPanel.style.width = "100%";
|
||||
}
|
||||
}
|
||||
|
||||
toggleCinemaMode(cinema = this.navBar.style.display == "none"){
|
||||
if(cinema){
|
||||
this.navBar.style.display = "flex";
|
||||
}else{
|
||||
this.navBar.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
setOnUI(onUI){
|
||||
this.onUI = onUI;
|
||||
this.popUI();
|
||||
}
|
||||
|
||||
getRatio(){
|
||||
return this.video.videoWidth / this.video.videoHeight;
|
||||
}
|
||||
}
|
||||
107
www/js/channel/userlist.js
Normal file
107
www/js/channel/userlist.js
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
class userList{
|
||||
constructor(client){
|
||||
//Client object
|
||||
this.client = client
|
||||
|
||||
//Click Dragger Object
|
||||
this.clickDragger = new canopyUXUtils.clickDragger("#chat-panel-users-drag-handle", "#chat-panel-users-div");
|
||||
|
||||
//Strings
|
||||
this.userColors = [
|
||||
"userlist-color0",
|
||||
"userlist-color1",
|
||||
"userlist-color2",
|
||||
"userlist-color3",
|
||||
"userlist-color4",
|
||||
"userlist-color5",
|
||||
"userlist-color6"];
|
||||
|
||||
//Maps
|
||||
this.colorMap = new Map();
|
||||
|
||||
//Element Nodes
|
||||
this.userDiv = document.querySelector("#chat-panel-users-div");
|
||||
this.userList = document.querySelector("#chat-panel-users-list-div");
|
||||
this.userCount = document.querySelector("#chat-panel-user-count");
|
||||
this.toggleIcon = document.querySelector("#chat-panel-users-toggle");
|
||||
|
||||
//Call setup functions
|
||||
this.setupInput();
|
||||
this.defineListeners();
|
||||
}
|
||||
|
||||
//Setup functions
|
||||
setupInput(){
|
||||
this.toggleIcon.addEventListener("click", ()=>{this.toggleUI()});
|
||||
this.userCount.addEventListener("click", ()=>{this.toggleUI()});
|
||||
}
|
||||
|
||||
defineListeners(){
|
||||
this.client.socket.on('user-list', (data) => {
|
||||
this.updateList(data);
|
||||
});
|
||||
}
|
||||
|
||||
updateList(list){
|
||||
//Clear list and set user count
|
||||
this.userCount.textContent = list.length == 1 ? '1 User' : `${list.length} Users`;
|
||||
this.userList.innerHTML = null;
|
||||
|
||||
//create a new map
|
||||
var newMap = new Map();
|
||||
|
||||
//for each user
|
||||
list.forEach((user) => {
|
||||
//randomly pick a color
|
||||
var color = this.userColors[Math.floor(Math.random()*this.userColors.length)]
|
||||
|
||||
//if this user was in the previous colormap
|
||||
if(this.colorMap.get(user) != null){
|
||||
//Override with previous color
|
||||
color = this.colorMap.get(user);
|
||||
}
|
||||
|
||||
newMap.set(user, color);
|
||||
this.renderUser(user, color);
|
||||
});
|
||||
|
||||
this.colorMap = newMap;
|
||||
}
|
||||
|
||||
renderUser(user, color){
|
||||
var userEntry = document.createElement('p');
|
||||
|
||||
userEntry.innerText = user;
|
||||
userEntry.id = `user-entry-${user}`;
|
||||
userEntry.classList.add("chat-panel-users","user-entry",color);
|
||||
|
||||
this.userList.appendChild(userEntry);
|
||||
}
|
||||
|
||||
toggleUI(show = this.userDiv.style.display == "none"){
|
||||
if(show){
|
||||
this.userDiv.style.display = "flex";
|
||||
this.toggleIcon.classList.replace("bi-caret-left-fill","bi-caret-down-fill");
|
||||
}else{
|
||||
this.userDiv.style.display = "none";
|
||||
this.toggleIcon.classList.replace("bi-caret-down-fill","bi-caret-left-fill");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
54
www/js/channelSettings.js
Normal file
54
www/js/channelSettings.js
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
class channelSettingsPrompt{
|
||||
constructor(){
|
||||
this.channel = window.location.pathname.slice(3).replace('/settings','');
|
||||
this.hidden = document.querySelector("#channel-hidden");
|
||||
this.delete = document.querySelector("#channel-delete");
|
||||
|
||||
this.hidden.addEventListener('change', this.submitUpdate.bind(this));
|
||||
this.delete.addEventListener('click', this.promptDelete.bind(this));
|
||||
}
|
||||
|
||||
async submitUpdate(event){
|
||||
//probably not the cleanest way to get the chan name :P
|
||||
const key = event.target.id.split("-").pop();
|
||||
const value = event.target.type == "checkbox" ? event.target.checked : event.target.value;
|
||||
const settingsMap = new Map([
|
||||
[key, value]
|
||||
]);
|
||||
|
||||
this.handleUpdate(await utils.ajax.setChannelSetting(this.channel, settingsMap));
|
||||
}
|
||||
|
||||
handleUpdate(updateObj){
|
||||
this.hidden.checked = updateObj.hidden;
|
||||
}
|
||||
|
||||
promptDelete(){
|
||||
var confirm = window.prompt(`Warning: You are about to nuke ${this.channel} off of the face of the fucking planet, no taksie-backsies. \n \n Type in ${this.channel} to confirm.`);
|
||||
this.deleteChannel(confirm);
|
||||
}
|
||||
|
||||
async deleteChannel(confirm){
|
||||
if(this.channel === confirm){
|
||||
utils.ajax.deleteChannel(this.channel, confirm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new channelSettingsPrompt();
|
||||
36
www/js/navbar.js
Normal file
36
www/js/navbar.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//I could make a class like the others but it's so god-damned basic why bother?
|
||||
async function navbarLogin(event){
|
||||
if(!event || !event.key || event.key == "Enter"){
|
||||
var user = document.querySelector("#username-prompt").value;
|
||||
var pass = document.querySelector("#password-prompt").value;
|
||||
|
||||
utils.ajax.login(user, pass);
|
||||
}
|
||||
}
|
||||
|
||||
//assign events
|
||||
if(document.querySelector("#username-prompt")){
|
||||
document.querySelector("#username-prompt").addEventListener("keydown", navbarLogin);
|
||||
document.querySelector("#password-prompt").addEventListener("keydown", navbarLogin);
|
||||
document.querySelector("#login-button").addEventListener("click", navbarLogin);
|
||||
}
|
||||
|
||||
if(document.querySelector("#logout-button")){
|
||||
document.querySelector("#logout-button").addEventListener("click", utils.ajax.logout);
|
||||
}
|
||||
31
www/js/newChannel.js
Normal file
31
www/js/newChannel.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//I could make a class like the others but it's so god-damned basic why bother?
|
||||
async function registerPrompt(event){
|
||||
if(!event || event.key == "Enter"){
|
||||
var name = document.querySelector("#register-channel-name").value;
|
||||
var description = document.querySelector("#register-description").value;
|
||||
var thumbnail = document.querySelector("#register-thumbnail").value;
|
||||
|
||||
utils.ajax.newChannel(name, description, thumbnail);
|
||||
}
|
||||
}
|
||||
|
||||
//assign events
|
||||
document.querySelector("#register-channel-name").addEventListener("keydown", registerPrompt)
|
||||
document.querySelector("#register-description").addEventListener("keydown", registerPrompt)
|
||||
document.querySelector("#register-thumbnail").addEventListener("keydown", registerPrompt)
|
||||
184
www/js/profile.js
Normal file
184
www/js/profile.js
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//Base Class
|
||||
class profileEditPrompt{
|
||||
constructor(field, content, useTextArea = false){
|
||||
this.field = field;
|
||||
this.useTextArea = useTextArea;
|
||||
this.content = content;
|
||||
this.link = document.querySelector(`#profile-${field}-edit`);
|
||||
|
||||
//Bail out if something ain't right
|
||||
if(!this.link || !this.content){
|
||||
return;
|
||||
}
|
||||
|
||||
this.setupPrompt();
|
||||
}
|
||||
|
||||
setupPrompt(){
|
||||
if(this.link != null){
|
||||
this.link.addEventListener("click", this.prompt.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
prompt(){
|
||||
//Create input element
|
||||
if(this.useTextArea){
|
||||
this.prompt = document.createElement("textArea");
|
||||
}else{
|
||||
this.prompt = document.createElement("input");
|
||||
}
|
||||
|
||||
//Setup properties
|
||||
this.prompt.id = `profile-${this.field}-prompt`;
|
||||
this.prompt.classList.add("profile-edit-prompt");
|
||||
this.prompt.placeholder = this.content.innerHTML;
|
||||
|
||||
//Setup event listener
|
||||
this.prompt.addEventListener("keydown", this.update.bind(this));
|
||||
|
||||
//replace label
|
||||
this.content.replaceWith(this.prompt);
|
||||
}
|
||||
|
||||
async update(event){
|
||||
if((!event || event.key == "Enter") && this.prompt.value){
|
||||
//setup object
|
||||
var updateObj = {};
|
||||
updateObj[this.field] = this.prompt.value;
|
||||
|
||||
//contact server, and collect response
|
||||
var response = await utils.ajax.updateProfile(updateObj);
|
||||
var updated_content = (await response.json())[this.field];
|
||||
|
||||
//Update label
|
||||
if(response.status == 200){
|
||||
if(this.field == "img"){
|
||||
this.content.src = updated_content;
|
||||
}else{
|
||||
this.content.innerHTML = updated_content;
|
||||
}
|
||||
}
|
||||
this.finish();
|
||||
}else if(event.key == "Escape" || event.key == "Enter"){
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
finish(){
|
||||
this.prompt.replaceWith(this.content);
|
||||
}
|
||||
}
|
||||
|
||||
class profileTextEditPrompt extends profileEditPrompt{
|
||||
constructor(field, useTextArea = false){
|
||||
//Get content based on field name
|
||||
var content = document.querySelector(`#profile-${field}-content`);
|
||||
//Derived Constructor
|
||||
super(field, content, useTextArea);
|
||||
}
|
||||
|
||||
prompt(){
|
||||
super.prompt();
|
||||
}
|
||||
|
||||
async update(event){
|
||||
await super.update(event)
|
||||
}
|
||||
}
|
||||
|
||||
//Child Classes
|
||||
class profileImgEditPrompt extends profileEditPrompt{
|
||||
constructor(){
|
||||
//Get content based on field name
|
||||
var content = document.querySelector(`#profile-img`);
|
||||
//Derived constructor
|
||||
super("img", content, false);
|
||||
}
|
||||
}
|
||||
|
||||
class passwordResetPrompt{
|
||||
constructor(){
|
||||
this.oldPassNode = document.querySelector('#account-settings-password-reset-old');
|
||||
this.newPassNode = document.querySelector('#account-settings-password-reset-new');
|
||||
this.confirmPassNode = document.querySelector('#account-settings-password-reset-confirm');
|
||||
|
||||
this.setupInput(this.oldPassNode);
|
||||
this.setupInput(this.newPassNode);
|
||||
this.setupInput(this.confirmPassNode);
|
||||
}
|
||||
|
||||
setupInput(node){
|
||||
if(node != null){
|
||||
node.addEventListener("keydown", this.update.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
async update(event){
|
||||
var hasVal = (this.oldPassNode.value && this.newPassNode.value && this.confirmPassNode.value);
|
||||
if((!event || event.key == "Enter") && hasVal){
|
||||
if(this.newPassNode.value == this.confirmPassNode.value){
|
||||
const updateObj = {};
|
||||
|
||||
updateObj.passChange = {
|
||||
oldPass: this.oldPassNode.value,
|
||||
newPass: this.newPassNode.value,
|
||||
confirmPass: this.confirmPassNode.value
|
||||
};
|
||||
|
||||
const response = await utils.ajax.updateProfile(updateObj);
|
||||
|
||||
if(response.status == 200){
|
||||
//Return user homepage after good pass change, as we've probably been logged out by the server for security.
|
||||
window.location.pathname = '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class deleteAccountPrompt{
|
||||
constructor(){
|
||||
this.deleteLink = document.querySelector('#account-settings-delete-link');
|
||||
this.setupEvent();
|
||||
}
|
||||
|
||||
setupEvent(){
|
||||
if(this.deleteLink != null){
|
||||
this.deleteLink.addEventListener("click",this.deletePrompt);
|
||||
}
|
||||
}
|
||||
|
||||
async deletePrompt(event){
|
||||
const pass = window.prompt("Warning: You are about to nuke your account off of the face of the fucking planet, no taksie-backsies.\n \n (todo: replace with dialog that has obscured password input) \n Enter your password to confirm.");
|
||||
const response = await utils.ajax.deleteAccount(pass);
|
||||
|
||||
if(response.status == 200){
|
||||
window.location.pathname = '/';
|
||||
}else{
|
||||
displayResponseError(await response.json());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Object Instantiation
|
||||
new profileTextEditPrompt("signature");
|
||||
new profileTextEditPrompt("bio", true);
|
||||
new profileImgEditPrompt();
|
||||
new passwordResetPrompt();
|
||||
new deleteAccountPrompt();
|
||||
33
www/js/register.js
Normal file
33
www/js/register.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
//I could make a class like the others but it's so god-damned basic why bother?
|
||||
async function registerPrompt(event){
|
||||
if(!event || event.key == "Enter"){
|
||||
var user = document.querySelector("#register-username").value;
|
||||
var pass = document.querySelector("#register-password").value;
|
||||
var passConfirm = document.querySelector("#register-password-confirm").value;
|
||||
var email = document.querySelector("#register-email").value;
|
||||
|
||||
utils.ajax.register(user, pass, passConfirm, email);
|
||||
}
|
||||
}
|
||||
|
||||
//assign events
|
||||
document.querySelector("#register-username").addEventListener("keydown", registerPrompt)
|
||||
document.querySelector("#register-password").addEventListener("keydown", registerPrompt)
|
||||
document.querySelector("#register-password-confirm").addEventListener("keydown", registerPrompt)
|
||||
document.querySelector("#register-email").addEventListener("keydown", registerPrompt)
|
||||
214
www/js/utils.js
Normal file
214
www/js/utils.js
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
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 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/>.*/
|
||||
|
||||
class canopyUtils{
|
||||
constructor(){
|
||||
this.ajax = new canopyAjaxUtils();
|
||||
this.ux = new canopyUXUtils();
|
||||
}
|
||||
}
|
||||
|
||||
class canopyUXUtils{
|
||||
constructor(){
|
||||
}
|
||||
|
||||
|
||||
static clickDragger = class{
|
||||
constructor(handle, element, breakPoint){
|
||||
//Pull needed nodes
|
||||
this.handle = document.querySelector(handle);
|
||||
this.element = document.querySelector(element);
|
||||
|
||||
//True while dragging
|
||||
this.dragLock = false;
|
||||
|
||||
//Little hacky but it could be worse :P
|
||||
this.fixWidth = false;
|
||||
|
||||
//Setup our event listeners
|
||||
this.setupInput();
|
||||
}
|
||||
|
||||
setupInput(){
|
||||
this.handle.addEventListener("mousedown", this.startDrag.bind(this));
|
||||
this.element.parentElement.addEventListener("mouseup", this.endDrag.bind(this));
|
||||
this.element.parentElement.addEventListener("mousemove", this.drag.bind(this));
|
||||
}
|
||||
|
||||
startDrag(event){
|
||||
//we are now dragging
|
||||
this.dragLock = true;
|
||||
}
|
||||
|
||||
endDrag(event){
|
||||
//we're no longer dragging
|
||||
this.dragLock = false;
|
||||
|
||||
//if we broke the page we need to fix it
|
||||
if(this.fixWidth){
|
||||
//Pop the element width up just a bit to compensate for the extra pixel
|
||||
this.element.style.width = `${this.calcWidth(this.element.getBoundingClientRect().width + 1)}%`;
|
||||
//if this is true, it no longer needs to be, though it *should* be reset by the drag function by the time it matters anywho :P
|
||||
this.fixWidth = false;
|
||||
}
|
||||
}
|
||||
|
||||
drag(event){
|
||||
|
||||
if(this.dragLock){
|
||||
//get difference between mouse and right edge of element
|
||||
var difference = this.element.getBoundingClientRect().right - event.clientX;
|
||||
//check if we have a scrollbar because we're breaking shit
|
||||
var pageBreak = document.body.scrollWidth - document.body.getBoundingClientRect().width;
|
||||
|
||||
|
||||
//if we're not breaking the page, or we're moving left
|
||||
if(pageBreak <= 0 || event.clientX < this.handle.getBoundingClientRect().left){
|
||||
//Apply difference to width
|
||||
this.element.style.width = `${this.calcWidth(difference)}%`;
|
||||
//If we let go here, the width isn't breaking anything so there's nothing to fix.
|
||||
this.fixWidth = false;
|
||||
}else{
|
||||
//We need to move the element back, but we can't do it all the way while we're still dragging as it will thrash
|
||||
this.element.style.width = `${this.calcWidth(this.element.getBoundingClientRect().width + pageBreak - 1)}%`;
|
||||
//If we stop dragging here, let the endDrag function know to fix the pixel difference used to prevent thrashing
|
||||
this.fixWidth = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
calcWidth(px){
|
||||
return (px / this.element.parentElement.getBoundingClientRect().width) * 100;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class canopyAjaxUtils{
|
||||
|
||||
constructor(){
|
||||
|
||||
}
|
||||
|
||||
//Profile
|
||||
async displayResponseError(body){
|
||||
const err = body.msg;
|
||||
window.alert(`ERROR:\n${err}`);
|
||||
}
|
||||
|
||||
async register(user, pass, passConfirm, email){
|
||||
var response = await fetch(`/api/account/register`,{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(email ? {user, pass, passConfirm, email} : {user, pass, passConfirm})
|
||||
});
|
||||
|
||||
if(response.status == 200){
|
||||
location = "/";
|
||||
}
|
||||
}
|
||||
|
||||
async login(user, pass){
|
||||
var response = await fetch(`/api/account/login`,{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({user, pass})
|
||||
});
|
||||
|
||||
if(response.status == 200){
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
async logout(){
|
||||
var response = await fetch(`/api/account/logout`,{
|
||||
method: "GET",
|
||||
});
|
||||
|
||||
if(response.status == 200){
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
async updateProfile(update){
|
||||
return await fetch(`/api/account/update`,{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(update)
|
||||
});
|
||||
}
|
||||
|
||||
async deleteAccount(pass){
|
||||
return await fetch(`/api/account/delete`,{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({pass})
|
||||
});
|
||||
}
|
||||
|
||||
async newChannel(name, description, thumbnail){
|
||||
var response = await fetch(`/api/channel/register`,{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(thumbnail ? {name, description, thumbnail} : {name, description})
|
||||
});
|
||||
|
||||
if(response.status == 200){
|
||||
location = "/";
|
||||
}
|
||||
}
|
||||
|
||||
async setChannelSetting(chanName, settingsMap){
|
||||
var response = await fetch(`/api/channel/settings`,{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
//Unfortunately JSON doesn't natively handle ES6 maps, and god forbid someone update the standard in a way that's backwards compatible...
|
||||
body: JSON.stringify({chanName, settingsMap: Object.fromEntries(settingsMap)})
|
||||
});
|
||||
|
||||
if(response.status == 200){
|
||||
return await response.json();
|
||||
}
|
||||
}
|
||||
|
||||
async deleteChannel(chanName, confirm){
|
||||
var response = await fetch(`/api/channel/delete`,{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({chanName, confirm})
|
||||
});
|
||||
|
||||
if(response.status == 200){
|
||||
location = "/";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const utils = new canopyUtils()
|
||||
BIN
www/video/static.webm
Normal file
BIN
www/video/static.webm
Normal file
Binary file not shown.
Loading…
Reference in a new issue