mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-10-30 11:46:16 +00:00
commit
1be6a774ff
798
LICENSE
798
LICENSE
@ -1,201 +1,661 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
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.
|
||||
|
||||
1. Definitions.
|
||||
Preamble
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
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.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
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.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
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.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
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.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
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.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
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.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
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.
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
0. Definitions.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
"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.
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
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.
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
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.
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
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.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
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.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
1. Source Code.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
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.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
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.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
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.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
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.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
2. Basic Permissions.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
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.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
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.
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
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/>.
|
||||
|
3
Makefile
3
Makefile
@ -4,6 +4,9 @@ run: build
|
||||
config_run: build
|
||||
./mycorrhiza -config-path "assets/config.ini" metarrhiza
|
||||
|
||||
devconfig_run: build
|
||||
./mycorrhiza -config-path "assets/devconfig.ini" metarrhiza
|
||||
|
||||
build:
|
||||
go generate
|
||||
go build .
|
||||
|
@ -1,4 +1,4 @@
|
||||
# 🍄 MycorrhizaWiki
|
||||
# 🍄 MycorrhizaWiki 1.1
|
||||
A wiki engine.
|
||||
|
||||
[Main wiki](https://mycorrhiza.lesarbr.es)
|
||||
@ -28,10 +28,10 @@ Options:
|
||||
```
|
||||
|
||||
## Features
|
||||
* Edit pages through html forms, graphical preview
|
||||
* Wiki pages (called hyphae) are written in mycomarkup
|
||||
* Edit pages through html forms, graphical preview, toolbar that helps you use the markup
|
||||
* Responsive design, dark theme (synced with system theme)
|
||||
* Works in text browsers
|
||||
* Wiki pages (called hyphae) are written in mycomarkup
|
||||
* Everything is stored as simple files, no database required. You can run a wiki on almost any directory and get something to work with
|
||||
* Page trees; links to previous and next pages
|
||||
* Changes are saved to git
|
||||
@ -42,7 +42,7 @@ Options:
|
||||
* Hyphae can be deleted (while still preserving history)
|
||||
* Hyphae can be renamed (recursive renaming of subhyphae is also supported)
|
||||
* Light on resources
|
||||
* Authorization with pre-set credentials
|
||||
* Authorization with pre-set credentials, registration
|
||||
* Basic Gemini protocol support
|
||||
|
||||
## Contributing
|
||||
|
@ -10,6 +10,10 @@ Usage of %s:
|
||||
{% cat "default.css" %}
|
||||
{% endfunc %}
|
||||
|
||||
{% func ToolbarJS() %}
|
||||
{% cat "toolbar.js" %}
|
||||
{% endfunc %}
|
||||
|
||||
Next three are from https://remixicon.com/
|
||||
{% func IconHTTP() %}
|
||||
{% cat "icon/http-protocol-icon.svg" %}
|
||||
@ -27,3 +31,8 @@ This is a modified version of https://www.svgrepo.com/svg/232085/rat
|
||||
{% func IconGopher() %}
|
||||
{% cat "icon/gopher-protocol-icon.svg" %}
|
||||
{% endfunc %}
|
||||
|
||||
https://upload.wikimedia.org/wikipedia/commons/4/46/Generic_Feed-icon.svg
|
||||
{% func IconFeed() %}
|
||||
{% cat "icon/feed-icon.svg" %}
|
||||
{% endfunc %}
|
||||
|
@ -70,6 +70,10 @@ GeminiCertificatePath = /home/wiki/gemcerts
|
||||
[Authorization]
|
||||
UseFixedAuth = true
|
||||
FixedAuthCredentialsPath = /home/wiki/mycocredentials.json
|
||||
|
||||
UseRegistration = true
|
||||
RegistrationCredentialsPath = /home/wiki/mycoregistration.json
|
||||
LimitRegistration = 10
|
||||
`)
|
||||
//line assets/assets.qtpl:6
|
||||
qw422016.N().S(`
|
||||
@ -109,7 +113,8 @@ func StreamDefaultCSS(qw422016 *qt422016.Writer) {
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:10
|
||||
qw422016.N().S(`.amnt-grid { display: grid; grid-template-columns: 1fr 1fr; }
|
||||
qw422016.N().S(`
|
||||
.amnt-grid { display: grid; grid-template-columns: 1fr 1fr; }
|
||||
.upload-binary__input { display: block; margin: .25rem 0; }
|
||||
|
||||
.modal__title { font-size: 2rem; }
|
||||
@ -170,27 +175,38 @@ header { width: 100%; margin-bottom: 1rem; }
|
||||
.header-links__entry:nth-of-type(1), .hypha-tabs__tab:nth-of-type(1) { margin-left: 2rem; }
|
||||
}
|
||||
|
||||
|
||||
/* Wide enough to fit two columns ok */
|
||||
@media screen and (min-width: 1100px) {
|
||||
.layout { display: grid; grid-template-columns: auto 1fr; column-gap: 1rem; margin: 0 1rem; row-gap: 1rem; }
|
||||
.main-width { margin: 0; }
|
||||
main { grid-column: 1 / span 1; grid-row: 1 / span 2; }
|
||||
.relative-hyphae { grid-column: 2 / span 1; grid-row: 1 / span 1; }
|
||||
.relative-hyphae, .edit-toolbar { grid-column: 2 / span 1; grid-row: 1 / span 1; }
|
||||
.layout-card { width: 100%; }
|
||||
.edit-toolbar__buttons {display: grid; }
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1150px) {
|
||||
.edit-toolbar__buttons { grid-template-columns: 1fr 1fr; }
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1250px) {
|
||||
.layout { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
|
||||
.layout-card { max-width: 16rem; }
|
||||
.layout-card {max-width: 18rem;}
|
||||
.main-width { margin: 0 auto; }
|
||||
.backlinks { grid-column: 1 / span 1; margin-right: 0; }
|
||||
main { grid-column: 2 / span 1; }
|
||||
.relative-hyphae { grid-column: 3 / span 1; margin-left: 0; }
|
||||
.relative-hyphae, .edit-toolbar { grid-column: 3 / span 1; margin-left: 0; }
|
||||
.edit-toolbar__buttons { grid-template-columns: 1fr; }
|
||||
|
||||
.backlinks__title { text-align: right; }
|
||||
.backlinks__link { text-align: right; padding-right: 1.25rem; padding-left: .25rem; }
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1400px) {
|
||||
.edit-toolbar__buttons { grid-template-columns: 1fr 1fr; }
|
||||
}
|
||||
|
||||
*, *::before, *::after {box-sizing: border-box;}
|
||||
html { height:100%; padding:0; }
|
||||
body {height:100%; margin:0; }
|
||||
@ -204,6 +220,7 @@ textarea {font-size:16px; font-family: 'PT Sans', 'Liberation Sans', sans-serif;
|
||||
.edit-form {height:70vh;}
|
||||
.edit-form textarea {width:100%;height:95%;}
|
||||
.edit-form__save { font-weight: bold; }
|
||||
.edit-toolbar__buttons, .edit-toolbar__ad { margin: .5rem; }
|
||||
|
||||
.icon {margin-right: .25rem; vertical-align: bottom; }
|
||||
|
||||
@ -281,19 +298,16 @@ td { padding: .25rem; }
|
||||
caption { caption-side: top; font-size: small; }
|
||||
|
||||
.subhyphae__list, .subhyphae__list ul { display: flex; padding: 0; margin: 0; flex-wrap: wrap; }
|
||||
.subhyphae__list ul { font-size: 90%; }
|
||||
.subhyphae__entry { list-style-type: none; border: 1px solid #999; padding: 0; margin: .125rem; border-radius: .25rem; }
|
||||
.subhyphae__link { display: block; padding: .25rem; text-decoration: none; }
|
||||
.subhyphae__link:hover { background: #eee; }
|
||||
|
||||
.navitree { padding: 0; margin: 0; }
|
||||
.navitree__entry { }
|
||||
.navitree > .navitree__entry > a::before { display: inline-block; width: .5rem; color: #999; margin: 0 .25rem; }
|
||||
.navitree > .navitree__entry_infertile > a::before { content: " "} /* nbsp, careful */
|
||||
.navitree > .navitree__sibling_fertile > a::before { content: "▸"}
|
||||
.navitree__trunk { border-left: 1px #999 solid; }
|
||||
.navitree__link { text-decoration: none; display: block; padding: .25rem; }
|
||||
.navitree__entry_this > span { display: block; padding: .25rem; font-weight: bold; }
|
||||
.navitree__entry_this > span::before { content: " "; display: inline-block; width: 1rem; }
|
||||
.relative-hyphae__list { padding: 0; margin: 0; }
|
||||
.relative-hyphae__entry { clear: both; }
|
||||
.relative-hyphae__count { display: inline-block; float: right; }
|
||||
.relative-hyphae__entry_this { padding: .25rem .5rem; font-weight: bold; }
|
||||
.relative-hyphae__link { text-decoration: none; display: block; padding: .25rem .5rem; }
|
||||
|
||||
|
||||
/* Color stuff */
|
||||
@ -326,7 +340,7 @@ table { background-color: #eee; }
|
||||
|
||||
/* Other stuff */
|
||||
html { background-color: #ddd;
|
||||
background-image: url("data:image/svg+xml,%3Csvg width='42' height='44' viewBox='0 0 42 44' xmlns='http://www.w3.org/2000/svg'%3E%3Cg id='Page-1' fill='none' fill-rule='evenodd'%3E%3Cg id='brick-wall' fill='%23bbbbbb' fill-opacity='0.4'%3E%3Cpath d='M0 0h42v44H0V0zm1 1h40v20H1V1zM0 23h20v20H0V23zm22 0h20v20H22V23z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='199' viewBox='0 0 100 199'%3E%3Cg fill='%23bbbbbb' %3E%3Cpath d='M0 199V0h1v1.99L100 199h-1.12L1 4.22V199H0zM100 2h-.12l-1-2H100v2z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E");
|
||||
} /* heropatterns.com */
|
||||
header { background-color: #bbb; }
|
||||
.header-links__link { color: black; }
|
||||
@ -342,7 +356,7 @@ blockquote { border-left: 4px black solid; }
|
||||
.upload-amnt { border: #eee 1px solid; }
|
||||
td { border: #ddd 1px solid; }
|
||||
|
||||
.navitree__link:hover, .backlinks__link:hover { background-color: #eee; }
|
||||
.relative-hyphae__link:hover, .backlinks__link:hover { background-color: #eee; }
|
||||
|
||||
/* Dark theme! */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
@ -352,7 +366,7 @@ main, article, .hypha-tabs__tab, header, .layout-card { background-color: #3434
|
||||
a, .wikilink_external { color: #f1fa8c; }
|
||||
a:visited, .wikilink_external:visited { color: #ffb86c; }
|
||||
.wikilink_new, .wikilink_new:visited { color: #dd4444; }
|
||||
.navitree__link:hover, .backlinks__link:hover { background-color: #444; }
|
||||
.subhyphae__link:hover, .relative-hyphae__link:hover, .backlinks__link:hover { background-color: #444; }
|
||||
|
||||
.header-links__link, .header-links__link:visited,
|
||||
.prevnext__el, .prevnext__el:visited { color: #ddd; }
|
||||
@ -381,6 +395,8 @@ mark { background: rgba(130, 80, 30, 5); color: inherit; }
|
||||
.hypha-tabs { background-color: #232323; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
`)
|
||||
//line assets/assets.qtpl:10
|
||||
qw422016.N().S(`
|
||||
@ -414,136 +430,273 @@ func DefaultCSS() string {
|
||||
//line assets/assets.qtpl:11
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:13
|
||||
func StreamToolbarJS(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:13
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S(`const editTextarea = document.getElementsByClassName('edit-form__textarea')[0]
|
||||
|
||||
function placeCursor(position, el = editTextarea) {
|
||||
el.selectionEnd = position
|
||||
el.selectionStart = el.selectionEnd
|
||||
}
|
||||
|
||||
function getSelectedText(el = editTextarea) {
|
||||
const [start, end] = [el.selectionStart, el.selectionEnd]
|
||||
const text = el.value
|
||||
return text.substring(start, end)
|
||||
}
|
||||
|
||||
function textInserter(text, cursorPosition = null, el = editTextarea) {
|
||||
return function() {
|
||||
const [start, end] = [el.selectionStart, el.selectionEnd]
|
||||
el.setRangeText(text, start, end, 'select')
|
||||
el.focus()
|
||||
if (cursorPosition == null) {
|
||||
placeCursor(end + text.length)
|
||||
} else {
|
||||
placeCursor(end + cursorPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function selectionWrapper(cursorPosition, prefix, postfix = null, el = editTextarea) {
|
||||
return function() {
|
||||
const [start, end] = [el.selectionStart, el.selectionEnd]
|
||||
if (postfix == null) {
|
||||
postfix = prefix
|
||||
}
|
||||
let text = getSelectedText(el)
|
||||
let result = prefix + text + postfix
|
||||
el.setRangeText(result, start, end, 'select')
|
||||
el.focus()
|
||||
placeCursor(end + cursorPosition)
|
||||
}
|
||||
}
|
||||
|
||||
const wrapBold = selectionWrapper(2, '**'),
|
||||
wrapItalic = selectionWrapper(2, '//'),
|
||||
wrapMonospace = selectionWrapper(1, '`)
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S("`")
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S(`'),
|
||||
wrapHighlighted = selectionWrapper(2, '!!'),
|
||||
wrapLifted = selectionWrapper(1, '^'),
|
||||
wrapLowered = selectionWrapper(2, ',,'),
|
||||
wrapStrikethrough = selectionWrapper(2, '~~'),
|
||||
wrapLink = selectionWrapper(2, '[[', ']]')
|
||||
|
||||
const insertHorizontalBar = textInserter('\n----\n'),
|
||||
insertImgBlock = textInserter('\nimg {\n \n}\n', 10),
|
||||
insertTableBlock = textInserter('\ntable {\n \n}\n', 12),
|
||||
insertRocket = textInserter('\n=> '),
|
||||
insertXcl = textInserter('\n<= '),
|
||||
insertHeading2 = textInserter('\n## '),
|
||||
insertHeading3 = textInserter('\n### '),
|
||||
insertCodeblock = textInserter('\n`)
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S("`")
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S(``)
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S("`")
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S(``)
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S("`")
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S(`\n\n`)
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S("`")
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S(``)
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S("`")
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S(``)
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S("`")
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S(`\n', 5),
|
||||
insertBulletedList = textInserter('\n* '),
|
||||
insertNumberedList = textInserter('\n*. ')
|
||||
|
||||
function insertDate() {
|
||||
let date = new Date().toISOString().split('T')[0]
|
||||
textInserter(date)()
|
||||
}
|
||||
|
||||
function insertUserlink() {
|
||||
const userlink = document.querySelector('.header-links__entry_user a')
|
||||
const userHypha = userlink.getAttribute('href').substring(7) // no /hypha/
|
||||
textInserter('[[' + userHypha + ']]')()
|
||||
}
|
||||
`)
|
||||
//line assets/assets.qtpl:14
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:15
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:15
|
||||
func WriteToolbarJS(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:15
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:15
|
||||
StreamToolbarJS(qw422016)
|
||||
//line assets/assets.qtpl:15
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:15
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:15
|
||||
func ToolbarJS() string {
|
||||
//line assets/assets.qtpl:15
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:15
|
||||
WriteToolbarJS(qb422016)
|
||||
//line assets/assets.qtpl:15
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:15
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:15
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:15
|
||||
}
|
||||
|
||||
// Next three are from https://remixicon.com/
|
||||
|
||||
//line assets/assets.qtpl:14
|
||||
//line assets/assets.qtpl:18
|
||||
func StreamIconHTTP(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:14
|
||||
//line assets/assets.qtpl:18
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:15
|
||||
//line assets/assets.qtpl:19
|
||||
qw422016.N().S(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="#999" d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-2.29-2.333A17.9 17.9 0 0 1 8.027 13H4.062a8.008 8.008 0 0 0 5.648 6.667zM10.03 13c.151 2.439.848 4.73 1.97 6.752A15.905 15.905 0 0 0 13.97 13h-3.94zm9.908 0h-3.965a17.9 17.9 0 0 1-1.683 6.667A8.008 8.008 0 0 0 19.938 13zM4.062 11h3.965A17.9 17.9 0 0 1 9.71 4.333 8.008 8.008 0 0 0 4.062 11zm5.969 0h3.938A15.905 15.905 0 0 0 12 4.248 15.905 15.905 0 0 0 10.03 11zm4.259-6.667A17.9 17.9 0 0 1 15.973 11h3.965a8.008 8.008 0 0 0-5.648-6.667z"/></svg>
|
||||
`)
|
||||
//line assets/assets.qtpl:15
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:16
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:16
|
||||
func WriteIconHTTP(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:16
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:16
|
||||
StreamIconHTTP(qw422016)
|
||||
//line assets/assets.qtpl:16
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:16
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:16
|
||||
func IconHTTP() string {
|
||||
//line assets/assets.qtpl:16
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:16
|
||||
WriteIconHTTP(qb422016)
|
||||
//line assets/assets.qtpl:16
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:16
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:16
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:16
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:18
|
||||
func StreamIconGemini(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:18
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:19
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:20
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:20
|
||||
func WriteIconHTTP(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:20
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:20
|
||||
StreamIconHTTP(qw422016)
|
||||
//line assets/assets.qtpl:20
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:20
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:20
|
||||
func IconHTTP() string {
|
||||
//line assets/assets.qtpl:20
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:20
|
||||
WriteIconHTTP(qb422016)
|
||||
//line assets/assets.qtpl:20
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:20
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:20
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:20
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:22
|
||||
func StreamIconGemini(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:22
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:23
|
||||
qw422016.N().S(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="#999" d="M15.502 20A6.523 6.523 0 0 1 12 23.502 6.523 6.523 0 0 1 8.498 20h2.26c.326.489.747.912 1.242 1.243.495-.33.916-.754 1.243-1.243h2.259zM18 14.805l2 2.268V19H4v-1.927l2-2.268V9c0-3.483 2.504-6.447 6-7.545C15.496 2.553 18 5.517 18 9v5.805zM17.27 17L16 15.56V9c0-2.318-1.57-4.43-4-5.42C9.57 4.57 8 6.681 8 9v6.56L6.73 17h10.54zM12 11a2 2 0 1 1 0-4 2 2 0 0 1 0 4z"/></svg>
|
||||
`)
|
||||
//line assets/assets.qtpl:19
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:20
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:20
|
||||
func WriteIconGemini(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:20
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:20
|
||||
StreamIconGemini(qw422016)
|
||||
//line assets/assets.qtpl:20
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:20
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:20
|
||||
func IconGemini() string {
|
||||
//line assets/assets.qtpl:20
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:20
|
||||
WriteIconGemini(qb422016)
|
||||
//line assets/assets.qtpl:20
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:20
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:20
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:20
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:22
|
||||
func StreamIconMailto(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:22
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:23
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:24
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:24
|
||||
func WriteIconGemini(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:24
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:24
|
||||
StreamIconGemini(qw422016)
|
||||
//line assets/assets.qtpl:24
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:24
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:24
|
||||
func IconGemini() string {
|
||||
//line assets/assets.qtpl:24
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:24
|
||||
WriteIconGemini(qb422016)
|
||||
//line assets/assets.qtpl:24
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:24
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:24
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:24
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:26
|
||||
func StreamIconMailto(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:26
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:27
|
||||
qw422016.N().S(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="#999" d="M3 3h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm17 4.238l-7.928 7.1L4 7.216V19h16V7.238zM4.511 5l7.55 6.662L19.502 5H4.511z"/></svg>
|
||||
`)
|
||||
//line assets/assets.qtpl:23
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:24
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:24
|
||||
func WriteIconMailto(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:24
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:24
|
||||
StreamIconMailto(qw422016)
|
||||
//line assets/assets.qtpl:24
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:24
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:24
|
||||
func IconMailto() string {
|
||||
//line assets/assets.qtpl:24
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:24
|
||||
WriteIconMailto(qb422016)
|
||||
//line assets/assets.qtpl:24
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:24
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:24
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:24
|
||||
}
|
||||
|
||||
// This is a modified version of https://www.svgrepo.com/svg/232085/rat
|
||||
|
||||
//line assets/assets.qtpl:27
|
||||
func StreamIconGopher(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:27
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:28
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:28
|
||||
func WriteIconMailto(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:28
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:28
|
||||
StreamIconMailto(qw422016)
|
||||
//line assets/assets.qtpl:28
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:28
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:28
|
||||
func IconMailto() string {
|
||||
//line assets/assets.qtpl:28
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:28
|
||||
WriteIconMailto(qb422016)
|
||||
//line assets/assets.qtpl:28
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:28
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:28
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:28
|
||||
}
|
||||
|
||||
// This is a modified version of https://www.svgrepo.com/svg/232085/rat
|
||||
|
||||
//line assets/assets.qtpl:31
|
||||
func StreamIconGopher(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:31
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:32
|
||||
qw422016.N().S(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="16" height="16">
|
||||
<path fill="#999" d="M447.238,204.944v-70.459c0-8.836-7.164-16-16-16c-34.051,0-64.414,21.118-75.079,55.286
|
||||
C226.094,41.594,0,133.882,0,319.435c0,0.071,0.01,0.14,0.011,0.21c0.116,44.591,36.423,80.833,81.04,80.833h171.203
|
||||
@ -556,34 +709,92 @@ c55.425-8.382,107.014,29.269,115.759,84.394H295.484z"/>
|
||||
<circle fill="#999" cx="415.238" cy="260.05" r="21.166"/>
|
||||
</svg>
|
||||
`)
|
||||
//line assets/assets.qtpl:28
|
||||
//line assets/assets.qtpl:32
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:29
|
||||
//line assets/assets.qtpl:33
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:29
|
||||
//line assets/assets.qtpl:33
|
||||
func WriteIconGopher(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:29
|
||||
//line assets/assets.qtpl:33
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:29
|
||||
//line assets/assets.qtpl:33
|
||||
StreamIconGopher(qw422016)
|
||||
//line assets/assets.qtpl:29
|
||||
//line assets/assets.qtpl:33
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:29
|
||||
//line assets/assets.qtpl:33
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:29
|
||||
//line assets/assets.qtpl:33
|
||||
func IconGopher() string {
|
||||
//line assets/assets.qtpl:29
|
||||
//line assets/assets.qtpl:33
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:29
|
||||
//line assets/assets.qtpl:33
|
||||
WriteIconGopher(qb422016)
|
||||
//line assets/assets.qtpl:29
|
||||
//line assets/assets.qtpl:33
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:29
|
||||
//line assets/assets.qtpl:33
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:29
|
||||
//line assets/assets.qtpl:33
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:29
|
||||
//line assets/assets.qtpl:33
|
||||
}
|
||||
|
||||
// https://upload.wikimedia.org/wikipedia/commons/4/46/Generic_Feed-icon.svg
|
||||
|
||||
//line assets/assets.qtpl:36
|
||||
func StreamIconFeed(qw422016 *qt422016.Writer) {
|
||||
//line assets/assets.qtpl:36
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:37
|
||||
qw422016.N().S(`<svg xmlns="http://www.w3.org/2000/svg"
|
||||
id="RSSicon"
|
||||
viewBox="0 0 8 8" width="256" height="256">
|
||||
|
||||
<title>RSS feed icon</title>
|
||||
|
||||
<style type="text/css">
|
||||
.button {stroke: none; fill: orange;}
|
||||
.symbol {stroke: none; fill: white;}
|
||||
</style>
|
||||
|
||||
<rect class="button" width="8" height="8" rx="1.5" />
|
||||
<circle class="symbol" cx="2" cy="6" r="1" />
|
||||
<path class="symbol" d="m 1,4 a 3,3 0 0 1 3,3 h 1 a 4,4 0 0 0 -4,-4 z" />
|
||||
<path class="symbol" d="m 1,2 a 5,5 0 0 1 5,5 h 1 a 6,6 0 0 0 -6,-6 z" />
|
||||
|
||||
</svg>
|
||||
`)
|
||||
//line assets/assets.qtpl:37
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line assets/assets.qtpl:38
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:38
|
||||
func WriteIconFeed(qq422016 qtio422016.Writer) {
|
||||
//line assets/assets.qtpl:38
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line assets/assets.qtpl:38
|
||||
StreamIconFeed(qw422016)
|
||||
//line assets/assets.qtpl:38
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line assets/assets.qtpl:38
|
||||
}
|
||||
|
||||
//line assets/assets.qtpl:38
|
||||
func IconFeed() string {
|
||||
//line assets/assets.qtpl:38
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line assets/assets.qtpl:38
|
||||
WriteIconFeed(qb422016)
|
||||
//line assets/assets.qtpl:38
|
||||
qs422016 := string(qb422016.B)
|
||||
//line assets/assets.qtpl:38
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line assets/assets.qtpl:38
|
||||
return qs422016
|
||||
//line assets/assets.qtpl:38
|
||||
}
|
||||
|
@ -14,3 +14,7 @@ GeminiCertificatePath = /home/wiki/gemcerts
|
||||
[Authorization]
|
||||
UseFixedAuth = true
|
||||
FixedAuthCredentialsPath = /home/wiki/mycocredentials.json
|
||||
|
||||
UseRegistration = true
|
||||
RegistrationCredentialsPath = /home/wiki/mycoregistration.json
|
||||
LimitRegistration = 10
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
.amnt-grid { display: grid; grid-template-columns: 1fr 1fr; }
|
||||
.upload-binary__input { display: block; margin: .25rem 0; }
|
||||
|
||||
@ -59,27 +60,38 @@ header { width: 100%; margin-bottom: 1rem; }
|
||||
.header-links__entry:nth-of-type(1), .hypha-tabs__tab:nth-of-type(1) { margin-left: 2rem; }
|
||||
}
|
||||
|
||||
|
||||
/* Wide enough to fit two columns ok */
|
||||
@media screen and (min-width: 1100px) {
|
||||
.layout { display: grid; grid-template-columns: auto 1fr; column-gap: 1rem; margin: 0 1rem; row-gap: 1rem; }
|
||||
.main-width { margin: 0; }
|
||||
main { grid-column: 1 / span 1; grid-row: 1 / span 2; }
|
||||
.relative-hyphae { grid-column: 2 / span 1; grid-row: 1 / span 1; }
|
||||
.relative-hyphae, .edit-toolbar { grid-column: 2 / span 1; grid-row: 1 / span 1; }
|
||||
.layout-card { width: 100%; }
|
||||
.edit-toolbar__buttons {display: grid; }
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1150px) {
|
||||
.edit-toolbar__buttons { grid-template-columns: 1fr 1fr; }
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1250px) {
|
||||
.layout { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
|
||||
.layout-card { max-width: 16rem; }
|
||||
.layout-card {max-width: 18rem;}
|
||||
.main-width { margin: 0 auto; }
|
||||
.backlinks { grid-column: 1 / span 1; margin-right: 0; }
|
||||
main { grid-column: 2 / span 1; }
|
||||
.relative-hyphae { grid-column: 3 / span 1; margin-left: 0; }
|
||||
.relative-hyphae, .edit-toolbar { grid-column: 3 / span 1; margin-left: 0; }
|
||||
.edit-toolbar__buttons { grid-template-columns: 1fr; }
|
||||
|
||||
.backlinks__title { text-align: right; }
|
||||
.backlinks__link { text-align: right; padding-right: 1.25rem; padding-left: .25rem; }
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1400px) {
|
||||
.edit-toolbar__buttons { grid-template-columns: 1fr 1fr; }
|
||||
}
|
||||
|
||||
*, *::before, *::after {box-sizing: border-box;}
|
||||
html { height:100%; padding:0; }
|
||||
body {height:100%; margin:0; }
|
||||
@ -93,6 +105,7 @@ textarea {font-size:16px; font-family: 'PT Sans', 'Liberation Sans', sans-serif;
|
||||
.edit-form {height:70vh;}
|
||||
.edit-form textarea {width:100%;height:95%;}
|
||||
.edit-form__save { font-weight: bold; }
|
||||
.edit-toolbar__buttons, .edit-toolbar__ad { margin: .5rem; }
|
||||
|
||||
.icon {margin-right: .25rem; vertical-align: bottom; }
|
||||
|
||||
@ -170,19 +183,16 @@ td { padding: .25rem; }
|
||||
caption { caption-side: top; font-size: small; }
|
||||
|
||||
.subhyphae__list, .subhyphae__list ul { display: flex; padding: 0; margin: 0; flex-wrap: wrap; }
|
||||
.subhyphae__list ul { font-size: 90%; }
|
||||
.subhyphae__entry { list-style-type: none; border: 1px solid #999; padding: 0; margin: .125rem; border-radius: .25rem; }
|
||||
.subhyphae__link { display: block; padding: .25rem; text-decoration: none; }
|
||||
.subhyphae__link:hover { background: #eee; }
|
||||
|
||||
.navitree { padding: 0; margin: 0; }
|
||||
.navitree__entry { }
|
||||
.navitree > .navitree__entry > a::before { display: inline-block; width: .5rem; color: #999; margin: 0 .25rem; }
|
||||
.navitree > .navitree__entry_infertile > a::before { content: " "} /* nbsp, careful */
|
||||
.navitree > .navitree__sibling_fertile > a::before { content: "▸"}
|
||||
.navitree__trunk { border-left: 1px #999 solid; }
|
||||
.navitree__link { text-decoration: none; display: block; padding: .25rem; }
|
||||
.navitree__entry_this > span { display: block; padding: .25rem; font-weight: bold; }
|
||||
.navitree__entry_this > span::before { content: " "; display: inline-block; width: 1rem; }
|
||||
.relative-hyphae__list { padding: 0; margin: 0; }
|
||||
.relative-hyphae__entry { clear: both; }
|
||||
.relative-hyphae__count { display: inline-block; float: right; }
|
||||
.relative-hyphae__entry_this { padding: .25rem .5rem; font-weight: bold; }
|
||||
.relative-hyphae__link { text-decoration: none; display: block; padding: .25rem .5rem; }
|
||||
|
||||
|
||||
/* Color stuff */
|
||||
@ -215,7 +225,7 @@ table { background-color: #eee; }
|
||||
|
||||
/* Other stuff */
|
||||
html { background-color: #ddd;
|
||||
background-image: url("data:image/svg+xml,%3Csvg width='42' height='44' viewBox='0 0 42 44' xmlns='http://www.w3.org/2000/svg'%3E%3Cg id='Page-1' fill='none' fill-rule='evenodd'%3E%3Cg id='brick-wall' fill='%23bbbbbb' fill-opacity='0.4'%3E%3Cpath d='M0 0h42v44H0V0zm1 1h40v20H1V1zM0 23h20v20H0V23zm22 0h20v20H22V23z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='199' viewBox='0 0 100 199'%3E%3Cg fill='%23bbbbbb' %3E%3Cpath d='M0 199V0h1v1.99L100 199h-1.12L1 4.22V199H0zM100 2h-.12l-1-2H100v2z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E");
|
||||
} /* heropatterns.com */
|
||||
header { background-color: #bbb; }
|
||||
.header-links__link { color: black; }
|
||||
@ -231,7 +241,7 @@ blockquote { border-left: 4px black solid; }
|
||||
.upload-amnt { border: #eee 1px solid; }
|
||||
td { border: #ddd 1px solid; }
|
||||
|
||||
.navitree__link:hover, .backlinks__link:hover { background-color: #eee; }
|
||||
.relative-hyphae__link:hover, .backlinks__link:hover { background-color: #eee; }
|
||||
|
||||
/* Dark theme! */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
@ -241,7 +251,7 @@ main, article, .hypha-tabs__tab, header, .layout-card { background-color: #3434
|
||||
a, .wikilink_external { color: #f1fa8c; }
|
||||
a:visited, .wikilink_external:visited { color: #ffb86c; }
|
||||
.wikilink_new, .wikilink_new:visited { color: #dd4444; }
|
||||
.navitree__link:hover, .backlinks__link:hover { background-color: #444; }
|
||||
.subhyphae__link:hover, .relative-hyphae__link:hover, .backlinks__link:hover { background-color: #444; }
|
||||
|
||||
.header-links__link, .header-links__link:visited,
|
||||
.prevnext__el, .prevnext__el:visited { color: #ddd; }
|
||||
@ -270,3 +280,5 @@ mark { background: rgba(130, 80, 30, 5); color: inherit; }
|
||||
.hypha-tabs { background-color: #232323; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
19
assets/devconfig.ini
Normal file
19
assets/devconfig.ini
Normal file
@ -0,0 +1,19 @@
|
||||
WikiName = Mycorrhiza (dev)
|
||||
NaviTitleIcon = 🧑💻
|
||||
|
||||
[Hyphae]
|
||||
HomeHypha = home
|
||||
UserHypha = u
|
||||
HeaderLinksHypha = header-links
|
||||
|
||||
[Network]
|
||||
HTTPPort = 1737
|
||||
URL = http://localhost:1737
|
||||
|
||||
[Authorization]
|
||||
UseFixedAuth = true
|
||||
FixedAuthCredentialsPath = mycocredentials.json
|
||||
|
||||
UseRegistration = true
|
||||
RegistrationCredentialsPath = mycoregistration.json
|
||||
LimitRegistration = 3
|
17
assets/icon/feed-icon.svg
Normal file
17
assets/icon/feed-icon.svg
Normal file
@ -0,0 +1,17 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
id="RSSicon"
|
||||
viewBox="0 0 8 8" width="256" height="256">
|
||||
|
||||
<title>RSS feed icon</title>
|
||||
|
||||
<style type="text/css">
|
||||
.button {stroke: none; fill: orange;}
|
||||
.symbol {stroke: none; fill: white;}
|
||||
</style>
|
||||
|
||||
<rect class="button" width="8" height="8" rx="1.5" />
|
||||
<circle class="symbol" cx="2" cy="6" r="1" />
|
||||
<path class="symbol" d="m 1,4 a 3,3 0 0 1 3,3 h 1 a 4,4 0 0 0 -4,-4 z" />
|
||||
<path class="symbol" d="m 1,2 a 5,5 0 0 1 5,5 h 1 a 6,6 0 0 0 -6,-6 z" />
|
||||
|
||||
</svg>
|
After Width: | Height: | Size: 531 B |
70
assets/toolbar.js
Normal file
70
assets/toolbar.js
Normal file
@ -0,0 +1,70 @@
|
||||
const editTextarea = document.getElementsByClassName('edit-form__textarea')[0]
|
||||
|
||||
function placeCursor(position, el = editTextarea) {
|
||||
el.selectionEnd = position
|
||||
el.selectionStart = el.selectionEnd
|
||||
}
|
||||
|
||||
function getSelectedText(el = editTextarea) {
|
||||
const [start, end] = [el.selectionStart, el.selectionEnd]
|
||||
const text = el.value
|
||||
return text.substring(start, end)
|
||||
}
|
||||
|
||||
function textInserter(text, cursorPosition = null, el = editTextarea) {
|
||||
return function() {
|
||||
const [start, end] = [el.selectionStart, el.selectionEnd]
|
||||
el.setRangeText(text, start, end, 'select')
|
||||
el.focus()
|
||||
if (cursorPosition == null) {
|
||||
placeCursor(end + text.length)
|
||||
} else {
|
||||
placeCursor(end + cursorPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function selectionWrapper(cursorPosition, prefix, postfix = null, el = editTextarea) {
|
||||
return function() {
|
||||
const [start, end] = [el.selectionStart, el.selectionEnd]
|
||||
if (postfix == null) {
|
||||
postfix = prefix
|
||||
}
|
||||
let text = getSelectedText(el)
|
||||
let result = prefix + text + postfix
|
||||
el.setRangeText(result, start, end, 'select')
|
||||
el.focus()
|
||||
placeCursor(end + cursorPosition)
|
||||
}
|
||||
}
|
||||
|
||||
const wrapBold = selectionWrapper(2, '**'),
|
||||
wrapItalic = selectionWrapper(2, '//'),
|
||||
wrapMonospace = selectionWrapper(1, '`'),
|
||||
wrapHighlighted = selectionWrapper(2, '!!'),
|
||||
wrapLifted = selectionWrapper(1, '^'),
|
||||
wrapLowered = selectionWrapper(2, ',,'),
|
||||
wrapStrikethrough = selectionWrapper(2, '~~'),
|
||||
wrapLink = selectionWrapper(2, '[[', ']]')
|
||||
|
||||
const insertHorizontalBar = textInserter('\n----\n'),
|
||||
insertImgBlock = textInserter('\nimg {\n \n}\n', 10),
|
||||
insertTableBlock = textInserter('\ntable {\n \n}\n', 12),
|
||||
insertRocket = textInserter('\n=> '),
|
||||
insertXcl = textInserter('\n<= '),
|
||||
insertHeading2 = textInserter('\n## '),
|
||||
insertHeading3 = textInserter('\n### '),
|
||||
insertCodeblock = textInserter('\n```\n\n```\n', 5),
|
||||
insertBulletedList = textInserter('\n* '),
|
||||
insertNumberedList = textInserter('\n*. ')
|
||||
|
||||
function insertDate() {
|
||||
let date = new Date().toISOString().split('T')[0]
|
||||
textInserter(date)()
|
||||
}
|
||||
|
||||
function insertUserlink() {
|
||||
const userlink = document.querySelector('.header-links__entry_user a')
|
||||
const userHypha = userlink.getAttribute('href').substring(7) // no /hypha/
|
||||
textInserter('[[' + userHypha + ']]')()
|
||||
}
|
98
files/files.go
Normal file
98
files/files.go
Normal file
@ -0,0 +1,98 @@
|
||||
package files
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/adrg/xdg"
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
)
|
||||
|
||||
var paths struct {
|
||||
tokensJSON string
|
||||
registrationCredentialsJSON string
|
||||
fixedCredentialsJSON string
|
||||
}
|
||||
|
||||
func TokensJSON() string { return paths.tokensJSON }
|
||||
func RegistrationCredentialsJSON() string { return paths.registrationCredentialsJSON }
|
||||
func FixedCredentialsJSON() string { return paths.fixedCredentialsJSON }
|
||||
|
||||
// CalculatePaths looks for all external paths and stores them. Tries its best to find any errors. It is safe it to call it multiple times in order to save new paths.
|
||||
func CalculatePaths() error {
|
||||
if dir, err := registrationCredentialsPath(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
paths.registrationCredentialsJSON = dir
|
||||
}
|
||||
|
||||
if dir, err := tokenStoragePath(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
paths.tokensJSON = dir
|
||||
}
|
||||
|
||||
if dir, err := fixedCredentialsPath(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
paths.fixedCredentialsJSON = dir
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func tokenStoragePath() (string, error) {
|
||||
dir, err := xdg.DataFile("mycorrhiza/tokens.json")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if strings.HasPrefix(dir, util.WikiDir) {
|
||||
return "", errors.New("wiki storage directory includes private config files")
|
||||
}
|
||||
return dir, nil
|
||||
}
|
||||
|
||||
func registrationCredentialsPath() (string, error) {
|
||||
var err error
|
||||
path := util.RegistrationCredentialsPath
|
||||
|
||||
if len(path) == 0 {
|
||||
path, err = xdg.DataFile("mycorrhiza/registration.json")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot get a file to registration credentials, so no registered users will be saved: %w", err)
|
||||
}
|
||||
} else {
|
||||
path, err = homedir.Expand(path)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot expand RegistrationCredentialsPath: %w", err)
|
||||
}
|
||||
|
||||
path, err = filepath.Abs(path)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot expand RegistrationCredentialsPath: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return path, nil
|
||||
}
|
||||
|
||||
func fixedCredentialsPath() (string, error) {
|
||||
var err error
|
||||
path := util.FixedCredentialsPath
|
||||
|
||||
if len(path) > 0 {
|
||||
path, err = homedir.Expand(path)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot expand FixedAuthCredentialsPath: %w", err)
|
||||
}
|
||||
|
||||
path, err = filepath.Abs(path)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot expand FixedAuthCredentialsPath: %w", err)
|
||||
}
|
||||
}
|
||||
return path, nil
|
||||
}
|
18
flag.go
18
flag.go
@ -8,23 +8,12 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/assets"
|
||||
"github.com/bouncepaw/mycorrhiza/user"
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
)
|
||||
|
||||
var printExampleConfig bool
|
||||
|
||||
func init() {
|
||||
// flag.StringVar(&util.URL, "url", "http://0.0.0.0:$port", "URL at which your wiki can be found. Used to generate feeds and social media previews")
|
||||
// flag.StringVar(&util.ServerPort, "port", "1737", "Port to serve the wiki at using HTTP")
|
||||
// flag.StringVar(&util.HomePage, "home", "home", "The home page name")
|
||||
// flag.StringVar(&util.SiteNavIcon, "icon", "🍄", "What to show in the navititle in the beginning, before the colon")
|
||||
// flag.StringVar(&util.SiteName, "name", "wiki", "What is the name of your wiki")
|
||||
// flag.StringVar(&util.UserHypha, "user-hypha", "u", "Hypha which is a superhypha of all user pages")
|
||||
// flag.StringVar(&util.AuthMethod, "auth-method", "none", "What auth method to use. Variants: \"none\", \"fixed\"")
|
||||
// flag.StringVar(&util.FixedCredentialsPath, "fixed-credentials-path", "mycocredentials.json", "Used when -auth-method=fixed. Path to file with user credentials.")
|
||||
// flag.StringVar(&util.HeaderLinksHypha, "header-links-hypha", "", "Optional hypha that overrides the header links")
|
||||
// flag.StringVar(&util.GeminiCertPath, "gemini-cert-path", "", "Directory where you store Gemini certificates. Leave empty if you don't want to use Gemini.")
|
||||
flag.StringVar(&util.ConfigFilePath, "config-path", "", "Path to a configuration file. Leave empty if you don't want to use it.")
|
||||
flag.BoolVar(&printExampleConfig, "print-example-config", false, "If true, print an example configuration file contents and exit. You can save the output to a file and base your own configuration on it.")
|
||||
flag.Usage = func() {
|
||||
@ -51,9 +40,6 @@ func parseCliArgs() {
|
||||
log.Fatal("Error: pass a wiki directory")
|
||||
}
|
||||
|
||||
// It is ok if the path is ""
|
||||
util.ReadConfigFile(util.ConfigFilePath)
|
||||
|
||||
var err error
|
||||
WikiDir, err = filepath.Abs(args[0])
|
||||
util.WikiDir = WikiDir
|
||||
@ -68,8 +54,4 @@ func parseCliArgs() {
|
||||
util.HomePage = util.CanonicalName(util.HomePage)
|
||||
util.UserHypha = util.CanonicalName(util.UserHypha)
|
||||
util.HeaderLinksHypha = util.CanonicalName(util.HeaderLinksHypha)
|
||||
user.AuthUsed = util.UseFixedAuth
|
||||
if user.AuthUsed && util.FixedCredentialsPath != "" {
|
||||
user.ReadUsersFromFilesystem()
|
||||
}
|
||||
}
|
||||
|
6
go.mod
6
go.mod
@ -5,8 +5,12 @@ go 1.14
|
||||
require (
|
||||
git.sr.ht/~adnano/go-gemini v0.1.13
|
||||
github.com/adrg/xdg v0.2.2
|
||||
github.com/go-ini/ini v1.62.0 // indirect
|
||||
github.com/go-ini/ini v1.62.0
|
||||
github.com/gorilla/feeds v1.1.1
|
||||
github.com/kr/pretty v0.2.1 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/smartystreets/goconvey v1.6.4 // indirect
|
||||
github.com/valyala/quicktemplate v1.6.3
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
|
||||
gopkg.in/ini.v1 v1.62.0 // indirect
|
||||
)
|
||||
|
15
go.sum
15
go.sum
@ -7,8 +7,12 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-ini/ini v1.62.0 h1:7VJT/ZXjzqSrvtraFp4ONq80hTcRQth1c9ZnQ3uNQvU=
|
||||
github.com/go-ini/ini v1.62.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/feeds v1.1.1 h1:HwKXxqzcRNg9to+BbvJog4+f3s/xzvtZXICcQGutYfY=
|
||||
github.com/gorilla/feeds v1.1.1/go.mod h1:Nk0jZrvPFZX1OBe5NPiddPw7CfwF6Q9eqzaBbaightA=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/klauspost/compress v1.11.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||
@ -16,8 +20,14 @@ github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
@ -27,13 +37,18 @@ github.com/valyala/fasthttp v1.16.0/go.mod h1:YOKImeEosDdBPnxc0gy7INqi3m1zK6A+xl
|
||||
github.com/valyala/quicktemplate v1.6.3 h1:O7EuMwuH7Q94U2CXD6sOX8AYHqQqWtmIk690IhmpkKA=
|
||||
github.com/valyala/quicktemplate v1.6.3/go.mod h1:fwPzK2fHuYEODzJ9pkw0ipCPNHZ2tD5KW4lOuSdPKzY=
|
||||
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU=
|
||||
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
31
http_auth.go
31
http_auth.go
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
@ -10,12 +11,42 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
http.HandleFunc("/register", handlerRegister)
|
||||
http.HandleFunc("/login", handlerLogin)
|
||||
http.HandleFunc("/login-data", handlerLoginData)
|
||||
http.HandleFunc("/logout", handlerLogout)
|
||||
http.HandleFunc("/logout-confirm", handlerLogoutConfirm)
|
||||
}
|
||||
|
||||
func handlerRegister(w http.ResponseWriter, rq *http.Request) {
|
||||
log.Println(rq.URL)
|
||||
if !util.UseRegistration {
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
}
|
||||
if rq.Method == http.MethodGet {
|
||||
io.WriteString(
|
||||
w,
|
||||
base(
|
||||
"Register",
|
||||
views.RegisterHTML(rq),
|
||||
user.FromRequest(rq),
|
||||
),
|
||||
)
|
||||
} else if rq.Method == http.MethodPost {
|
||||
var (
|
||||
username = rq.PostFormValue("username")
|
||||
password = rq.PostFormValue("password")
|
||||
err = user.Register(username, password)
|
||||
)
|
||||
if err != nil {
|
||||
io.WriteString(w, err.Error())
|
||||
} else {
|
||||
user.LoginDataHTTP(w, rq, username, password)
|
||||
http.Redirect(w, rq, "/"+rq.URL.RawQuery, http.StatusSeeOther)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func handlerLogout(w http.ResponseWriter, rq *http.Request) {
|
||||
var (
|
||||
u = user.FromRequest(rq)
|
||||
|
52
hyphae/iteration.go
Normal file
52
hyphae/iteration.go
Normal file
@ -0,0 +1,52 @@
|
||||
package hyphae
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Iteration represents an iteration over all hyphae in the storage. You may use it instead of directly iterating using hyphae.YieldExistingHyphae when you want to do n checks at once instead of iterating n times.
|
||||
type Iteration struct {
|
||||
sync.Mutex
|
||||
iterator func() chan *Hypha
|
||||
checks []func(h *Hypha) CheckResult
|
||||
}
|
||||
|
||||
func NewIteration() *Iteration {
|
||||
return &Iteration{
|
||||
iterator: YieldExistingHyphae,
|
||||
checks: make([]func(h *Hypha) CheckResult, 0),
|
||||
}
|
||||
}
|
||||
|
||||
// AddCheck adds the check to the iteration. It is concurrent-safe.
|
||||
func (i7n *Iteration) AddCheck(check func(h *Hypha) CheckResult) {
|
||||
i7n.Lock()
|
||||
i7n.checks = append(i7n.checks, check)
|
||||
i7n.Unlock()
|
||||
}
|
||||
|
||||
func (i7n *Iteration) removeCheck(i int) {
|
||||
i7n.checks[i] = i7n.checks[len(i7n.checks)-1]
|
||||
i7n.checks = i7n.checks[:len(i7n.checks)-1]
|
||||
}
|
||||
|
||||
// Ignite does the iteration by walking over all hyphae yielded by the iterator used and calling all checks on the hypha. Ignited iterations are not concurrent-safe.
|
||||
func (i7n *Iteration) Ignite() {
|
||||
for h := range i7n.iterator() {
|
||||
for i, check := range i7n.checks {
|
||||
if res := check(h); res == CheckForgetMe {
|
||||
i7n.removeCheck(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CheckResult is a result of an iteration check.
|
||||
type CheckResult int
|
||||
|
||||
const (
|
||||
// CheckContinue is returned when the check wants to be used next time too.
|
||||
CheckContinue CheckResult = iota
|
||||
// CheckForgetMe is returned when the check wants to be forgotten and not used anymore.
|
||||
CheckForgetMe
|
||||
)
|
13
link/link.go
13
link/link.go
@ -66,7 +66,7 @@ func (l *Link) Classes() string {
|
||||
func (l *Link) Href() string {
|
||||
switch l.Kind {
|
||||
case LinkExternal, LinkLocalRoot:
|
||||
return l.Address
|
||||
return l.Address + l.Anchor
|
||||
default:
|
||||
return "/hypha/" + l.Address + l.Anchor
|
||||
}
|
||||
@ -97,7 +97,7 @@ func From(address, display, hyphaName string) *Link {
|
||||
link.Display = strings.TrimSpace(display)
|
||||
}
|
||||
|
||||
if pos := strings.IndexRune(address, '#'); pos != -1 {
|
||||
if pos := strings.IndexRune(address, '#'); pos != -1 && pos != 0 {
|
||||
link.Anchor = address[pos:]
|
||||
address = address[:pos]
|
||||
}
|
||||
@ -113,8 +113,13 @@ func From(address, display, hyphaName string) *Link {
|
||||
if strings.HasPrefix(link.Display, "//") && len(link.Display) > 2 {
|
||||
link.Display = link.Display[2:]
|
||||
}
|
||||
link.Display += link.Anchor
|
||||
}
|
||||
link.Address = address
|
||||
case strings.HasPrefix(address, "#"):
|
||||
link.Kind = LinkLocalHypha
|
||||
link.Address = util.CanonicalName(hyphaName)
|
||||
link.Anchor = address
|
||||
case strings.HasPrefix(address, "/"):
|
||||
link.Address = address
|
||||
link.Kind = LinkLocalRoot
|
||||
@ -124,10 +129,6 @@ func From(address, display, hyphaName string) *Link {
|
||||
case strings.HasPrefix(address, "../"):
|
||||
link.Kind = LinkLocalHypha
|
||||
link.Address = util.CanonicalName(path.Join(path.Dir(hyphaName), address[3:]))
|
||||
case strings.HasPrefix(address, "#"):
|
||||
link.Kind = LinkLocalHypha
|
||||
link.Address = util.CanonicalName(hyphaName)
|
||||
link.Anchor = address
|
||||
default:
|
||||
link.Kind = LinkLocalHypha
|
||||
link.Address = util.CanonicalName(address)
|
||||
|
24
main.go
24
main.go
@ -1,6 +1,7 @@
|
||||
//go:generate go get -u github.com/valyala/quicktemplate/qtc
|
||||
//go:generate qtc -dir=assets
|
||||
//go:generate qtc -dir=views
|
||||
//go:generate qtc -dir=tree
|
||||
package main
|
||||
|
||||
import (
|
||||
@ -13,6 +14,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/assets"
|
||||
"github.com/bouncepaw/mycorrhiza/files"
|
||||
"github.com/bouncepaw/mycorrhiza/history"
|
||||
"github.com/bouncepaw/mycorrhiza/hyphae"
|
||||
"github.com/bouncepaw/mycorrhiza/shroom"
|
||||
@ -117,6 +119,12 @@ func handlerStyle(w http.ResponseWriter, rq *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
func handlerToolbar(w http.ResponseWriter, rq *http.Request) {
|
||||
log.Println(rq.URL)
|
||||
w.Header().Set("Content-Type", "text/javascript;charset=utf-8")
|
||||
w.Write([]byte(assets.ToolbarJS()))
|
||||
}
|
||||
|
||||
func handlerIcon(w http.ResponseWriter, rq *http.Request) {
|
||||
iconName := strings.TrimPrefix(rq.URL.Path, "/static/icon/")
|
||||
if iconName == "https" {
|
||||
@ -139,6 +147,8 @@ func handlerIcon(w http.ResponseWriter, rq *http.Request) {
|
||||
w.Write([]byte(assets.IconMailto()))
|
||||
case "gopher":
|
||||
w.Write([]byte(assets.IconGopher()))
|
||||
case "feed":
|
||||
w.Write([]byte(assets.IconFeed()))
|
||||
default:
|
||||
w.Write([]byte(assets.IconHTTP()))
|
||||
}
|
||||
@ -169,7 +179,15 @@ Crawl-delay: 5`))
|
||||
|
||||
func main() {
|
||||
parseCliArgs()
|
||||
log.Println("Running MycorrhizaWiki β")
|
||||
|
||||
// It is ok if the path is ""
|
||||
util.ReadConfigFile(util.ConfigFilePath)
|
||||
|
||||
if err := files.CalculatePaths(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Println("Running MycorrhizaWiki")
|
||||
if err := os.Chdir(WikiDir); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -177,6 +195,9 @@ func main() {
|
||||
hyphae.Index(WikiDir)
|
||||
log.Println("Indexed", hyphae.Count(), "hyphae")
|
||||
|
||||
// Initialize user database
|
||||
user.InitUserDatabase()
|
||||
|
||||
history.Start(WikiDir)
|
||||
shroom.SetHeaderLinks()
|
||||
|
||||
@ -199,6 +220,7 @@ func main() {
|
||||
http.ServeFile(w, rq, WikiDir+"/static/favicon.ico")
|
||||
})
|
||||
http.HandleFunc("/static/common.css", handlerStyle)
|
||||
http.HandleFunc("/static/toolbar.js", handlerToolbar)
|
||||
http.HandleFunc("/static/icon/", handlerIcon)
|
||||
http.HandleFunc("/robots.txt", handlerRobotsTxt)
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, rq *http.Request) {
|
||||
|
@ -31,6 +31,7 @@ type GemLexerState struct {
|
||||
// Temporaries
|
||||
img *Img
|
||||
table *Table
|
||||
list *List
|
||||
}
|
||||
|
||||
type Line struct {
|
||||
@ -64,12 +65,6 @@ func lineToAST(line string, state *GemLexerState, ast *[]Line) {
|
||||
// Process empty lines depending on the current state
|
||||
if "" == strings.TrimSpace(line) {
|
||||
switch state.where {
|
||||
case "list":
|
||||
state.where = ""
|
||||
addLine(state.buf + "</ul>")
|
||||
case "number":
|
||||
state.where = ""
|
||||
addLine(state.buf + "</ol>")
|
||||
case "pre":
|
||||
state.buf += "\n"
|
||||
case "launchpad":
|
||||
@ -95,12 +90,10 @@ func lineToAST(line string, state *GemLexerState, ast *[]Line) {
|
||||
goto imgState
|
||||
case "table":
|
||||
goto tableState
|
||||
case "pre":
|
||||
goto preformattedState
|
||||
case "list":
|
||||
goto listState
|
||||
case "number":
|
||||
goto numberState
|
||||
case "pre":
|
||||
goto preformattedState
|
||||
case "launchpad":
|
||||
goto launchpadState
|
||||
default: // "p" or ""
|
||||
@ -121,6 +114,14 @@ tableState:
|
||||
}
|
||||
return
|
||||
|
||||
listState:
|
||||
if done := state.list.Parse(line); done {
|
||||
state.list.Finalize()
|
||||
state.where = ""
|
||||
goto normalState
|
||||
}
|
||||
return
|
||||
|
||||
preformattedState:
|
||||
switch {
|
||||
case startsWith("```"):
|
||||
@ -133,38 +134,6 @@ preformattedState:
|
||||
}
|
||||
return
|
||||
|
||||
listState:
|
||||
switch {
|
||||
case startsWith("* "):
|
||||
state.buf += fmt.Sprintf("\t<li>%s</li>\n", ParagraphToHtml(state.name, line[2:]))
|
||||
case startsWith("```"):
|
||||
state.where = "pre"
|
||||
addLine(state.buf + "</ul>")
|
||||
state.id++
|
||||
state.buf = fmt.Sprintf("<pre id='%d' alt='%s' class='codeblock'><code>", state.id, strings.TrimPrefix(line, "```"))
|
||||
default:
|
||||
state.where = ""
|
||||
addLine(state.buf + "</ul>")
|
||||
goto normalState
|
||||
}
|
||||
return
|
||||
|
||||
numberState:
|
||||
switch {
|
||||
case startsWith("*. "):
|
||||
state.buf += fmt.Sprintf("\t<li>%s</li>\n", ParagraphToHtml(state.name, line[3:]))
|
||||
case startsWith("```"):
|
||||
state.where = "pre"
|
||||
addLine(state.buf + "</ol>")
|
||||
state.id++
|
||||
state.buf = fmt.Sprintf("<pre id='%d' alt='%s' class='codeblock'><code>", state.id, strings.TrimPrefix(line, "```"))
|
||||
default:
|
||||
state.where = ""
|
||||
addLine(state.buf + "</ol>")
|
||||
goto normalState
|
||||
}
|
||||
return
|
||||
|
||||
launchpadState:
|
||||
switch {
|
||||
case startsWith("=>"):
|
||||
@ -190,16 +159,6 @@ normalState:
|
||||
addParagraphIfNeeded()
|
||||
state.where = "pre"
|
||||
state.buf = fmt.Sprintf("<pre id='%d' alt='%s' class='codeblock'><code>", state.id, strings.TrimPrefix(line, "```"))
|
||||
case startsWith("* "):
|
||||
addParagraphIfNeeded()
|
||||
state.where = "list"
|
||||
state.buf = fmt.Sprintf("<ul id='%d'>\n", state.id)
|
||||
goto listState
|
||||
case startsWith("*. "):
|
||||
addParagraphIfNeeded()
|
||||
state.where = "number"
|
||||
state.buf = fmt.Sprintf("<ol id='%d'>\n", state.id)
|
||||
goto numberState
|
||||
|
||||
case startsWith("###### "):
|
||||
addParagraphIfNeeded()
|
||||
@ -241,6 +200,12 @@ normalState:
|
||||
case MatchesHorizontalLine(line):
|
||||
addParagraphIfNeeded()
|
||||
*ast = append(*ast, Line{id: -1, contents: "<hr/>"})
|
||||
case MatchesList(line):
|
||||
addParagraphIfNeeded()
|
||||
list, _ := NewList(line, state.name)
|
||||
state.where = "list"
|
||||
state.list = list
|
||||
addLine(state.list)
|
||||
case MatchesImg(line):
|
||||
addParagraphIfNeeded()
|
||||
img, shouldGoBackToNormal := ImgFromFirstLine(line, state.name)
|
||||
|
171
markup/list.go
Normal file
171
markup/list.go
Normal file
@ -0,0 +1,171 @@
|
||||
package markup
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func parseListItem(line string) (level int, offset int, ordered bool, err error) {
|
||||
for line[level] == '*' {
|
||||
level++
|
||||
}
|
||||
|
||||
if line[level] == '.' {
|
||||
ordered = true
|
||||
offset = level + 2
|
||||
} else {
|
||||
ordered = false
|
||||
offset = level + 1
|
||||
}
|
||||
|
||||
if line[offset-1] != ' ' || len(line) < offset+2 || level < 1 || level > 6 {
|
||||
err = errors.New("ill-formatted list item")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func MatchesList(line string) bool {
|
||||
level, _, _, err := parseListItem(line)
|
||||
return err == nil && level == 1
|
||||
}
|
||||
|
||||
type listItem struct {
|
||||
content string
|
||||
parent *listItem
|
||||
children []*listItem
|
||||
depth int
|
||||
}
|
||||
|
||||
func newListItem(parent *listItem) *listItem {
|
||||
depth := 0
|
||||
if parent != nil {
|
||||
depth = parent.depth + 1
|
||||
}
|
||||
return &listItem{
|
||||
parent: parent,
|
||||
children: make([]*listItem, 0),
|
||||
depth: depth,
|
||||
}
|
||||
}
|
||||
|
||||
func (item *listItem) renderAsHtmlTo(b *strings.Builder, hyphaName string, ordered bool) {
|
||||
if len(item.content) > 0 {
|
||||
b.WriteString("<li>")
|
||||
b.WriteString(ParagraphToHtml(hyphaName, item.content))
|
||||
}
|
||||
|
||||
if len(item.children) > 0 {
|
||||
if ordered {
|
||||
b.WriteString("<ol>")
|
||||
} else {
|
||||
b.WriteString("<ul>")
|
||||
}
|
||||
|
||||
for _, child := range item.children {
|
||||
child.renderAsHtmlTo(b, hyphaName, ordered)
|
||||
}
|
||||
|
||||
if ordered {
|
||||
b.WriteString("</ol>")
|
||||
} else {
|
||||
b.WriteString("</ul>")
|
||||
}
|
||||
}
|
||||
|
||||
if len(item.content) > 0 {
|
||||
b.WriteString("</li>")
|
||||
}
|
||||
}
|
||||
|
||||
// A structure representing ordered and unordered lists in the AST.
|
||||
type List struct {
|
||||
curr *listItem
|
||||
hyphaName string
|
||||
ordered bool
|
||||
finalized bool
|
||||
}
|
||||
|
||||
func NewList(line, hyphaName string) (*List, bool) {
|
||||
list := &List{
|
||||
hyphaName: hyphaName,
|
||||
curr: newListItem(nil),
|
||||
}
|
||||
return list, list.Parse(line)
|
||||
}
|
||||
|
||||
func (list *List) pushItem() {
|
||||
item := newListItem(list.curr)
|
||||
list.curr.children = append(list.curr.children, item)
|
||||
list.curr = item
|
||||
}
|
||||
|
||||
func (list *List) popItem() {
|
||||
if list.curr == nil {
|
||||
return
|
||||
}
|
||||
list.curr = list.curr.parent
|
||||
}
|
||||
|
||||
func (list *List) balance(level int) {
|
||||
for level > list.curr.depth {
|
||||
list.pushItem()
|
||||
}
|
||||
|
||||
for level < list.curr.depth {
|
||||
list.popItem()
|
||||
}
|
||||
}
|
||||
|
||||
func (list *List) Parse(line string) (done bool) {
|
||||
level, offset, ordered, err := parseListItem(line)
|
||||
if err != nil {
|
||||
list.Finalize()
|
||||
return true
|
||||
}
|
||||
|
||||
// update ordered flag if the current node is the root one
|
||||
// (i.e. no parsing has been done yet)
|
||||
if list.curr.parent == nil {
|
||||
list.ordered = ordered
|
||||
}
|
||||
|
||||
// if list type has suddenly changed (ill-formatted list), quit
|
||||
if ordered != list.ordered {
|
||||
list.Finalize()
|
||||
return true
|
||||
}
|
||||
|
||||
list.balance(level)
|
||||
|
||||
// if the current node already has content, create a new one
|
||||
// to prevent overwriting existing content (effectively creating
|
||||
// a new sibling node)
|
||||
if len(list.curr.content) > 0 {
|
||||
list.popItem()
|
||||
list.pushItem()
|
||||
}
|
||||
|
||||
list.curr.content = line[offset:]
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (list *List) Finalize() {
|
||||
if !list.finalized {
|
||||
// close all opened nodes, effectively going up to the root node
|
||||
list.balance(0)
|
||||
list.finalized = true
|
||||
}
|
||||
}
|
||||
|
||||
func (list *List) RenderAsHtml() (html string) {
|
||||
// for a good measure
|
||||
list.Finalize()
|
||||
|
||||
b := &strings.Builder{}
|
||||
|
||||
// fire up recursive render process
|
||||
list.curr.renderAsHtmlTo(b, list.hyphaName, list.ordered)
|
||||
|
||||
return b.String()
|
||||
}
|
@ -15,6 +15,8 @@ func Parse(ast []Line, from, to int, recursionLevel int) (html string) {
|
||||
html += v.ToHtml()
|
||||
case Table:
|
||||
html += v.asHtml()
|
||||
case *List:
|
||||
html += v.RenderAsHtml()
|
||||
case string:
|
||||
html += v
|
||||
default:
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 133b2689fbd67cad274f1c10fc6cbe8adbfc156a
|
||||
Subproject commit 515634c88a51a616f486dfefc2a7b9e6ca692689
|
206
tree/tree.go
206
tree/tree.go
@ -5,136 +5,134 @@ import (
|
||||
"path"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/hyphae"
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
)
|
||||
|
||||
type sibling struct {
|
||||
name string
|
||||
hasChildren bool
|
||||
}
|
||||
func findSiblingsAndDescendants(hyphaName string) ([]*sibling, map[string]bool) {
|
||||
var (
|
||||
siblings = []*sibling{&sibling{hyphaName, 0, 0}}
|
||||
siblingCheck = func(h *hyphae.Hypha) hyphae.CheckResult {
|
||||
if path.Dir(hyphaName) == path.Dir(h.Name) && h.Name != hyphaName {
|
||||
siblings = append(siblings, &sibling{h.Name, 0, 0})
|
||||
}
|
||||
return hyphae.CheckContinue
|
||||
}
|
||||
|
||||
func (s *sibling) checkThisChild(hyphaName string) {
|
||||
if !s.hasChildren && path.Dir(hyphaName) == s.name {
|
||||
s.hasChildren = true
|
||||
}
|
||||
}
|
||||
descendantsPool = make(map[string]bool, 0)
|
||||
descendantCheck = func(h *hyphae.Hypha) hyphae.CheckResult {
|
||||
if strings.HasPrefix(h.Name, hyphaName+"/") {
|
||||
descendantsPool[h.Name] = true
|
||||
}
|
||||
return hyphae.CheckContinue
|
||||
}
|
||||
|
||||
func (s *sibling) asHTML() string {
|
||||
class := "navitree__entry navitree__sibling"
|
||||
if s.hasChildren {
|
||||
class += " navitree__sibling_fertile navitree__entry_fertile"
|
||||
} else {
|
||||
class += " navitree__sibling_infertile navitree__entry_infertile"
|
||||
}
|
||||
return fmt.Sprintf(
|
||||
`<li class="%s"><a class="navitree__link" href="/hypha/%s">%s</a></li>`,
|
||||
class,
|
||||
s.name,
|
||||
util.BeautifulName(path.Base(s.name)),
|
||||
i7n = hyphae.NewIteration()
|
||||
)
|
||||
}
|
||||
|
||||
type mainFamilyMember struct {
|
||||
name string
|
||||
children []*mainFamilyMember
|
||||
}
|
||||
|
||||
func (m *mainFamilyMember) checkThisChild(hyphaName string) (adopted bool) {
|
||||
if path.Dir(hyphaName) == m.name {
|
||||
m.children = append(m.children, &mainFamilyMember{
|
||||
name: hyphaName,
|
||||
children: make([]*mainFamilyMember, 0),
|
||||
})
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *mainFamilyMember) asHTML() string {
|
||||
if len(m.children) == 0 {
|
||||
return fmt.Sprintf(`<li class="subhyphae__entry"><a class="subhyphae__link" href="/hypha/%s">%s</a></li>`, m.name, util.BeautifulName(path.Base(m.name)))
|
||||
}
|
||||
sort.Slice(m.children, func(i, j int) bool {
|
||||
return m.children[i].name < m.children[j].name
|
||||
i7n.AddCheck(siblingCheck)
|
||||
i7n.AddCheck(descendantCheck)
|
||||
i7n.Ignite()
|
||||
sort.Slice(siblings, func(i, j int) bool {
|
||||
return siblings[i].name < siblings[j].name
|
||||
})
|
||||
html := fmt.Sprintf(`<li class="subhyphae__entry"><a class="subhyphae__link" href="/hypha/%s">%s</a><ul>`, m.name, util.BeautifulName(path.Base(m.name)))
|
||||
for _, child := range m.children {
|
||||
html += child.asHTML()
|
||||
}
|
||||
return html + `</li></ul></li>`
|
||||
return siblings, descendantsPool
|
||||
}
|
||||
|
||||
func mainFamilyFromPool(hyphaName string, subhyphaePool map[string]bool) *mainFamilyMember {
|
||||
func countSubhyphae(siblings []*sibling) {
|
||||
var (
|
||||
subhyphaCheck = func(h *hyphae.Hypha) hyphae.CheckResult {
|
||||
for _, s := range siblings {
|
||||
if path.Dir(h.Name) == s.name {
|
||||
s.directSubhyphaeCount++
|
||||
return hyphae.CheckContinue
|
||||
} else if strings.HasPrefix(h.Name, s.name+"/") {
|
||||
s.indirectSubhyphaeCount++
|
||||
return hyphae.CheckContinue
|
||||
}
|
||||
}
|
||||
return hyphae.CheckContinue
|
||||
}
|
||||
i7n = hyphae.NewIteration()
|
||||
)
|
||||
i7n.AddCheck(subhyphaCheck)
|
||||
i7n.Ignite()
|
||||
}
|
||||
|
||||
// Tree generates a tree for `hyphaName` as html and returns next and previous hyphae if any.
|
||||
func Tree(hyphaName string) (siblingsHTML, childrenHTML, prev, next string) {
|
||||
children := make([]child, 0)
|
||||
I := 0
|
||||
// The tree is generated in two iterations of hyphae storage:
|
||||
// 1. Find all siblings (sorted) and descendants' names
|
||||
// 2. Count how many subhyphae siblings have
|
||||
//
|
||||
// We also have to figure out what is going on with the descendants: who is a child of whom. We do that in parallel with (2) because we can.
|
||||
// One of the siblings is the hypha with name `hyphaName`
|
||||
siblings, descendantsPool := findSiblingsAndDescendants(hyphaName)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(2)
|
||||
go func() {
|
||||
countSubhyphae(siblings)
|
||||
wg.Done()
|
||||
}()
|
||||
go func() {
|
||||
children = figureOutChildren(hyphaName, descendantsPool).children
|
||||
wg.Done()
|
||||
}()
|
||||
wg.Wait()
|
||||
|
||||
for i, s := range siblings {
|
||||
if s.name == hyphaName {
|
||||
I = i
|
||||
siblingsHTML += fmt.Sprintf(`<li class="relative-hyphae__entry relative-hyphae__entry_this"><span>%s</span></li>`, util.BeautifulName(path.Base(hyphaName)))
|
||||
} else {
|
||||
siblingsHTML += siblingHTML(s)
|
||||
}
|
||||
}
|
||||
if I != 0 && len(siblings) > 1 {
|
||||
prev = siblings[I-1].name
|
||||
}
|
||||
if I != len(siblings)-1 && len(siblings) > 1 {
|
||||
next = siblings[I+1].name
|
||||
}
|
||||
return fmt.Sprintf(`<ul class="relative-hyphae__list">%s</ul>`, siblingsHTML), subhyphaeMatrix(children), prev, next
|
||||
}
|
||||
|
||||
type child struct {
|
||||
name string
|
||||
children []child
|
||||
}
|
||||
|
||||
func figureOutChildren(hyphaName string, subhyphaePool map[string]bool) child {
|
||||
var (
|
||||
nestLevel = strings.Count(hyphaName, "/")
|
||||
adopted = make([]*mainFamilyMember, 0)
|
||||
adopted = make([]child, 0)
|
||||
)
|
||||
for subhyphaName, _ := range subhyphaePool {
|
||||
subnestLevel := strings.Count(subhyphaName, "/")
|
||||
if subnestLevel-1 == nestLevel && path.Dir(subhyphaName) == hyphaName {
|
||||
delete(subhyphaePool, subhyphaName)
|
||||
adopted = append(adopted, mainFamilyFromPool(subhyphaName, subhyphaePool))
|
||||
adopted = append(adopted, figureOutChildren(subhyphaName, subhyphaePool))
|
||||
}
|
||||
}
|
||||
return &mainFamilyMember{name: hyphaName, children: adopted}
|
||||
return child{hyphaName, adopted}
|
||||
}
|
||||
|
||||
func subhyphaeMatrix(hyphaName string, subhyphaePool map[string]bool) string {
|
||||
var html string
|
||||
children := mainFamilyFromPool(hyphaName, subhyphaePool).children
|
||||
type sibling struct {
|
||||
name string
|
||||
directSubhyphaeCount int
|
||||
indirectSubhyphaeCount int
|
||||
}
|
||||
|
||||
func subhyphaeMatrix(children []child) (html string) {
|
||||
sort.Slice(children, func(i, j int) bool {
|
||||
return children[i].name < children[j].name
|
||||
})
|
||||
for _, child := range children {
|
||||
html += child.asHTML()
|
||||
html += childHTML(&child)
|
||||
}
|
||||
return html
|
||||
}
|
||||
|
||||
// Tree generates a tree for `hyphaName` as html and returns next and previous hyphae if any.
|
||||
func Tree(hyphaName string) (relatives, subhyphae, prev, next string) {
|
||||
var (
|
||||
// One of the siblings is the hypha with name `hyphaName`
|
||||
siblings = findSiblings(hyphaName)
|
||||
subhyphaePool = make(map[string]bool)
|
||||
I int
|
||||
)
|
||||
for h := range hyphae.YieldExistingHyphae() {
|
||||
for _, s := range siblings {
|
||||
s.checkThisChild(h.Name)
|
||||
}
|
||||
if strings.HasPrefix(h.Name, hyphaName+"/") {
|
||||
subhyphaePool[h.Name] = true
|
||||
}
|
||||
}
|
||||
for i, s := range siblings {
|
||||
if s.name == hyphaName {
|
||||
I = i
|
||||
relatives += fmt.Sprintf(`<li class="navitree__entry navitree__entry_this"><span>%s</span></li>`, util.BeautifulName(path.Base(hyphaName)))
|
||||
} else {
|
||||
relatives += s.asHTML()
|
||||
}
|
||||
}
|
||||
if I != 0 {
|
||||
prev = siblings[I-1].name
|
||||
}
|
||||
if I != len(siblings)-1 {
|
||||
next = siblings[I+1].name
|
||||
}
|
||||
return fmt.Sprintf(`<ul class="navitree">%s</ul>`, relatives), subhyphaeMatrix(hyphaName, subhyphaePool), prev, next
|
||||
}
|
||||
|
||||
func findSiblings(hyphaName string) []*sibling {
|
||||
siblings := []*sibling{&sibling{name: hyphaName, hasChildren: true}}
|
||||
for h := range hyphae.YieldExistingHyphae() {
|
||||
if path.Dir(hyphaName) == path.Dir(h.Name) && hyphaName != h.Name {
|
||||
siblings = append(siblings, &sibling{name: h.Name, hasChildren: false})
|
||||
}
|
||||
}
|
||||
sort.Slice(siblings, func(i, j int) bool {
|
||||
return siblings[i].name < siblings[j].name
|
||||
})
|
||||
return siblings
|
||||
}
|
||||
|
55
tree/view.qtpl
Normal file
55
tree/view.qtpl
Normal file
@ -0,0 +1,55 @@
|
||||
{% import "sort" %}
|
||||
{% import "path" %}
|
||||
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
||||
|
||||
{% func TreeHTML() %}
|
||||
{% endfunc %}
|
||||
|
||||
Subhyphae links are recursive. It may end up looking like that if drawn with
|
||||
pseudographics:
|
||||
╔══════════════╗
|
||||
║Foo ║ The presented hyphae are foo and foo/bar
|
||||
║╔════════════╗║
|
||||
║║Bar ║║
|
||||
║╚════════════╝║
|
||||
╚══════════════╝
|
||||
{% func childHTML(c *child) %}
|
||||
{% code
|
||||
sort.Slice(c.children, func(i, j int) bool {
|
||||
return c.children[i].name < c.children[j].name
|
||||
})
|
||||
%}
|
||||
<li class="subhyphae__entry">
|
||||
<a class="subhyphae__link" href="/hypha/{%s c.name %}">
|
||||
{%s util.BeautifulName(path.Base(c.name)) %}
|
||||
</a>
|
||||
{% if len(c.children) > 0 %}
|
||||
<ul>
|
||||
{% for _, child := range c.children %}
|
||||
{%s= childHTML(&child) %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfunc %}
|
||||
|
||||
|
||||
{% func siblingHTML(s *sibling) %}
|
||||
<li class="relative-hyphae__entry">
|
||||
<a class="relative-hyphae__link" href="/hypha/{%s s.name %}">
|
||||
{%s util.BeautifulName(path.Base(s.name)) %}
|
||||
<span class="relative-hyphae__count">
|
||||
{% if s.directSubhyphaeCount > 0 %}
|
||||
<span class="relative-hyphae__direct-count">
|
||||
{%d s.directSubhyphaeCount %}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if s.indirectSubhyphaeCount > 0 %}
|
||||
<span class="relative-hyphae__indirect-count">
|
||||
({%d s.indirectSubhyphaeCount %})
|
||||
</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endfunc %}
|
235
tree/view.qtpl.go
Normal file
235
tree/view.qtpl.go
Normal file
@ -0,0 +1,235 @@
|
||||
// Code generated by qtc from "view.qtpl". DO NOT EDIT.
|
||||
// See https://github.com/valyala/quicktemplate for details.
|
||||
|
||||
//line tree/view.qtpl:1
|
||||
package tree
|
||||
|
||||
//line tree/view.qtpl:1
|
||||
import "sort"
|
||||
|
||||
//line tree/view.qtpl:2
|
||||
import "path"
|
||||
|
||||
//line tree/view.qtpl:3
|
||||
import "github.com/bouncepaw/mycorrhiza/util"
|
||||
|
||||
//line tree/view.qtpl:5
|
||||
import (
|
||||
qtio422016 "io"
|
||||
|
||||
qt422016 "github.com/valyala/quicktemplate"
|
||||
)
|
||||
|
||||
//line tree/view.qtpl:5
|
||||
var (
|
||||
_ = qtio422016.Copy
|
||||
_ = qt422016.AcquireByteBuffer
|
||||
)
|
||||
|
||||
//line tree/view.qtpl:5
|
||||
func StreamTreeHTML(qw422016 *qt422016.Writer) {
|
||||
//line tree/view.qtpl:5
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line tree/view.qtpl:6
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:6
|
||||
func WriteTreeHTML(qq422016 qtio422016.Writer) {
|
||||
//line tree/view.qtpl:6
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line tree/view.qtpl:6
|
||||
StreamTreeHTML(qw422016)
|
||||
//line tree/view.qtpl:6
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line tree/view.qtpl:6
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:6
|
||||
func TreeHTML() string {
|
||||
//line tree/view.qtpl:6
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line tree/view.qtpl:6
|
||||
WriteTreeHTML(qb422016)
|
||||
//line tree/view.qtpl:6
|
||||
qs422016 := string(qb422016.B)
|
||||
//line tree/view.qtpl:6
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line tree/view.qtpl:6
|
||||
return qs422016
|
||||
//line tree/view.qtpl:6
|
||||
}
|
||||
|
||||
// Subhyphae links are recursive. It may end up looking like that if drawn with
|
||||
// pseudographics:
|
||||
// ╔══════════════╗
|
||||
// ║Foo ║ The presented hyphae are foo and foo/bar
|
||||
// ║╔════════════╗║
|
||||
// ║║Bar ║║
|
||||
// ║╚════════════╝║
|
||||
// ╚══════════════╝
|
||||
|
||||
//line tree/view.qtpl:16
|
||||
func streamchildHTML(qw422016 *qt422016.Writer, c *child) {
|
||||
//line tree/view.qtpl:16
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line tree/view.qtpl:18
|
||||
sort.Slice(c.children, func(i, j int) bool {
|
||||
return c.children[i].name < c.children[j].name
|
||||
})
|
||||
|
||||
//line tree/view.qtpl:21
|
||||
qw422016.N().S(`
|
||||
<li class="subhyphae__entry">
|
||||
<a class="subhyphae__link" href="/hypha/`)
|
||||
//line tree/view.qtpl:23
|
||||
qw422016.E().S(c.name)
|
||||
//line tree/view.qtpl:23
|
||||
qw422016.N().S(`">
|
||||
`)
|
||||
//line tree/view.qtpl:24
|
||||
qw422016.E().S(util.BeautifulName(path.Base(c.name)))
|
||||
//line tree/view.qtpl:24
|
||||
qw422016.N().S(`
|
||||
</a>
|
||||
`)
|
||||
//line tree/view.qtpl:26
|
||||
if len(c.children) > 0 {
|
||||
//line tree/view.qtpl:26
|
||||
qw422016.N().S(`
|
||||
<ul>
|
||||
`)
|
||||
//line tree/view.qtpl:28
|
||||
for _, child := range c.children {
|
||||
//line tree/view.qtpl:28
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line tree/view.qtpl:29
|
||||
qw422016.N().S(childHTML(&child))
|
||||
//line tree/view.qtpl:29
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line tree/view.qtpl:30
|
||||
}
|
||||
//line tree/view.qtpl:30
|
||||
qw422016.N().S(`
|
||||
</ul>
|
||||
`)
|
||||
//line tree/view.qtpl:32
|
||||
}
|
||||
//line tree/view.qtpl:32
|
||||
qw422016.N().S(`
|
||||
</li>
|
||||
`)
|
||||
//line tree/view.qtpl:34
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:34
|
||||
func writechildHTML(qq422016 qtio422016.Writer, c *child) {
|
||||
//line tree/view.qtpl:34
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line tree/view.qtpl:34
|
||||
streamchildHTML(qw422016, c)
|
||||
//line tree/view.qtpl:34
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line tree/view.qtpl:34
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:34
|
||||
func childHTML(c *child) string {
|
||||
//line tree/view.qtpl:34
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line tree/view.qtpl:34
|
||||
writechildHTML(qb422016, c)
|
||||
//line tree/view.qtpl:34
|
||||
qs422016 := string(qb422016.B)
|
||||
//line tree/view.qtpl:34
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line tree/view.qtpl:34
|
||||
return qs422016
|
||||
//line tree/view.qtpl:34
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:37
|
||||
func streamsiblingHTML(qw422016 *qt422016.Writer, s *sibling) {
|
||||
//line tree/view.qtpl:37
|
||||
qw422016.N().S(`
|
||||
<li class="relative-hyphae__entry">
|
||||
<a class="relative-hyphae__link" href="/hypha/`)
|
||||
//line tree/view.qtpl:39
|
||||
qw422016.E().S(s.name)
|
||||
//line tree/view.qtpl:39
|
||||
qw422016.N().S(`">
|
||||
`)
|
||||
//line tree/view.qtpl:40
|
||||
qw422016.E().S(util.BeautifulName(path.Base(s.name)))
|
||||
//line tree/view.qtpl:40
|
||||
qw422016.N().S(`
|
||||
<span class="relative-hyphae__count">
|
||||
`)
|
||||
//line tree/view.qtpl:42
|
||||
if s.directSubhyphaeCount > 0 {
|
||||
//line tree/view.qtpl:42
|
||||
qw422016.N().S(`
|
||||
<span class="relative-hyphae__direct-count">
|
||||
`)
|
||||
//line tree/view.qtpl:44
|
||||
qw422016.N().D(s.directSubhyphaeCount)
|
||||
//line tree/view.qtpl:44
|
||||
qw422016.N().S(`
|
||||
</span>
|
||||
`)
|
||||
//line tree/view.qtpl:46
|
||||
}
|
||||
//line tree/view.qtpl:46
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line tree/view.qtpl:47
|
||||
if s.indirectSubhyphaeCount > 0 {
|
||||
//line tree/view.qtpl:47
|
||||
qw422016.N().S(`
|
||||
<span class="relative-hyphae__indirect-count">
|
||||
(`)
|
||||
//line tree/view.qtpl:49
|
||||
qw422016.N().D(s.indirectSubhyphaeCount)
|
||||
//line tree/view.qtpl:49
|
||||
qw422016.N().S(`)
|
||||
</span>
|
||||
`)
|
||||
//line tree/view.qtpl:51
|
||||
}
|
||||
//line tree/view.qtpl:51
|
||||
qw422016.N().S(`
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
`)
|
||||
//line tree/view.qtpl:55
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:55
|
||||
func writesiblingHTML(qq422016 qtio422016.Writer, s *sibling) {
|
||||
//line tree/view.qtpl:55
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line tree/view.qtpl:55
|
||||
streamsiblingHTML(qw422016, s)
|
||||
//line tree/view.qtpl:55
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line tree/view.qtpl:55
|
||||
}
|
||||
|
||||
//line tree/view.qtpl:55
|
||||
func siblingHTML(s *sibling) string {
|
||||
//line tree/view.qtpl:55
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line tree/view.qtpl:55
|
||||
writesiblingHTML(qb422016, s)
|
||||
//line tree/view.qtpl:55
|
||||
qs422016 := string(qb422016.B)
|
||||
//line tree/view.qtpl:55
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line tree/view.qtpl:55
|
||||
return qs422016
|
||||
//line tree/view.qtpl:55
|
||||
}
|
@ -4,22 +4,38 @@ import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"strings"
|
||||
"os"
|
||||
|
||||
"github.com/adrg/xdg"
|
||||
"github.com/bouncepaw/mycorrhiza/files"
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
)
|
||||
|
||||
// ReadUsersFromFilesystem reads all user information from filesystem and stores it internally. Call it during initialization.
|
||||
// InitUserDatabase checks the configuration for auth methods and loads users
|
||||
// if necessary. Call it during initialization.
|
||||
func InitUserDatabase() {
|
||||
AuthUsed = util.UseFixedAuth || util.UseRegistration
|
||||
|
||||
if AuthUsed && (util.FixedCredentialsPath != "" || util.RegistrationCredentialsPath != "") {
|
||||
ReadUsersFromFilesystem()
|
||||
}
|
||||
}
|
||||
|
||||
// ReadUsersFromFilesystem reads all user information from filesystem and stores it internally.
|
||||
func ReadUsersFromFilesystem() {
|
||||
rememberUsers(usersFromFixedCredentials())
|
||||
if util.UseFixedAuth {
|
||||
rememberUsers(usersFromFixedCredentials())
|
||||
}
|
||||
if util.UseRegistration {
|
||||
rememberUsers(usersFromRegistrationCredentials())
|
||||
}
|
||||
readTokensToUsers()
|
||||
}
|
||||
|
||||
func usersFromFixedCredentials() []*User {
|
||||
var users []*User
|
||||
contents, err := ioutil.ReadFile(util.FixedCredentialsPath)
|
||||
func usersFromFile(path string, source UserSource) (users []*User) {
|
||||
contents, err := ioutil.ReadFile(path)
|
||||
if os.IsNotExist(err) {
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -27,10 +43,24 @@ func usersFromFixedCredentials() []*User {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
for _, u := range users {
|
||||
u.Source = source
|
||||
}
|
||||
return users
|
||||
}
|
||||
|
||||
func usersFromFixedCredentials() (users []*User) {
|
||||
users = usersFromFile(files.FixedCredentialsJSON(), SourceFixed)
|
||||
log.Println("Found", len(users), "fixed users")
|
||||
return users
|
||||
}
|
||||
|
||||
func usersFromRegistrationCredentials() (users []*User) {
|
||||
users = usersFromFile(files.RegistrationCredentialsJSON(), SourceRegistration)
|
||||
log.Println("Found", len(users), "registered users")
|
||||
return users
|
||||
}
|
||||
|
||||
func rememberUsers(uu []*User) {
|
||||
// uu is used to not shadow the `users` in `users.go`.
|
||||
for _, user := range uu {
|
||||
@ -39,7 +69,7 @@ func rememberUsers(uu []*User) {
|
||||
}
|
||||
|
||||
func readTokensToUsers() {
|
||||
contents, err := ioutil.ReadFile(tokenStoragePath())
|
||||
contents, err := ioutil.ReadFile(files.TokensJSON())
|
||||
if os.IsNotExist(err) {
|
||||
return
|
||||
}
|
||||
@ -59,16 +89,29 @@ func readTokensToUsers() {
|
||||
log.Println("Found", len(tmp), "active sessions")
|
||||
}
|
||||
|
||||
// Return path to tokens.json. Creates folders if needed.
|
||||
func tokenStoragePath() string {
|
||||
dir, err := xdg.DataFile("mycorrhiza/tokens.json")
|
||||
func dumpRegistrationCredentials() error {
|
||||
tmp := []*User{}
|
||||
|
||||
for u := range YieldUsers() {
|
||||
if u.Source != SourceRegistration {
|
||||
continue
|
||||
}
|
||||
copiedUser := u
|
||||
copiedUser.Password = ""
|
||||
tmp = append(tmp, copiedUser)
|
||||
}
|
||||
|
||||
blob, err := json.Marshal(tmp)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Println(err)
|
||||
return err
|
||||
}
|
||||
if strings.HasPrefix(dir, util.WikiDir) {
|
||||
log.Fatal("Error: Wiki storage directory includes private config files")
|
||||
err = ioutil.WriteFile(files.RegistrationCredentialsJSON(), blob, 0644)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return err
|
||||
}
|
||||
return dir
|
||||
return nil
|
||||
}
|
||||
|
||||
func dumpTokens() {
|
||||
@ -85,6 +128,6 @@ func dumpTokens() {
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
} else {
|
||||
ioutil.WriteFile(tokenStoragePath(), blob, 0644)
|
||||
ioutil.WriteFile(files.TokensJSON(), blob, 0644)
|
||||
}
|
||||
}
|
||||
|
36
user/net.go
36
user/net.go
@ -1,11 +1,14 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/util"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
// CanProceed returns `true` if the user in `rq` has enough rights to access `route`.
|
||||
@ -31,6 +34,39 @@ func LogoutFromRequest(w http.ResponseWriter, rq *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// Register registers the given user. If it fails, a non-nil error is returned.
|
||||
func Register(username, password string) error {
|
||||
username = util.CanonicalName(username)
|
||||
log.Println("Attempt to register user", username)
|
||||
switch {
|
||||
case CountRegistered() >= util.LimitRegistration && util.LimitRegistration > 0:
|
||||
i := strconv.Itoa(util.LimitRegistration)
|
||||
log.Println("Limit reached: " + i)
|
||||
return errors.New("Reached the limit of registered users: " + i)
|
||||
case HasUsername(username):
|
||||
log.Println("Username taken")
|
||||
return errors.New("Username " + username + " is taken already.")
|
||||
case !util.IsPossibleUsername(username):
|
||||
log.Println("Illegal username:", username)
|
||||
}
|
||||
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
u := User{
|
||||
Name: username,
|
||||
Group: "editor",
|
||||
HashedPassword: string(hash),
|
||||
Source: SourceRegistration,
|
||||
}
|
||||
users.Store(username, &u)
|
||||
err = dumpRegistrationCredentials()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoginDataHTTP logs such user in and returns string representation of an error if there is any.
|
||||
func LoginDataHTTP(w http.ResponseWriter, rq *http.Request, username, password string) string {
|
||||
w.Header().Set("Content-Type", "text/html;charset=utf-8")
|
||||
|
34
user/user.go
34
user/user.go
@ -2,15 +2,34 @@ package user
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
// UserSource shows where is the user data gotten from.
|
||||
type UserSource int
|
||||
|
||||
const (
|
||||
SourceUnknown UserSource = iota
|
||||
// SourceFixed is used with users that are predefined using fixed auth
|
||||
SourceFixed
|
||||
// SourceRegistration is used with users that are registered through the register form
|
||||
SourceRegistration
|
||||
)
|
||||
|
||||
// User is a user.
|
||||
type User struct {
|
||||
// Name is a username. It must follow hypha naming rules.
|
||||
Name string `json:"name"`
|
||||
Group string `json:"group"`
|
||||
Password string `json:"password"`
|
||||
Name string `json:"name"`
|
||||
Group string `json:"group"`
|
||||
Password string `json:"password"` // for fixed
|
||||
HashedPassword string `json:"hashed_password"` // for registered
|
||||
Source UserSource `json:"-"`
|
||||
sync.RWMutex
|
||||
|
||||
// A note about why HashedPassword is string and not []byte. The reason is
|
||||
// simple: golang's json marshals []byte as slice of numbers, which is not
|
||||
// acceptable.
|
||||
}
|
||||
|
||||
// Route — Right (more is more right)
|
||||
@ -67,5 +86,12 @@ func (user *User) isCorrectPassword(password string) bool {
|
||||
user.RLock()
|
||||
defer user.RUnlock()
|
||||
|
||||
return password == user.Password
|
||||
switch user.Source {
|
||||
case SourceFixed:
|
||||
return password == user.Password
|
||||
case SourceRegistration:
|
||||
err := bcrypt.CompareHashAndPassword([]byte(user.HashedPassword), []byte(password))
|
||||
return err == nil
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -30,6 +30,17 @@ func ListUsersWithGroup(group string) []string {
|
||||
return usersWithTheGroup
|
||||
}
|
||||
|
||||
func CountRegistered() int {
|
||||
i := 0
|
||||
users.Range(func(k, v interface{}) bool {
|
||||
if v.(*User).Source == SourceRegistration {
|
||||
i++
|
||||
}
|
||||
return true
|
||||
})
|
||||
return i
|
||||
}
|
||||
|
||||
func Count() int {
|
||||
i := 0
|
||||
users.Range(func(k, v interface{}) bool {
|
||||
|
@ -2,11 +2,13 @@ package util
|
||||
|
||||
import (
|
||||
"log"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-ini/ini"
|
||||
)
|
||||
|
||||
// See https://mycorrhiza.lesarbr.es/hypha/configuration/fields
|
||||
type Config struct {
|
||||
WikiName string
|
||||
NaviTitleIcon string
|
||||
@ -30,6 +32,10 @@ type Network struct {
|
||||
type Authorization struct {
|
||||
UseFixedAuth bool
|
||||
FixedAuthCredentialsPath string
|
||||
|
||||
UseRegistration bool
|
||||
RegistrationCredentialsPath string
|
||||
LimitRegistration uint64
|
||||
}
|
||||
|
||||
func ReadConfigFile(path string) {
|
||||
@ -49,17 +55,27 @@ func ReadConfigFile(path string) {
|
||||
Authorization: Authorization{
|
||||
UseFixedAuth: false,
|
||||
FixedAuthCredentialsPath: "",
|
||||
|
||||
UseRegistration: false,
|
||||
RegistrationCredentialsPath: "",
|
||||
LimitRegistration: 0,
|
||||
},
|
||||
}
|
||||
|
||||
if path != "" {
|
||||
path, err := filepath.Abs(path)
|
||||
if err != nil {
|
||||
log.Fatalf("cannot expand config file path: %s", err)
|
||||
}
|
||||
|
||||
log.Println("Loading config at", path)
|
||||
err := ini.MapTo(cfg, path)
|
||||
err = ini.MapTo(cfg, path)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Map the struct to the global variables
|
||||
SiteName = cfg.WikiName
|
||||
SiteNavIcon = cfg.NaviTitleIcon
|
||||
HomePage = cfg.HomeHypha
|
||||
@ -70,4 +86,7 @@ func ReadConfigFile(path string) {
|
||||
GeminiCertPath = cfg.GeminiCertificatePath
|
||||
UseFixedAuth = cfg.UseFixedAuth
|
||||
FixedCredentialsPath = cfg.FixedAuthCredentialsPath
|
||||
UseRegistration = cfg.UseRegistration
|
||||
RegistrationCredentialsPath = cfg.RegistrationCredentialsPath
|
||||
LimitRegistration = int(cfg.LimitRegistration)
|
||||
}
|
||||
|
22
util/util.go
22
util/util.go
@ -22,11 +22,14 @@ var (
|
||||
URL string
|
||||
GeminiCertPath string
|
||||
|
||||
UseFixedAuth bool
|
||||
FixedCredentialsPath string
|
||||
|
||||
WikiDir string
|
||||
ConfigFilePath string
|
||||
|
||||
UseFixedAuth bool
|
||||
FixedCredentialsPath string
|
||||
UseRegistration bool
|
||||
RegistrationCredentialsPath string
|
||||
LimitRegistration int
|
||||
)
|
||||
|
||||
// LettersNumbersOnly keeps letters and numbers only in the given string.
|
||||
@ -91,13 +94,24 @@ func BeautifulName(uglyName string) string {
|
||||
|
||||
// CanonicalName makes sure the `name` is canonical. A name is canonical if it is lowercase and all spaces are replaced with underscores.
|
||||
func CanonicalName(name string) string {
|
||||
return strings.ToLower(strings.ReplaceAll(name, " ", "_"))
|
||||
return strings.ToLower(
|
||||
strings.ReplaceAll(
|
||||
strings.TrimRight(
|
||||
strings.TrimLeft(name, "_"),
|
||||
"_",
|
||||
), " ", "_"))
|
||||
}
|
||||
|
||||
// HyphaPattern is a pattern which all hyphae must match.
|
||||
var HyphaPattern = regexp.MustCompile(`[^?!:#@><*|"\'&%{}]+`)
|
||||
|
||||
var UsernamePattern = regexp.MustCompile(`[^?!:#@><*|"\'&%{}/]+`)
|
||||
|
||||
// IsCanonicalName checks if the `name` is canonical.
|
||||
func IsCanonicalName(name string) bool {
|
||||
return HyphaPattern.MatchString(name)
|
||||
}
|
||||
|
||||
func IsPossibleUsername(username string) bool {
|
||||
return UsernamePattern.MatchString(strings.TrimSpace(username))
|
||||
}
|
||||
|
@ -1,6 +1,41 @@
|
||||
{% import "net/http" %}
|
||||
{% import "github.com/bouncepaw/mycorrhiza/user" %}
|
||||
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
||||
|
||||
{% func RegisterHTML(rq *http.Request) %}
|
||||
<div class="layout">
|
||||
<main class="main-width">
|
||||
<section>
|
||||
{% if util.UseRegistration %}
|
||||
<form class="modal" method="post" action="/register?{%s rq.URL.RawQuery %}" id="register-form" enctype="multipart/form-data" autocomplete="off">
|
||||
<fieldset class="modal__fieldset">
|
||||
<legend class="modal__title">Register to {%s util.SiteName %}</legend>
|
||||
|
||||
<label for="register-form__username">Username</label>
|
||||
<br>
|
||||
<input type="text" required autofocus id="login-form__username" name="username">
|
||||
<br>
|
||||
<label for="login-form__password">Password</label>
|
||||
<br>
|
||||
<input type="password" required name="password">
|
||||
<p>The server stores your password in an encrypted form; even administrators cannot read it.</p>
|
||||
<p>By submitting this form you give this wiki a permission to store cookies in your browser. It lets the engine associate your edits with you. You will stay logged in until you log out.</p>
|
||||
<input class="modal__action modal__submit" type="submit">
|
||||
<a class="modal__action modal__cancel" href="/">Cancel</a>
|
||||
</fieldset>
|
||||
</form>
|
||||
{% elseif util.UseFixedAuth %}
|
||||
<p>Administrators have forbidden registration for this wiki. Administrators can make an account for you by hand; contact them.</p>
|
||||
<p><a href="{%s rq.URL.RawQuery %}">← Go back</a></p>
|
||||
{% else %}
|
||||
<p>Administrators of this wiki have not configured any authorization method. You can make edits anonymously.</p>
|
||||
<p><a href="{%s rq.URL.RawQuery %}">← Go back</a></p>
|
||||
{% endif %}
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
{% endfunc %}
|
||||
|
||||
{% func LoginHTML() %}
|
||||
<div class="layout">
|
||||
<main class="main-width">
|
||||
|
@ -5,42 +5,142 @@
|
||||
package views
|
||||
|
||||
//line views/auth.qtpl:1
|
||||
import "github.com/bouncepaw/mycorrhiza/user"
|
||||
import "net/http"
|
||||
|
||||
//line views/auth.qtpl:2
|
||||
import "github.com/bouncepaw/mycorrhiza/user"
|
||||
|
||||
//line views/auth.qtpl:3
|
||||
import "github.com/bouncepaw/mycorrhiza/util"
|
||||
|
||||
//line views/auth.qtpl:4
|
||||
//line views/auth.qtpl:5
|
||||
import (
|
||||
qtio422016 "io"
|
||||
|
||||
qt422016 "github.com/valyala/quicktemplate"
|
||||
)
|
||||
|
||||
//line views/auth.qtpl:4
|
||||
//line views/auth.qtpl:5
|
||||
var (
|
||||
_ = qtio422016.Copy
|
||||
_ = qt422016.AcquireByteBuffer
|
||||
)
|
||||
|
||||
//line views/auth.qtpl:4
|
||||
func StreamLoginHTML(qw422016 *qt422016.Writer) {
|
||||
//line views/auth.qtpl:4
|
||||
//line views/auth.qtpl:5
|
||||
func StreamRegisterHTML(qw422016 *qt422016.Writer, rq *http.Request) {
|
||||
//line views/auth.qtpl:5
|
||||
qw422016.N().S(`
|
||||
<div class="layout">
|
||||
<main class="main-width">
|
||||
<section>
|
||||
`)
|
||||
//line views/auth.qtpl:8
|
||||
//line views/auth.qtpl:9
|
||||
if util.UseRegistration {
|
||||
//line views/auth.qtpl:9
|
||||
qw422016.N().S(`
|
||||
<form class="modal" method="post" action="/register?`)
|
||||
//line views/auth.qtpl:10
|
||||
qw422016.E().S(rq.URL.RawQuery)
|
||||
//line views/auth.qtpl:10
|
||||
qw422016.N().S(`" id="register-form" enctype="multipart/form-data" autocomplete="off">
|
||||
<fieldset class="modal__fieldset">
|
||||
<legend class="modal__title">Register to `)
|
||||
//line views/auth.qtpl:12
|
||||
qw422016.E().S(util.SiteName)
|
||||
//line views/auth.qtpl:12
|
||||
qw422016.N().S(`</legend>
|
||||
|
||||
<label for="register-form__username">Username</label>
|
||||
<br>
|
||||
<input type="text" required autofocus id="login-form__username" name="username">
|
||||
<br>
|
||||
<label for="login-form__password">Password</label>
|
||||
<br>
|
||||
<input type="password" required name="password">
|
||||
<p>The server stores your password in an encrypted form; even administrators cannot read it.</p>
|
||||
<p>By submitting this form you give this wiki a permission to store cookies in your browser. It lets the engine associate your edits with you. You will stay logged in until you log out.</p>
|
||||
<input class="modal__action modal__submit" type="submit">
|
||||
<a class="modal__action modal__cancel" href="/">Cancel</a>
|
||||
</fieldset>
|
||||
</form>
|
||||
`)
|
||||
//line views/auth.qtpl:27
|
||||
} else if util.UseFixedAuth {
|
||||
//line views/auth.qtpl:27
|
||||
qw422016.N().S(`
|
||||
<p>Administrators have forbidden registration for this wiki. Administrators can make an account for you by hand; contact them.</p>
|
||||
<p><a href="`)
|
||||
//line views/auth.qtpl:29
|
||||
qw422016.E().S(rq.URL.RawQuery)
|
||||
//line views/auth.qtpl:29
|
||||
qw422016.N().S(`">← Go back</a></p>
|
||||
`)
|
||||
//line views/auth.qtpl:30
|
||||
} else {
|
||||
//line views/auth.qtpl:30
|
||||
qw422016.N().S(`
|
||||
<p>Administrators of this wiki have not configured any authorization method. You can make edits anonymously.</p>
|
||||
<p><a href="`)
|
||||
//line views/auth.qtpl:32
|
||||
qw422016.E().S(rq.URL.RawQuery)
|
||||
//line views/auth.qtpl:32
|
||||
qw422016.N().S(`">← Go back</a></p>
|
||||
`)
|
||||
//line views/auth.qtpl:33
|
||||
}
|
||||
//line views/auth.qtpl:33
|
||||
qw422016.N().S(`
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
`)
|
||||
//line views/auth.qtpl:37
|
||||
}
|
||||
|
||||
//line views/auth.qtpl:37
|
||||
func WriteRegisterHTML(qq422016 qtio422016.Writer, rq *http.Request) {
|
||||
//line views/auth.qtpl:37
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line views/auth.qtpl:37
|
||||
StreamRegisterHTML(qw422016, rq)
|
||||
//line views/auth.qtpl:37
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line views/auth.qtpl:37
|
||||
}
|
||||
|
||||
//line views/auth.qtpl:37
|
||||
func RegisterHTML(rq *http.Request) string {
|
||||
//line views/auth.qtpl:37
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line views/auth.qtpl:37
|
||||
WriteRegisterHTML(qb422016, rq)
|
||||
//line views/auth.qtpl:37
|
||||
qs422016 := string(qb422016.B)
|
||||
//line views/auth.qtpl:37
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line views/auth.qtpl:37
|
||||
return qs422016
|
||||
//line views/auth.qtpl:37
|
||||
}
|
||||
|
||||
//line views/auth.qtpl:39
|
||||
func StreamLoginHTML(qw422016 *qt422016.Writer) {
|
||||
//line views/auth.qtpl:39
|
||||
qw422016.N().S(`
|
||||
<div class="layout">
|
||||
<main class="main-width">
|
||||
<section>
|
||||
`)
|
||||
//line views/auth.qtpl:43
|
||||
if user.AuthUsed {
|
||||
//line views/auth.qtpl:8
|
||||
//line views/auth.qtpl:43
|
||||
qw422016.N().S(`
|
||||
<form class="modal" method="post" action="/login-data" id="login-form" enctype="multipart/form-data" autocomplete="on">
|
||||
<fieldset class="modal__fieldset">
|
||||
<legend class="modal__title">Log in to `)
|
||||
//line views/auth.qtpl:11
|
||||
//line views/auth.qtpl:46
|
||||
qw422016.E().S(util.SiteName)
|
||||
//line views/auth.qtpl:11
|
||||
//line views/auth.qtpl:46
|
||||
qw422016.N().S(`</legend>
|
||||
<p>Use the data you were given by an administrator.</p>
|
||||
<label for="login-form__username">Username</label>
|
||||
@ -56,177 +156,177 @@ func StreamLoginHTML(qw422016 *qt422016.Writer) {
|
||||
</fieldset>
|
||||
</form>
|
||||
`)
|
||||
//line views/auth.qtpl:25
|
||||
//line views/auth.qtpl:60
|
||||
} else {
|
||||
//line views/auth.qtpl:25
|
||||
//line views/auth.qtpl:60
|
||||
qw422016.N().S(`
|
||||
<p>Administrators of this wiki have not configured any authorization method. You can make edits anonymously.</p>
|
||||
<p><a class="modal__cancel" href="/">← Go home</a></p>
|
||||
`)
|
||||
//line views/auth.qtpl:28
|
||||
//line views/auth.qtpl:63
|
||||
}
|
||||
//line views/auth.qtpl:28
|
||||
//line views/auth.qtpl:63
|
||||
qw422016.N().S(`
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
`)
|
||||
//line views/auth.qtpl:32
|
||||
//line views/auth.qtpl:67
|
||||
}
|
||||
|
||||
//line views/auth.qtpl:32
|
||||
//line views/auth.qtpl:67
|
||||
func WriteLoginHTML(qq422016 qtio422016.Writer) {
|
||||
//line views/auth.qtpl:32
|
||||
//line views/auth.qtpl:67
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line views/auth.qtpl:32
|
||||
//line views/auth.qtpl:67
|
||||
StreamLoginHTML(qw422016)
|
||||
//line views/auth.qtpl:32
|
||||
//line views/auth.qtpl:67
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line views/auth.qtpl:32
|
||||
//line views/auth.qtpl:67
|
||||
}
|
||||
|
||||
//line views/auth.qtpl:32
|
||||
//line views/auth.qtpl:67
|
||||
func LoginHTML() string {
|
||||
//line views/auth.qtpl:32
|
||||
//line views/auth.qtpl:67
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line views/auth.qtpl:32
|
||||
//line views/auth.qtpl:67
|
||||
WriteLoginHTML(qb422016)
|
||||
//line views/auth.qtpl:32
|
||||
//line views/auth.qtpl:67
|
||||
qs422016 := string(qb422016.B)
|
||||
//line views/auth.qtpl:32
|
||||
//line views/auth.qtpl:67
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line views/auth.qtpl:32
|
||||
//line views/auth.qtpl:67
|
||||
return qs422016
|
||||
//line views/auth.qtpl:32
|
||||
//line views/auth.qtpl:67
|
||||
}
|
||||
|
||||
//line views/auth.qtpl:34
|
||||
//line views/auth.qtpl:69
|
||||
func StreamLoginErrorHTML(qw422016 *qt422016.Writer, err string) {
|
||||
//line views/auth.qtpl:34
|
||||
//line views/auth.qtpl:69
|
||||
qw422016.N().S(`
|
||||
<div class="layout">
|
||||
<main class="main-width">
|
||||
<section>
|
||||
`)
|
||||
//line views/auth.qtpl:38
|
||||
//line views/auth.qtpl:73
|
||||
switch err {
|
||||
//line views/auth.qtpl:39
|
||||
//line views/auth.qtpl:74
|
||||
case "unknown username":
|
||||
//line views/auth.qtpl:39
|
||||
//line views/auth.qtpl:74
|
||||
qw422016.N().S(`
|
||||
<p class="error">Unknown username.</p>
|
||||
`)
|
||||
//line views/auth.qtpl:41
|
||||
//line views/auth.qtpl:76
|
||||
case "wrong password":
|
||||
//line views/auth.qtpl:41
|
||||
//line views/auth.qtpl:76
|
||||
qw422016.N().S(`
|
||||
<p class="error">Wrong password.</p>
|
||||
`)
|
||||
//line views/auth.qtpl:43
|
||||
//line views/auth.qtpl:78
|
||||
default:
|
||||
//line views/auth.qtpl:43
|
||||
//line views/auth.qtpl:78
|
||||
qw422016.N().S(`
|
||||
<p class="error">`)
|
||||
//line views/auth.qtpl:44
|
||||
//line views/auth.qtpl:79
|
||||
qw422016.E().S(err)
|
||||
//line views/auth.qtpl:44
|
||||
//line views/auth.qtpl:79
|
||||
qw422016.N().S(`</p>
|
||||
`)
|
||||
//line views/auth.qtpl:45
|
||||
//line views/auth.qtpl:80
|
||||
}
|
||||
//line views/auth.qtpl:45
|
||||
//line views/auth.qtpl:80
|
||||
qw422016.N().S(`
|
||||
<p><a href="/login">← Try again</a></p>
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
`)
|
||||
//line views/auth.qtpl:50
|
||||
//line views/auth.qtpl:85
|
||||
}
|
||||
|
||||
//line views/auth.qtpl:50
|
||||
//line views/auth.qtpl:85
|
||||
func WriteLoginErrorHTML(qq422016 qtio422016.Writer, err string) {
|
||||
//line views/auth.qtpl:50
|
||||
//line views/auth.qtpl:85
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line views/auth.qtpl:50
|
||||
//line views/auth.qtpl:85
|
||||
StreamLoginErrorHTML(qw422016, err)
|
||||
//line views/auth.qtpl:50
|
||||
//line views/auth.qtpl:85
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line views/auth.qtpl:50
|
||||
//line views/auth.qtpl:85
|
||||
}
|
||||
|
||||
//line views/auth.qtpl:50
|
||||
//line views/auth.qtpl:85
|
||||
func LoginErrorHTML(err string) string {
|
||||
//line views/auth.qtpl:50
|
||||
//line views/auth.qtpl:85
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line views/auth.qtpl:50
|
||||
//line views/auth.qtpl:85
|
||||
WriteLoginErrorHTML(qb422016, err)
|
||||
//line views/auth.qtpl:50
|
||||
//line views/auth.qtpl:85
|
||||
qs422016 := string(qb422016.B)
|
||||
//line views/auth.qtpl:50
|
||||
//line views/auth.qtpl:85
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line views/auth.qtpl:50
|
||||
//line views/auth.qtpl:85
|
||||
return qs422016
|
||||
//line views/auth.qtpl:50
|
||||
//line views/auth.qtpl:85
|
||||
}
|
||||
|
||||
//line views/auth.qtpl:52
|
||||
//line views/auth.qtpl:87
|
||||
func StreamLogoutHTML(qw422016 *qt422016.Writer, can bool) {
|
||||
//line views/auth.qtpl:52
|
||||
//line views/auth.qtpl:87
|
||||
qw422016.N().S(`
|
||||
<div class="layout">
|
||||
<main class="main-width">
|
||||
<section>
|
||||
`)
|
||||
//line views/auth.qtpl:56
|
||||
//line views/auth.qtpl:91
|
||||
if can {
|
||||
//line views/auth.qtpl:56
|
||||
//line views/auth.qtpl:91
|
||||
qw422016.N().S(`
|
||||
<h1>Log out?</h1>
|
||||
<p><a href="/logout-confirm"><strong>Confirm</strong></a></p>
|
||||
<p><a href="/">Cancel</a></p>
|
||||
`)
|
||||
//line views/auth.qtpl:60
|
||||
//line views/auth.qtpl:95
|
||||
} else {
|
||||
//line views/auth.qtpl:60
|
||||
//line views/auth.qtpl:95
|
||||
qw422016.N().S(`
|
||||
<p>You cannot log out because you are not logged in.</p>
|
||||
<p><a href="/login">Login</a></p>
|
||||
<p><a href="/login">← Home</a></p>
|
||||
`)
|
||||
//line views/auth.qtpl:64
|
||||
//line views/auth.qtpl:99
|
||||
}
|
||||
//line views/auth.qtpl:64
|
||||
//line views/auth.qtpl:99
|
||||
qw422016.N().S(`
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
`)
|
||||
//line views/auth.qtpl:68
|
||||
//line views/auth.qtpl:103
|
||||
}
|
||||
|
||||
//line views/auth.qtpl:68
|
||||
//line views/auth.qtpl:103
|
||||
func WriteLogoutHTML(qq422016 qtio422016.Writer, can bool) {
|
||||
//line views/auth.qtpl:68
|
||||
//line views/auth.qtpl:103
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line views/auth.qtpl:68
|
||||
//line views/auth.qtpl:103
|
||||
StreamLogoutHTML(qw422016, can)
|
||||
//line views/auth.qtpl:68
|
||||
//line views/auth.qtpl:103
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line views/auth.qtpl:68
|
||||
//line views/auth.qtpl:103
|
||||
}
|
||||
|
||||
//line views/auth.qtpl:68
|
||||
//line views/auth.qtpl:103
|
||||
func LogoutHTML(can bool) string {
|
||||
//line views/auth.qtpl:68
|
||||
//line views/auth.qtpl:103
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line views/auth.qtpl:68
|
||||
//line views/auth.qtpl:103
|
||||
WriteLogoutHTML(qb422016, can)
|
||||
//line views/auth.qtpl:68
|
||||
//line views/auth.qtpl:103
|
||||
qs422016 := string(qb422016.B)
|
||||
//line views/auth.qtpl:68
|
||||
//line views/auth.qtpl:103
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line views/auth.qtpl:68
|
||||
//line views/auth.qtpl:103
|
||||
return qs422016
|
||||
//line views/auth.qtpl:68
|
||||
//line views/auth.qtpl:103
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ if err != nil {
|
||||
<div class="layout">
|
||||
<main class="main-width recent-changes">
|
||||
<h1>Recent Changes</h1>
|
||||
<p><a href="/">← Back</a></p>
|
||||
|
||||
<nav class="recent-changes__count">
|
||||
See
|
||||
@ -45,7 +44,7 @@ if err != nil {
|
||||
recent changes
|
||||
</nav>
|
||||
|
||||
<p><img class="icon" width="20" height="20" src="https://upload.wikimedia.org/wikipedia/commons/4/46/Generic_Feed-icon.svg">Subscribe via <a href="/recent-changes-rss">RSS</a>, <a href="/recent-changes-atom">Atom</a> or <a href="/recent-changes-json">JSON feed</a>.</p>
|
||||
<p><img class="icon" width="20" height="20" src="/static/icon/feed">Subscribe via <a href="/recent-changes-rss">RSS</a>, <a href="/recent-changes-atom">Atom</a> or <a href="/recent-changes-json">JSON feed</a>.</p>
|
||||
|
||||
{% comment %}
|
||||
Here I am, willing to add some accessibility using ARIA. Turns out,
|
||||
|
@ -107,273 +107,272 @@ func StreamRecentChangesHTML(qw422016 *qt422016.Writer, n int) {
|
||||
<div class="layout">
|
||||
<main class="main-width recent-changes">
|
||||
<h1>Recent Changes</h1>
|
||||
<p><a href="/">← Back</a></p>
|
||||
|
||||
<nav class="recent-changes__count">
|
||||
See
|
||||
`)
|
||||
//line views/history.qtpl:35
|
||||
//line views/history.qtpl:34
|
||||
for _, m := range []int{20, 0, 50, 0, 100} {
|
||||
//line views/history.qtpl:35
|
||||
//line views/history.qtpl:34
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line views/history.qtpl:36
|
||||
//line views/history.qtpl:35
|
||||
switch m {
|
||||
//line views/history.qtpl:37
|
||||
//line views/history.qtpl:36
|
||||
case 0:
|
||||
//line views/history.qtpl:37
|
||||
//line views/history.qtpl:36
|
||||
qw422016.N().S(`
|
||||
<span aria-hidden="true">|</span>
|
||||
`)
|
||||
//line views/history.qtpl:39
|
||||
//line views/history.qtpl:38
|
||||
case n:
|
||||
//line views/history.qtpl:39
|
||||
//line views/history.qtpl:38
|
||||
qw422016.N().S(`
|
||||
<b>`)
|
||||
//line views/history.qtpl:40
|
||||
//line views/history.qtpl:39
|
||||
qw422016.N().D(n)
|
||||
//line views/history.qtpl:40
|
||||
//line views/history.qtpl:39
|
||||
qw422016.N().S(`</b>
|
||||
`)
|
||||
//line views/history.qtpl:41
|
||||
//line views/history.qtpl:40
|
||||
default:
|
||||
//line views/history.qtpl:41
|
||||
//line views/history.qtpl:40
|
||||
qw422016.N().S(`
|
||||
<a href="/recent-changes/`)
|
||||
//line views/history.qtpl:42
|
||||
//line views/history.qtpl:41
|
||||
qw422016.N().D(m)
|
||||
//line views/history.qtpl:42
|
||||
//line views/history.qtpl:41
|
||||
qw422016.N().S(`">`)
|
||||
//line views/history.qtpl:42
|
||||
//line views/history.qtpl:41
|
||||
qw422016.N().D(m)
|
||||
//line views/history.qtpl:42
|
||||
//line views/history.qtpl:41
|
||||
qw422016.N().S(`</a>
|
||||
`)
|
||||
//line views/history.qtpl:43
|
||||
//line views/history.qtpl:42
|
||||
}
|
||||
//line views/history.qtpl:43
|
||||
//line views/history.qtpl:42
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line views/history.qtpl:44
|
||||
//line views/history.qtpl:43
|
||||
}
|
||||
//line views/history.qtpl:44
|
||||
//line views/history.qtpl:43
|
||||
qw422016.N().S(`
|
||||
recent changes
|
||||
</nav>
|
||||
|
||||
<p><img class="icon" width="20" height="20" src="https://upload.wikimedia.org/wikipedia/commons/4/46/Generic_Feed-icon.svg">Subscribe via <a href="/recent-changes-rss">RSS</a>, <a href="/recent-changes-atom">Atom</a> or <a href="/recent-changes-json">JSON feed</a>.</p>
|
||||
<p><img class="icon" width="20" height="20" src="/static/icon/feed">Subscribe via <a href="/recent-changes-rss">RSS</a>, <a href="/recent-changes-atom">Atom</a> or <a href="/recent-changes-json">JSON feed</a>.</p>
|
||||
|
||||
`)
|
||||
//line views/history.qtpl:55
|
||||
//line views/history.qtpl:54
|
||||
qw422016.N().S(`
|
||||
|
||||
`)
|
||||
//line views/history.qtpl:58
|
||||
//line views/history.qtpl:57
|
||||
changes := history.RecentChanges(n)
|
||||
|
||||
//line views/history.qtpl:59
|
||||
//line views/history.qtpl:58
|
||||
qw422016.N().S(`
|
||||
<section class="recent-changes__list" role="feed">
|
||||
`)
|
||||
//line views/history.qtpl:61
|
||||
//line views/history.qtpl:60
|
||||
if len(changes) == 0 {
|
||||
//line views/history.qtpl:61
|
||||
//line views/history.qtpl:60
|
||||
qw422016.N().S(`
|
||||
<p>Could not find any recent changes.</p>
|
||||
`)
|
||||
//line views/history.qtpl:63
|
||||
//line views/history.qtpl:62
|
||||
} else {
|
||||
//line views/history.qtpl:63
|
||||
//line views/history.qtpl:62
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line views/history.qtpl:64
|
||||
//line views/history.qtpl:63
|
||||
for i, entry := range changes {
|
||||
//line views/history.qtpl:64
|
||||
//line views/history.qtpl:63
|
||||
qw422016.N().S(`
|
||||
<ul class="recent-changes__entry rc-entry" role="article"
|
||||
aria-setsize="`)
|
||||
//line views/history.qtpl:66
|
||||
//line views/history.qtpl:65
|
||||
qw422016.N().D(n)
|
||||
//line views/history.qtpl:66
|
||||
//line views/history.qtpl:65
|
||||
qw422016.N().S(`" aria-posinset="`)
|
||||
//line views/history.qtpl:66
|
||||
//line views/history.qtpl:65
|
||||
qw422016.N().D(i)
|
||||
//line views/history.qtpl:66
|
||||
//line views/history.qtpl:65
|
||||
qw422016.N().S(`">
|
||||
`)
|
||||
//line views/history.qtpl:67
|
||||
//line views/history.qtpl:66
|
||||
qw422016.N().S(recentChangesEntry(entry))
|
||||
//line views/history.qtpl:67
|
||||
//line views/history.qtpl:66
|
||||
qw422016.N().S(`
|
||||
</ul>
|
||||
`)
|
||||
//line views/history.qtpl:69
|
||||
//line views/history.qtpl:68
|
||||
}
|
||||
//line views/history.qtpl:69
|
||||
//line views/history.qtpl:68
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line views/history.qtpl:70
|
||||
//line views/history.qtpl:69
|
||||
}
|
||||
//line views/history.qtpl:70
|
||||
//line views/history.qtpl:69
|
||||
qw422016.N().S(`
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
`)
|
||||
//line views/history.qtpl:74
|
||||
//line views/history.qtpl:73
|
||||
}
|
||||
|
||||
//line views/history.qtpl:74
|
||||
//line views/history.qtpl:73
|
||||
func WriteRecentChangesHTML(qq422016 qtio422016.Writer, n int) {
|
||||
//line views/history.qtpl:74
|
||||
//line views/history.qtpl:73
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line views/history.qtpl:74
|
||||
//line views/history.qtpl:73
|
||||
StreamRecentChangesHTML(qw422016, n)
|
||||
//line views/history.qtpl:74
|
||||
//line views/history.qtpl:73
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line views/history.qtpl:74
|
||||
//line views/history.qtpl:73
|
||||
}
|
||||
|
||||
//line views/history.qtpl:74
|
||||
//line views/history.qtpl:73
|
||||
func RecentChangesHTML(n int) string {
|
||||
//line views/history.qtpl:74
|
||||
//line views/history.qtpl:73
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line views/history.qtpl:74
|
||||
//line views/history.qtpl:73
|
||||
WriteRecentChangesHTML(qb422016, n)
|
||||
//line views/history.qtpl:74
|
||||
//line views/history.qtpl:73
|
||||
qs422016 := string(qb422016.B)
|
||||
//line views/history.qtpl:74
|
||||
//line views/history.qtpl:73
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line views/history.qtpl:74
|
||||
//line views/history.qtpl:73
|
||||
return qs422016
|
||||
//line views/history.qtpl:74
|
||||
//line views/history.qtpl:73
|
||||
}
|
||||
|
||||
//line views/history.qtpl:76
|
||||
//line views/history.qtpl:75
|
||||
func streamrecentChangesEntry(qw422016 *qt422016.Writer, rev history.Revision) {
|
||||
//line views/history.qtpl:76
|
||||
//line views/history.qtpl:75
|
||||
qw422016.N().S(`
|
||||
<li class="rc-entry__time"><time>`)
|
||||
//line views/history.qtpl:77
|
||||
//line views/history.qtpl:76
|
||||
qw422016.E().S(rev.TimeString())
|
||||
//line views/history.qtpl:77
|
||||
//line views/history.qtpl:76
|
||||
qw422016.N().S(`</time></li>
|
||||
<li class="rc-entry__hash">`)
|
||||
//line views/history.qtpl:78
|
||||
//line views/history.qtpl:77
|
||||
qw422016.E().S(rev.Hash)
|
||||
//line views/history.qtpl:78
|
||||
//line views/history.qtpl:77
|
||||
qw422016.N().S(`</li>
|
||||
<li class="rc-entry__links">`)
|
||||
//line views/history.qtpl:79
|
||||
//line views/history.qtpl:78
|
||||
qw422016.N().S(rev.HyphaeLinksHTML())
|
||||
//line views/history.qtpl:79
|
||||
//line views/history.qtpl:78
|
||||
qw422016.N().S(`</li>
|
||||
<li class="rc-entry__msg">`)
|
||||
//line views/history.qtpl:80
|
||||
//line views/history.qtpl:79
|
||||
qw422016.E().S(rev.Message)
|
||||
//line views/history.qtpl:80
|
||||
//line views/history.qtpl:79
|
||||
qw422016.N().S(` `)
|
||||
//line views/history.qtpl:80
|
||||
//line views/history.qtpl:79
|
||||
if rev.Username != "anon" {
|
||||
//line views/history.qtpl:80
|
||||
//line views/history.qtpl:79
|
||||
qw422016.N().S(`<span class="rc-entry__author">by <a href="/hypha/`)
|
||||
//line views/history.qtpl:80
|
||||
//line views/history.qtpl:79
|
||||
qw422016.E().S(util.UserHypha)
|
||||
//line views/history.qtpl:80
|
||||
//line views/history.qtpl:79
|
||||
qw422016.N().S(`/`)
|
||||
//line views/history.qtpl:80
|
||||
//line views/history.qtpl:79
|
||||
qw422016.E().S(rev.Username)
|
||||
//line views/history.qtpl:80
|
||||
//line views/history.qtpl:79
|
||||
qw422016.N().S(`" rel="author">`)
|
||||
//line views/history.qtpl:80
|
||||
//line views/history.qtpl:79
|
||||
qw422016.E().S(rev.Username)
|
||||
//line views/history.qtpl:80
|
||||
//line views/history.qtpl:79
|
||||
qw422016.N().S(`</a></span>`)
|
||||
//line views/history.qtpl:80
|
||||
//line views/history.qtpl:79
|
||||
}
|
||||
//line views/history.qtpl:80
|
||||
//line views/history.qtpl:79
|
||||
qw422016.N().S(`</li>
|
||||
`)
|
||||
//line views/history.qtpl:81
|
||||
//line views/history.qtpl:80
|
||||
}
|
||||
|
||||
//line views/history.qtpl:81
|
||||
//line views/history.qtpl:80
|
||||
func writerecentChangesEntry(qq422016 qtio422016.Writer, rev history.Revision) {
|
||||
//line views/history.qtpl:81
|
||||
//line views/history.qtpl:80
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line views/history.qtpl:81
|
||||
//line views/history.qtpl:80
|
||||
streamrecentChangesEntry(qw422016, rev)
|
||||
//line views/history.qtpl:81
|
||||
//line views/history.qtpl:80
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line views/history.qtpl:81
|
||||
//line views/history.qtpl:80
|
||||
}
|
||||
|
||||
//line views/history.qtpl:81
|
||||
//line views/history.qtpl:80
|
||||
func recentChangesEntry(rev history.Revision) string {
|
||||
//line views/history.qtpl:81
|
||||
//line views/history.qtpl:80
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line views/history.qtpl:81
|
||||
//line views/history.qtpl:80
|
||||
writerecentChangesEntry(qb422016, rev)
|
||||
//line views/history.qtpl:81
|
||||
//line views/history.qtpl:80
|
||||
qs422016 := string(qb422016.B)
|
||||
//line views/history.qtpl:81
|
||||
//line views/history.qtpl:80
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line views/history.qtpl:81
|
||||
//line views/history.qtpl:80
|
||||
return qs422016
|
||||
//line views/history.qtpl:81
|
||||
//line views/history.qtpl:80
|
||||
}
|
||||
|
||||
//line views/history.qtpl:83
|
||||
//line views/history.qtpl:82
|
||||
func StreamHistoryHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, list string) {
|
||||
//line views/history.qtpl:83
|
||||
//line views/history.qtpl:82
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line views/history.qtpl:84
|
||||
//line views/history.qtpl:83
|
||||
StreamNavHTML(qw422016, rq, hyphaName, "history")
|
||||
//line views/history.qtpl:84
|
||||
//line views/history.qtpl:83
|
||||
qw422016.N().S(`
|
||||
<div class="layout">
|
||||
<main class="main-width">
|
||||
<article class="history">
|
||||
<h1>History of `)
|
||||
//line views/history.qtpl:88
|
||||
//line views/history.qtpl:87
|
||||
qw422016.E().S(util.BeautifulName(hyphaName))
|
||||
//line views/history.qtpl:88
|
||||
//line views/history.qtpl:87
|
||||
qw422016.N().S(`</h1>
|
||||
`)
|
||||
//line views/history.qtpl:89
|
||||
//line views/history.qtpl:88
|
||||
qw422016.N().S(list)
|
||||
//line views/history.qtpl:89
|
||||
//line views/history.qtpl:88
|
||||
qw422016.N().S(`
|
||||
</article>
|
||||
</main>
|
||||
</div>
|
||||
`)
|
||||
//line views/history.qtpl:93
|
||||
//line views/history.qtpl:92
|
||||
}
|
||||
|
||||
//line views/history.qtpl:93
|
||||
//line views/history.qtpl:92
|
||||
func WriteHistoryHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, list string) {
|
||||
//line views/history.qtpl:93
|
||||
//line views/history.qtpl:92
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line views/history.qtpl:93
|
||||
//line views/history.qtpl:92
|
||||
StreamHistoryHTML(qw422016, rq, hyphaName, list)
|
||||
//line views/history.qtpl:93
|
||||
//line views/history.qtpl:92
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line views/history.qtpl:93
|
||||
//line views/history.qtpl:92
|
||||
}
|
||||
|
||||
//line views/history.qtpl:93
|
||||
//line views/history.qtpl:92
|
||||
func HistoryHTML(rq *http.Request, hyphaName, list string) string {
|
||||
//line views/history.qtpl:93
|
||||
//line views/history.qtpl:92
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line views/history.qtpl:93
|
||||
//line views/history.qtpl:92
|
||||
WriteHistoryHTML(qb422016, rq, hyphaName, list)
|
||||
//line views/history.qtpl:93
|
||||
//line views/history.qtpl:92
|
||||
qs422016 := string(qb422016.B)
|
||||
//line views/history.qtpl:93
|
||||
//line views/history.qtpl:92
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line views/history.qtpl:93
|
||||
//line views/history.qtpl:92
|
||||
return qs422016
|
||||
//line views/history.qtpl:93
|
||||
//line views/history.qtpl:92
|
||||
}
|
||||
|
@ -22,8 +22,7 @@
|
||||
<span aria-hidden="true" class="navi-title__separator">/</span>
|
||||
{% endif %}
|
||||
|
||||
<a href="{%s prevAcc + part %}"
|
||||
rel="{% if i == len(parts) - 1 %}bookmark{% else %}up{% endif %}">
|
||||
<a href="{%s prevAcc + part %}" rel="{% if i == len(parts) - 1 %}bookmark{% else %}up{% endif %}">
|
||||
{%s= util.BeautifulName(part) %}
|
||||
</a>
|
||||
{% code prevAcc += part + "/" %}
|
||||
|
@ -67,167 +67,167 @@ func StreamNaviTitleHTML(qw422016 *qt422016.Writer, h *hyphae.Hypha) {
|
||||
//line views/hypha.qtpl:25
|
||||
qw422016.E().S(prevAcc + part)
|
||||
//line views/hypha.qtpl:25
|
||||
qw422016.N().S(`"rel="`)
|
||||
//line views/hypha.qtpl:26
|
||||
qw422016.N().S(`" rel="`)
|
||||
//line views/hypha.qtpl:25
|
||||
if i == len(parts)-1 {
|
||||
//line views/hypha.qtpl:26
|
||||
//line views/hypha.qtpl:25
|
||||
qw422016.N().S(`bookmark`)
|
||||
//line views/hypha.qtpl:26
|
||||
//line views/hypha.qtpl:25
|
||||
} else {
|
||||
//line views/hypha.qtpl:26
|
||||
//line views/hypha.qtpl:25
|
||||
qw422016.N().S(`up`)
|
||||
//line views/hypha.qtpl:26
|
||||
//line views/hypha.qtpl:25
|
||||
}
|
||||
//line views/hypha.qtpl:26
|
||||
//line views/hypha.qtpl:25
|
||||
qw422016.N().S(`">`)
|
||||
//line views/hypha.qtpl:27
|
||||
//line views/hypha.qtpl:26
|
||||
qw422016.N().S(util.BeautifulName(part))
|
||||
//line views/hypha.qtpl:27
|
||||
//line views/hypha.qtpl:26
|
||||
qw422016.N().S(`</a>`)
|
||||
//line views/hypha.qtpl:29
|
||||
//line views/hypha.qtpl:28
|
||||
prevAcc += part + "/"
|
||||
|
||||
//line views/hypha.qtpl:30
|
||||
//line views/hypha.qtpl:29
|
||||
}
|
||||
//line views/hypha.qtpl:31
|
||||
//line views/hypha.qtpl:30
|
||||
qw422016.N().S(`
|
||||
</h1>
|
||||
`)
|
||||
//line views/hypha.qtpl:33
|
||||
//line views/hypha.qtpl:32
|
||||
}
|
||||
|
||||
//line views/hypha.qtpl:33
|
||||
//line views/hypha.qtpl:32
|
||||
func WriteNaviTitleHTML(qq422016 qtio422016.Writer, h *hyphae.Hypha) {
|
||||
//line views/hypha.qtpl:33
|
||||
//line views/hypha.qtpl:32
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line views/hypha.qtpl:33
|
||||
//line views/hypha.qtpl:32
|
||||
StreamNaviTitleHTML(qw422016, h)
|
||||
//line views/hypha.qtpl:33
|
||||
//line views/hypha.qtpl:32
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line views/hypha.qtpl:33
|
||||
//line views/hypha.qtpl:32
|
||||
}
|
||||
|
||||
//line views/hypha.qtpl:33
|
||||
//line views/hypha.qtpl:32
|
||||
func NaviTitleHTML(h *hyphae.Hypha) string {
|
||||
//line views/hypha.qtpl:33
|
||||
//line views/hypha.qtpl:32
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line views/hypha.qtpl:33
|
||||
//line views/hypha.qtpl:32
|
||||
WriteNaviTitleHTML(qb422016, h)
|
||||
//line views/hypha.qtpl:33
|
||||
//line views/hypha.qtpl:32
|
||||
qs422016 := string(qb422016.B)
|
||||
//line views/hypha.qtpl:33
|
||||
//line views/hypha.qtpl:32
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line views/hypha.qtpl:33
|
||||
//line views/hypha.qtpl:32
|
||||
return qs422016
|
||||
//line views/hypha.qtpl:33
|
||||
//line views/hypha.qtpl:32
|
||||
}
|
||||
|
||||
//line views/hypha.qtpl:35
|
||||
//line views/hypha.qtpl:34
|
||||
func StreamAttachmentHTML(qw422016 *qt422016.Writer, h *hyphae.Hypha) {
|
||||
//line views/hypha.qtpl:35
|
||||
//line views/hypha.qtpl:34
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line views/hypha.qtpl:36
|
||||
//line views/hypha.qtpl:35
|
||||
switch filepath.Ext(h.BinaryPath) {
|
||||
//line views/hypha.qtpl:38
|
||||
//line views/hypha.qtpl:37
|
||||
case ".jpg", ".gif", ".png", ".webp", ".svg", ".ico":
|
||||
//line views/hypha.qtpl:38
|
||||
//line views/hypha.qtpl:37
|
||||
qw422016.N().S(`
|
||||
<div class="binary-container binary-container_with-img">
|
||||
<a href="/binary/`)
|
||||
//line views/hypha.qtpl:40
|
||||
//line views/hypha.qtpl:39
|
||||
qw422016.N().S(h.Name)
|
||||
//line views/hypha.qtpl:40
|
||||
//line views/hypha.qtpl:39
|
||||
qw422016.N().S(`"><img src="/binary/`)
|
||||
//line views/hypha.qtpl:40
|
||||
//line views/hypha.qtpl:39
|
||||
qw422016.N().S(h.Name)
|
||||
//line views/hypha.qtpl:40
|
||||
//line views/hypha.qtpl:39
|
||||
qw422016.N().S(`"/></a>
|
||||
</div>
|
||||
|
||||
`)
|
||||
//line views/hypha.qtpl:43
|
||||
//line views/hypha.qtpl:42
|
||||
case ".ogg", ".webm", ".mp4":
|
||||
//line views/hypha.qtpl:43
|
||||
//line views/hypha.qtpl:42
|
||||
qw422016.N().S(`
|
||||
<div class="binary-container binary-container_with-video">
|
||||
<video controls>
|
||||
<source src="/binary/`)
|
||||
//line views/hypha.qtpl:46
|
||||
//line views/hypha.qtpl:45
|
||||
qw422016.N().S(h.Name)
|
||||
//line views/hypha.qtpl:46
|
||||
//line views/hypha.qtpl:45
|
||||
qw422016.N().S(`"/>
|
||||
<p>Your browser does not support video. <a href="/binary/`)
|
||||
//line views/hypha.qtpl:47
|
||||
//line views/hypha.qtpl:46
|
||||
qw422016.N().S(h.Name)
|
||||
//line views/hypha.qtpl:47
|
||||
//line views/hypha.qtpl:46
|
||||
qw422016.N().S(`">Download video</a></p>
|
||||
</video>
|
||||
</div>
|
||||
|
||||
`)
|
||||
//line views/hypha.qtpl:51
|
||||
//line views/hypha.qtpl:50
|
||||
case ".mp3":
|
||||
//line views/hypha.qtpl:51
|
||||
//line views/hypha.qtpl:50
|
||||
qw422016.N().S(`
|
||||
<div class="binary-container binary-container_with-audio">
|
||||
<audio controls>
|
||||
<source src="/binary/`)
|
||||
//line views/hypha.qtpl:54
|
||||
//line views/hypha.qtpl:53
|
||||
qw422016.N().S(h.Name)
|
||||
//line views/hypha.qtpl:54
|
||||
//line views/hypha.qtpl:53
|
||||
qw422016.N().S(`"/>
|
||||
<p>Your browser does not support audio. <a href="/binary/`)
|
||||
//line views/hypha.qtpl:55
|
||||
//line views/hypha.qtpl:54
|
||||
qw422016.N().S(h.Name)
|
||||
//line views/hypha.qtpl:55
|
||||
//line views/hypha.qtpl:54
|
||||
qw422016.N().S(`">Download audio</a></p>
|
||||
</audio>
|
||||
</div>
|
||||
|
||||
`)
|
||||
//line views/hypha.qtpl:59
|
||||
//line views/hypha.qtpl:58
|
||||
default:
|
||||
//line views/hypha.qtpl:59
|
||||
//line views/hypha.qtpl:58
|
||||
qw422016.N().S(`
|
||||
<div class="binary-container binary-container_with-nothing">
|
||||
<p><a href="/binary/`)
|
||||
//line views/hypha.qtpl:61
|
||||
//line views/hypha.qtpl:60
|
||||
qw422016.N().S(h.Name)
|
||||
//line views/hypha.qtpl:61
|
||||
//line views/hypha.qtpl:60
|
||||
qw422016.N().S(`">Download media</a></p>
|
||||
</div>
|
||||
`)
|
||||
//line views/hypha.qtpl:63
|
||||
//line views/hypha.qtpl:62
|
||||
}
|
||||
//line views/hypha.qtpl:63
|
||||
//line views/hypha.qtpl:62
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line views/hypha.qtpl:64
|
||||
//line views/hypha.qtpl:63
|
||||
}
|
||||
|
||||
//line views/hypha.qtpl:64
|
||||
//line views/hypha.qtpl:63
|
||||
func WriteAttachmentHTML(qq422016 qtio422016.Writer, h *hyphae.Hypha) {
|
||||
//line views/hypha.qtpl:64
|
||||
//line views/hypha.qtpl:63
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line views/hypha.qtpl:64
|
||||
//line views/hypha.qtpl:63
|
||||
StreamAttachmentHTML(qw422016, h)
|
||||
//line views/hypha.qtpl:64
|
||||
//line views/hypha.qtpl:63
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line views/hypha.qtpl:64
|
||||
//line views/hypha.qtpl:63
|
||||
}
|
||||
|
||||
//line views/hypha.qtpl:64
|
||||
//line views/hypha.qtpl:63
|
||||
func AttachmentHTML(h *hyphae.Hypha) string {
|
||||
//line views/hypha.qtpl:64
|
||||
//line views/hypha.qtpl:63
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line views/hypha.qtpl:64
|
||||
//line views/hypha.qtpl:63
|
||||
WriteAttachmentHTML(qb422016, h)
|
||||
//line views/hypha.qtpl:64
|
||||
//line views/hypha.qtpl:63
|
||||
qs422016 := string(qb422016.B)
|
||||
//line views/hypha.qtpl:64
|
||||
//line views/hypha.qtpl:63
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line views/hypha.qtpl:64
|
||||
//line views/hypha.qtpl:63
|
||||
return qs422016
|
||||
//line views/hypha.qtpl:64
|
||||
//line views/hypha.qtpl:63
|
||||
}
|
||||
|
@ -1,5 +1,69 @@
|
||||
{% import "net/http" %}
|
||||
{% import "github.com/bouncepaw/mycorrhiza/util" %}
|
||||
{% import "github.com/bouncepaw/mycorrhiza/user" %}
|
||||
|
||||
{% func Toolbar(u *user.User) %}
|
||||
<aside class="edit-toolbar layout-card">
|
||||
<h2 class="edit-toolbar__title layout-card__title">Markup</h2>
|
||||
<section class="edit-toolbar__buttons">
|
||||
{% for _, el := range []struct{
|
||||
class string
|
||||
onclick string
|
||||
display string
|
||||
}{
|
||||
{"link", "wrapLink()", "[[link]]"},
|
||||
{"heading2", "insertHeading2()", "## heading"},
|
||||
{"heading3", "insertHeading3()", "### heading"},
|
||||
{"bold", "wrapBold()", "<b>**Bold**</b>"},
|
||||
{"italic", "wrapItalic()", "<i>//Italic//</i>"},
|
||||
{"highlighted", "wrapHighlighted()", "<mark>!!Highlight!!</mark>"},
|
||||
{"monospace", "wrapMonospace()", "<code>`Monospace`</code>"},
|
||||
{"lifted", "wrapLifted()", "<sup>^Lifted^</sup>"},
|
||||
{"lowered", "wrapLowered()", "<sub>,,Lowered,,</sub>"},
|
||||
{"strikethrough", "wrapStrikethrough()", "<strike>~~Strikethrough~~</strike>"},
|
||||
{"rocket", "insertRocket()", "=> rocketlink"},
|
||||
{"xcl", "insertXcl()", "<= transclusion"},
|
||||
{"img", "insertImgBlock()", "<code>img {}</code>"},
|
||||
{"table", "insertTableBlock()", "<code>table {}</code>"},
|
||||
{"hr", "insertHorizontalBar()", "Horizontal bar"},
|
||||
{"codeblock", "insertCodeblock()", "Code block"},
|
||||
{"bulletedlist", "insertBulletedList()", "* bullet list"},
|
||||
{"numberedlist", "insertNumberedList()", "*. number list"},
|
||||
} %}
|
||||
<button
|
||||
class="edit-toolbar__btn edit-toolbar__{%s el.class %}"
|
||||
onclick="{%s el.onclick %}">
|
||||
{%s= el.display %}
|
||||
</button>
|
||||
{% endfor %}
|
||||
</section>
|
||||
<p class="edit-toolbar__ad"><a href="https://mycorrhiza.lesarbr.es/hypha/mycomarkup" target="_blank">Learn more</a> about mycomarkup</p>
|
||||
<h2 class="edit-toolbar__title layout-card__title">Actions</h2>
|
||||
<section class="edit-toolbar__buttons">
|
||||
{% for _, el := range []struct{
|
||||
class string
|
||||
onclick string
|
||||
display string
|
||||
}{
|
||||
{"date", "insertDate()", "Insert current date"},
|
||||
} %}
|
||||
<button
|
||||
class="edit-toolbar__btn edit-toolbar__{%s el.class %}"
|
||||
onclick="{%s el.onclick %}">
|
||||
{%s= el.display %}
|
||||
</button>
|
||||
{% endfor %}
|
||||
{% if u.Group != "anon" %}
|
||||
<button
|
||||
class="edit-toolbar__btn edit-toolbar__user-link"
|
||||
onclick="insertUserlink()">
|
||||
Link yourself
|
||||
</button>
|
||||
{% endif %}
|
||||
</section>
|
||||
</aside>
|
||||
<script src="/static/toolbar.js"></script>
|
||||
{% endfunc %}
|
||||
|
||||
{% func EditHTML(rq *http.Request, hyphaName, textAreaFill, warning string) %}
|
||||
{%s= NavHTML(rq, hyphaName, "edit") %}
|
||||
@ -9,13 +73,14 @@
|
||||
{%s= warning %}
|
||||
<form method="post" class="edit-form"
|
||||
action="/upload-text/{%s hyphaName %}">
|
||||
<textarea name="text">{%s textAreaFill %}</textarea>
|
||||
<textarea name="text" class="edit-form__textarea">{%s textAreaFill %}</textarea>
|
||||
<br/>
|
||||
<input type="submit" name="action" value="Save" class="edit-form__save"/>
|
||||
<input type="submit" name="action" value="Preview" class="edit-form__preview">
|
||||
<a href="/page/{%s hyphaName %}" class="edit-form__cancel">Cancel</a>
|
||||
</form>
|
||||
</main>
|
||||
{%s= Toolbar(user.FromRequest(rq)) %}
|
||||
</div>
|
||||
{% endfunc %}
|
||||
|
||||
@ -27,7 +92,7 @@
|
||||
{%s= warning %}
|
||||
<form method="post" class="edit-form"
|
||||
action="/upload-text/{%s hyphaName %}">
|
||||
<textarea name="text">{%s textAreaFill %}</textarea>
|
||||
<textarea class="edit-form__textarea" name="text">{%s textAreaFill %}</textarea>
|
||||
<br/>
|
||||
<input type="submit" name="action" value="Save" class="edit-form__save"/>
|
||||
<input type="submit" name="action" value="Preview" class="edit-form__preview">
|
||||
@ -36,5 +101,6 @@
|
||||
<p class="warning">Note that the hypha is not saved yet. You can preview the changes ↓</p>
|
||||
<article class="edit__preview">{%s= renderedPage %}</article>
|
||||
</main>
|
||||
{%s= Toolbar(user.FromRequest(rq)) %}
|
||||
</div>
|
||||
{% endfunc %}
|
||||
|
@ -10,167 +10,322 @@ import "net/http"
|
||||
//line views/mutators.qtpl:2
|
||||
import "github.com/bouncepaw/mycorrhiza/util"
|
||||
|
||||
//line views/mutators.qtpl:4
|
||||
//line views/mutators.qtpl:3
|
||||
import "github.com/bouncepaw/mycorrhiza/user"
|
||||
|
||||
//line views/mutators.qtpl:5
|
||||
import (
|
||||
qtio422016 "io"
|
||||
|
||||
qt422016 "github.com/valyala/quicktemplate"
|
||||
)
|
||||
|
||||
//line views/mutators.qtpl:4
|
||||
//line views/mutators.qtpl:5
|
||||
var (
|
||||
_ = qtio422016.Copy
|
||||
_ = qt422016.AcquireByteBuffer
|
||||
)
|
||||
|
||||
//line views/mutators.qtpl:4
|
||||
//line views/mutators.qtpl:5
|
||||
func StreamToolbar(qw422016 *qt422016.Writer, u *user.User) {
|
||||
//line views/mutators.qtpl:5
|
||||
qw422016.N().S(`
|
||||
<aside class="edit-toolbar layout-card">
|
||||
<h2 class="edit-toolbar__title layout-card__title">Markup</h2>
|
||||
<section class="edit-toolbar__buttons">
|
||||
`)
|
||||
//line views/mutators.qtpl:9
|
||||
for _, el := range []struct {
|
||||
class string
|
||||
onclick string
|
||||
display string
|
||||
}{
|
||||
{"link", "wrapLink()", "[[link]]"},
|
||||
{"heading2", "insertHeading2()", "## heading"},
|
||||
{"heading3", "insertHeading3()", "### heading"},
|
||||
{"bold", "wrapBold()", "<b>**Bold**</b>"},
|
||||
{"italic", "wrapItalic()", "<i>//Italic//</i>"},
|
||||
{"highlighted", "wrapHighlighted()", "<mark>!!Highlight!!</mark>"},
|
||||
{"monospace", "wrapMonospace()", "<code>`Monospace`</code>"},
|
||||
{"lifted", "wrapLifted()", "<sup>^Lifted^</sup>"},
|
||||
{"lowered", "wrapLowered()", "<sub>,,Lowered,,</sub>"},
|
||||
{"strikethrough", "wrapStrikethrough()", "<strike>~~Strikethrough~~</strike>"},
|
||||
{"rocket", "insertRocket()", "=> rocketlink"},
|
||||
{"xcl", "insertXcl()", "<= transclusion"},
|
||||
{"img", "insertImgBlock()", "<code>img {}</code>"},
|
||||
{"table", "insertTableBlock()", "<code>table {}</code>"},
|
||||
{"hr", "insertHorizontalBar()", "Horizontal bar"},
|
||||
{"codeblock", "insertCodeblock()", "Code block"},
|
||||
{"bulletedlist", "insertBulletedList()", "* bullet list"},
|
||||
{"numberedlist", "insertNumberedList()", "*. number list"},
|
||||
} {
|
||||
//line views/mutators.qtpl:32
|
||||
qw422016.N().S(`
|
||||
<button
|
||||
class="edit-toolbar__btn edit-toolbar__`)
|
||||
//line views/mutators.qtpl:34
|
||||
qw422016.E().S(el.class)
|
||||
//line views/mutators.qtpl:34
|
||||
qw422016.N().S(`"
|
||||
onclick="`)
|
||||
//line views/mutators.qtpl:35
|
||||
qw422016.E().S(el.onclick)
|
||||
//line views/mutators.qtpl:35
|
||||
qw422016.N().S(`">
|
||||
`)
|
||||
//line views/mutators.qtpl:36
|
||||
qw422016.N().S(el.display)
|
||||
//line views/mutators.qtpl:36
|
||||
qw422016.N().S(`
|
||||
</button>
|
||||
`)
|
||||
//line views/mutators.qtpl:38
|
||||
}
|
||||
//line views/mutators.qtpl:38
|
||||
qw422016.N().S(`
|
||||
</section>
|
||||
<p class="edit-toolbar__ad"><a href="https://mycorrhiza.lesarbr.es/hypha/mycomarkup" target="_blank">Learn more</a> about mycomarkup</p>
|
||||
<h2 class="edit-toolbar__title layout-card__title">Actions</h2>
|
||||
<section class="edit-toolbar__buttons">
|
||||
`)
|
||||
//line views/mutators.qtpl:43
|
||||
for _, el := range []struct {
|
||||
class string
|
||||
onclick string
|
||||
display string
|
||||
}{
|
||||
{"date", "insertDate()", "Insert current date"},
|
||||
} {
|
||||
//line views/mutators.qtpl:49
|
||||
qw422016.N().S(`
|
||||
<button
|
||||
class="edit-toolbar__btn edit-toolbar__`)
|
||||
//line views/mutators.qtpl:51
|
||||
qw422016.E().S(el.class)
|
||||
//line views/mutators.qtpl:51
|
||||
qw422016.N().S(`"
|
||||
onclick="`)
|
||||
//line views/mutators.qtpl:52
|
||||
qw422016.E().S(el.onclick)
|
||||
//line views/mutators.qtpl:52
|
||||
qw422016.N().S(`">
|
||||
`)
|
||||
//line views/mutators.qtpl:53
|
||||
qw422016.N().S(el.display)
|
||||
//line views/mutators.qtpl:53
|
||||
qw422016.N().S(`
|
||||
</button>
|
||||
`)
|
||||
//line views/mutators.qtpl:55
|
||||
}
|
||||
//line views/mutators.qtpl:55
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line views/mutators.qtpl:56
|
||||
if u.Group != "anon" {
|
||||
//line views/mutators.qtpl:56
|
||||
qw422016.N().S(`
|
||||
<button
|
||||
class="edit-toolbar__btn edit-toolbar__user-link"
|
||||
onclick="insertUserlink()">
|
||||
Link yourself
|
||||
</button>
|
||||
`)
|
||||
//line views/mutators.qtpl:62
|
||||
}
|
||||
//line views/mutators.qtpl:62
|
||||
qw422016.N().S(`
|
||||
</section>
|
||||
</aside>
|
||||
<script src="/static/toolbar.js"></script>
|
||||
`)
|
||||
//line views/mutators.qtpl:66
|
||||
}
|
||||
|
||||
//line views/mutators.qtpl:66
|
||||
func WriteToolbar(qq422016 qtio422016.Writer, u *user.User) {
|
||||
//line views/mutators.qtpl:66
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line views/mutators.qtpl:66
|
||||
StreamToolbar(qw422016, u)
|
||||
//line views/mutators.qtpl:66
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line views/mutators.qtpl:66
|
||||
}
|
||||
|
||||
//line views/mutators.qtpl:66
|
||||
func Toolbar(u *user.User) string {
|
||||
//line views/mutators.qtpl:66
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line views/mutators.qtpl:66
|
||||
WriteToolbar(qb422016, u)
|
||||
//line views/mutators.qtpl:66
|
||||
qs422016 := string(qb422016.B)
|
||||
//line views/mutators.qtpl:66
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line views/mutators.qtpl:66
|
||||
return qs422016
|
||||
//line views/mutators.qtpl:66
|
||||
}
|
||||
|
||||
//line views/mutators.qtpl:68
|
||||
func StreamEditHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string) {
|
||||
//line views/mutators.qtpl:4
|
||||
//line views/mutators.qtpl:68
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line views/mutators.qtpl:5
|
||||
//line views/mutators.qtpl:69
|
||||
qw422016.N().S(NavHTML(rq, hyphaName, "edit"))
|
||||
//line views/mutators.qtpl:5
|
||||
//line views/mutators.qtpl:69
|
||||
qw422016.N().S(`
|
||||
<div class="layout">
|
||||
<main class="main-width edit edit_no-preview">
|
||||
<h1 class="edit__title">Edit `)
|
||||
//line views/mutators.qtpl:8
|
||||
//line views/mutators.qtpl:72
|
||||
qw422016.E().S(util.BeautifulName(hyphaName))
|
||||
//line views/mutators.qtpl:8
|
||||
//line views/mutators.qtpl:72
|
||||
qw422016.N().S(`</h1>
|
||||
`)
|
||||
//line views/mutators.qtpl:9
|
||||
//line views/mutators.qtpl:73
|
||||
qw422016.N().S(warning)
|
||||
//line views/mutators.qtpl:9
|
||||
//line views/mutators.qtpl:73
|
||||
qw422016.N().S(`
|
||||
<form method="post" class="edit-form"
|
||||
action="/upload-text/`)
|
||||
//line views/mutators.qtpl:11
|
||||
//line views/mutators.qtpl:75
|
||||
qw422016.E().S(hyphaName)
|
||||
//line views/mutators.qtpl:11
|
||||
//line views/mutators.qtpl:75
|
||||
qw422016.N().S(`">
|
||||
<textarea name="text">`)
|
||||
//line views/mutators.qtpl:12
|
||||
<textarea name="text" class="edit-form__textarea">`)
|
||||
//line views/mutators.qtpl:76
|
||||
qw422016.E().S(textAreaFill)
|
||||
//line views/mutators.qtpl:12
|
||||
//line views/mutators.qtpl:76
|
||||
qw422016.N().S(`</textarea>
|
||||
<br/>
|
||||
<input type="submit" name="action" value="Save" class="edit-form__save"/>
|
||||
<input type="submit" name="action" value="Preview" class="edit-form__preview">
|
||||
<a href="/page/`)
|
||||
//line views/mutators.qtpl:16
|
||||
//line views/mutators.qtpl:80
|
||||
qw422016.E().S(hyphaName)
|
||||
//line views/mutators.qtpl:16
|
||||
//line views/mutators.qtpl:80
|
||||
qw422016.N().S(`" class="edit-form__cancel">Cancel</a>
|
||||
</form>
|
||||
</main>
|
||||
`)
|
||||
//line views/mutators.qtpl:83
|
||||
qw422016.N().S(Toolbar(user.FromRequest(rq)))
|
||||
//line views/mutators.qtpl:83
|
||||
qw422016.N().S(`
|
||||
</div>
|
||||
`)
|
||||
//line views/mutators.qtpl:20
|
||||
//line views/mutators.qtpl:85
|
||||
}
|
||||
|
||||
//line views/mutators.qtpl:20
|
||||
//line views/mutators.qtpl:85
|
||||
func WriteEditHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string) {
|
||||
//line views/mutators.qtpl:20
|
||||
//line views/mutators.qtpl:85
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line views/mutators.qtpl:20
|
||||
//line views/mutators.qtpl:85
|
||||
StreamEditHTML(qw422016, rq, hyphaName, textAreaFill, warning)
|
||||
//line views/mutators.qtpl:20
|
||||
//line views/mutators.qtpl:85
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line views/mutators.qtpl:20
|
||||
//line views/mutators.qtpl:85
|
||||
}
|
||||
|
||||
//line views/mutators.qtpl:20
|
||||
//line views/mutators.qtpl:85
|
||||
func EditHTML(rq *http.Request, hyphaName, textAreaFill, warning string) string {
|
||||
//line views/mutators.qtpl:20
|
||||
//line views/mutators.qtpl:85
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line views/mutators.qtpl:20
|
||||
//line views/mutators.qtpl:85
|
||||
WriteEditHTML(qb422016, rq, hyphaName, textAreaFill, warning)
|
||||
//line views/mutators.qtpl:20
|
||||
//line views/mutators.qtpl:85
|
||||
qs422016 := string(qb422016.B)
|
||||
//line views/mutators.qtpl:20
|
||||
//line views/mutators.qtpl:85
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line views/mutators.qtpl:20
|
||||
//line views/mutators.qtpl:85
|
||||
return qs422016
|
||||
//line views/mutators.qtpl:20
|
||||
//line views/mutators.qtpl:85
|
||||
}
|
||||
|
||||
//line views/mutators.qtpl:22
|
||||
//line views/mutators.qtpl:87
|
||||
func StreamPreviewHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string, renderedPage string) {
|
||||
//line views/mutators.qtpl:22
|
||||
//line views/mutators.qtpl:87
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line views/mutators.qtpl:23
|
||||
//line views/mutators.qtpl:88
|
||||
qw422016.N().S(NavHTML(rq, hyphaName, "edit"))
|
||||
//line views/mutators.qtpl:23
|
||||
//line views/mutators.qtpl:88
|
||||
qw422016.N().S(`
|
||||
<div class="layout">
|
||||
<main class="main-width edit edit_with-preview">
|
||||
<h1>Edit `)
|
||||
//line views/mutators.qtpl:26
|
||||
//line views/mutators.qtpl:91
|
||||
qw422016.E().S(util.BeautifulName(hyphaName))
|
||||
//line views/mutators.qtpl:26
|
||||
//line views/mutators.qtpl:91
|
||||
qw422016.N().S(` (preview)</h1>
|
||||
`)
|
||||
//line views/mutators.qtpl:27
|
||||
//line views/mutators.qtpl:92
|
||||
qw422016.N().S(warning)
|
||||
//line views/mutators.qtpl:27
|
||||
//line views/mutators.qtpl:92
|
||||
qw422016.N().S(`
|
||||
<form method="post" class="edit-form"
|
||||
action="/upload-text/`)
|
||||
//line views/mutators.qtpl:29
|
||||
//line views/mutators.qtpl:94
|
||||
qw422016.E().S(hyphaName)
|
||||
//line views/mutators.qtpl:29
|
||||
//line views/mutators.qtpl:94
|
||||
qw422016.N().S(`">
|
||||
<textarea name="text">`)
|
||||
//line views/mutators.qtpl:30
|
||||
<textarea class="edit-form__textarea" name="text">`)
|
||||
//line views/mutators.qtpl:95
|
||||
qw422016.E().S(textAreaFill)
|
||||
//line views/mutators.qtpl:30
|
||||
//line views/mutators.qtpl:95
|
||||
qw422016.N().S(`</textarea>
|
||||
<br/>
|
||||
<input type="submit" name="action" value="Save" class="edit-form__save"/>
|
||||
<input type="submit" name="action" value="Preview" class="edit-form__preview">
|
||||
<a href="/page/`)
|
||||
//line views/mutators.qtpl:34
|
||||
//line views/mutators.qtpl:99
|
||||
qw422016.E().S(hyphaName)
|
||||
//line views/mutators.qtpl:34
|
||||
//line views/mutators.qtpl:99
|
||||
qw422016.N().S(`" class="edit-form__cancel">Cancel</a>
|
||||
</form>
|
||||
<p class="warning">Note that the hypha is not saved yet. You can preview the changes ↓</p>
|
||||
<article class="edit__preview">`)
|
||||
//line views/mutators.qtpl:37
|
||||
//line views/mutators.qtpl:102
|
||||
qw422016.N().S(renderedPage)
|
||||
//line views/mutators.qtpl:37
|
||||
//line views/mutators.qtpl:102
|
||||
qw422016.N().S(`</article>
|
||||
</main>
|
||||
`)
|
||||
//line views/mutators.qtpl:104
|
||||
qw422016.N().S(Toolbar(user.FromRequest(rq)))
|
||||
//line views/mutators.qtpl:104
|
||||
qw422016.N().S(`
|
||||
</div>
|
||||
`)
|
||||
//line views/mutators.qtpl:40
|
||||
//line views/mutators.qtpl:106
|
||||
}
|
||||
|
||||
//line views/mutators.qtpl:40
|
||||
//line views/mutators.qtpl:106
|
||||
func WritePreviewHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName, textAreaFill, warning string, renderedPage string) {
|
||||
//line views/mutators.qtpl:40
|
||||
//line views/mutators.qtpl:106
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line views/mutators.qtpl:40
|
||||
//line views/mutators.qtpl:106
|
||||
StreamPreviewHTML(qw422016, rq, hyphaName, textAreaFill, warning, renderedPage)
|
||||
//line views/mutators.qtpl:40
|
||||
//line views/mutators.qtpl:106
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line views/mutators.qtpl:40
|
||||
//line views/mutators.qtpl:106
|
||||
}
|
||||
|
||||
//line views/mutators.qtpl:40
|
||||
//line views/mutators.qtpl:106
|
||||
func PreviewHTML(rq *http.Request, hyphaName, textAreaFill, warning string, renderedPage string) string {
|
||||
//line views/mutators.qtpl:40
|
||||
//line views/mutators.qtpl:106
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line views/mutators.qtpl:40
|
||||
//line views/mutators.qtpl:106
|
||||
WritePreviewHTML(qb422016, rq, hyphaName, textAreaFill, warning, renderedPage)
|
||||
//line views/mutators.qtpl:40
|
||||
//line views/mutators.qtpl:106
|
||||
qs422016 := string(qb422016.B)
|
||||
//line views/mutators.qtpl:40
|
||||
//line views/mutators.qtpl:106
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line views/mutators.qtpl:40
|
||||
//line views/mutators.qtpl:106
|
||||
return qs422016
|
||||
//line views/mutators.qtpl:40
|
||||
//line views/mutators.qtpl:106
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ var navEntries = []navEntry{
|
||||
{% if u.Group == "anon" %}
|
||||
<a href="/login" class="header-links__link">Login</a>
|
||||
{% else %}
|
||||
<a href="/page/{%s util.UserHypha %}/{%s u.Name %}" class="header-links__link">{%s u.Name %}</a>
|
||||
<a href="/hypha/{%s util.UserHypha %}/{%s u.Name %}" class="header-links__link">{%s u.Name %}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
|
@ -162,7 +162,7 @@ func StreamUserMenuHTML(qw422016 *qt422016.Writer, u *user.User) {
|
||||
} else {
|
||||
//line views/nav.qtpl:54
|
||||
qw422016.N().S(`
|
||||
<a href="/page/`)
|
||||
<a href="/hypha/`)
|
||||
//line views/nav.qtpl:55
|
||||
qw422016.E().S(util.UserHypha)
|
||||
//line views/nav.qtpl:55
|
||||
|
@ -97,7 +97,7 @@ for u := range user.YieldUsers() {
|
||||
<section>
|
||||
<h1>About {%s util.SiteName %}</h1>
|
||||
<ul>
|
||||
<li><b><a href="https://mycorrhiza.lesarbr.es">MycorrhizaWiki</a> version:</b> 1.0.0</li>
|
||||
<li><b><a href="https://mycorrhiza.lesarbr.es">MycorrhizaWiki</a> version:</b> 1.1.0</li>
|
||||
{%- if user.AuthUsed -%}
|
||||
<li><b>User count:</b> {%d user.Count() %}</li>
|
||||
<li><b>Home page:</b> <a href="/">{%s util.HomePage %}</a></li>
|
||||
|
@ -352,7 +352,7 @@ func StreamAboutHTML(qw422016 *qt422016.Writer) {
|
||||
//line views/stuff.qtpl:98
|
||||
qw422016.N().S(`</h1>
|
||||
<ul>
|
||||
<li><b><a href="https://mycorrhiza.lesarbr.es">MycorrhizaWiki</a> version:</b> β 0.13</li>
|
||||
<li><b><a href="https://mycorrhiza.lesarbr.es">MycorrhizaWiki</a> version:</b> 1.1.0</li>
|
||||
`)
|
||||
//line views/stuff.qtpl:101
|
||||
if user.AuthUsed {
|
||||
|
Loading…
Reference in New Issue
Block a user