Compare commits

...

71 Commits

Author SHA1 Message Date
nekobit 2cb5bf79e0 Pledge flag
FossilOrigin-Name: e28716be9707aa232727f8ffe623eb73e79a7cfbc319be5e2c1664297bf4d2a5
2023-06-01 03:27:33 +00:00
nekobit fa92ac39d4 Fix status submission
FossilOrigin-Name: 5f60ebaa5fd46b5a954c0631e25ebf45f7b9ed9b917900a880f675062afa5140
2023-06-01 02:45:48 +00:00
nekobit 3a9dfa3dc9 Semi-broken login (it works (it doesn't))
FossilOrigin-Name: b256948f2166a866971b0e8f06497d71899a834fb972e346ce5675d697233208
2023-06-01 02:26:14 +00:00
nekobit c3e8efd394 Show login page (what's it doing in conversations.c?)
FossilOrigin-Name: 6757a70f24f25445893fa991cdedfee3298004e392285459b05eeba180fc899b
2023-06-01 01:54:23 +00:00
nekobit 9b476d3ab5 OpenBSD Pledge support
FossilOrigin-Name: 8cedfc5118348282ee78d14830a8d64326a62f91d34492e2f6b31e924cda0d5d
2023-06-01 01:10:47 +00:00
nekobit d4cd539019 Shorten OpenHTTPD example
FossilOrigin-Name: 3a32415027a7411ca7daac0f6b53261c4b20acf81005c9ef3196e04a36ce3298
2023-06-01 00:53:34 +00:00
nekobit 87586c6060 Fix paths, add debug, OpenHTTPD config
FossilOrigin-Name: 1aae905aee3907546c8cbe87a5990a6f09e9c91fb0dbcc064a06be5976fe01bb
2023-05-31 22:45:03 +00:00
nekobit b798501cc3 Fix - Building again :)
FossilOrigin-Name: 1781fda1a0fdc7705c1bc3d23d8f3118f93e4aad74971d71a635bb9195161300
2023-05-31 19:43:48 +00:00
nekobit ab6f8a58f4 Build again (with some hacks)
FossilOrigin-Name: 16e1c0939fda0e73429904ab72c386555a859d7a3ae4327d77b2aa55db9ae7b4
2023-05-31 16:47:17 +00:00
nekobit e003337b5c Makefile
FossilOrigin-Name: 9b32280cb809c26ca511f8dcda5fff3a8bc19a517ff60c095cde46ad3ad606e2
2023-05-31 15:30:42 +00:00
nekobit cb11af71f1 Build file-to-c, set dependencies
FossilOrigin-Name: cb8cb1429e23c7bd7ce43ede38d3affd42ff3616714b476bd39d08a7644cf3f3
2023-04-05 14:58:15 +00:00
nekobit 109ad1fc08 Switch to premake5, as we need custom rules for .ctt generation
FossilOrigin-Name: 53c0a5d0fd0c60024ae08322a97e790752a714e7576e26eb56b83afcf48cc392
2023-04-03 16:56:16 +00:00
nekobit 82522a99b3 Splash text; fix building (!!!); fix install subcommand
FossilOrigin-Name: f2231a6e284132794d0a83ba94466329f0fb98a7098b7bd78fe3f33144504f80
2023-04-02 06:13:54 +00:00
nekobit 33fcc22d3c Refactor notifications
FossilOrigin-Name: f004687ef197a3e2e66e47c69de9453eb9c6d60a92d8eb15e7b7bde39816f574
2023-04-01 23:47:33 +00:00
nekobit 5e5274da26 Work
FossilOrigin-Name: f629ca882d2efe8f6b169748e36ea9b6fe4d03187abc9e60c0cd6ae50f7ec6cf
2023-03-31 03:32:40 +00:00
nekobit dfd8cfac84 Fix timeline code
FossilOrigin-Name: aec1e1d87eea9acfc6f084ddfedccb80a204e78c7acc2b787fd1256b491bb029
2023-03-29 03:41:30 +00:00
nekobit 0b1b8f60a4 Cleanup
FossilOrigin-Name: 66200db6f53cf736216777c7922d658ef47c00b93d2aa5844babf81d98a91359
2023-03-27 04:03:59 +00:00
nekobit 9518274848 Merge files
FossilOrigin-Name: 6ec1414ee879b0cfacb461460908e5b0f7495551a031e0da1111d841139389a8
2023-03-27 04:01:36 +00:00
nekobit 78c09fd7dc Finish premake transition
FossilOrigin-Name: 30676561791954ccd8a2d8cb627fdb74b0cd38780ffa3b17a9aae4719a26e3fe
2023-03-27 03:36:57 +00:00
nekobit 7634b3df93 Fully switch to premake (a little more sane to write and maintain)
FossilOrigin-Name: fe55e222e21c7ba224ea4c584f727fcb827b7d4aeaff910a2befcd3f3d90f203
2023-03-26 06:31:33 +00:00
nekobit 4e8c7defc3 Switch to premake slowly...
FossilOrigin-Name: fbec91473a28cdf9b9d94b75b3955be56fd0fb20975a8219958fae284c523315
2023-03-24 18:55:46 +00:00
nekobit e4f23744a7 Use SH
FossilOrigin-Name: d516366a9551a2d23ce09363c2c5185bfab603d8d8c40cb44b1fd6cfdc5a463a
2023-03-13 00:00:37 +00:00
nekobit e1c08901f8 FCGI
FossilOrigin-Name: bb3e5b890e12776482d79f2ccdcaad1790f03a2aa5a7849f4b9ce92489087c26
2023-01-23 18:55:30 +00:00
nekobit e51bc1a07e Adapt to Mastodont changes
FossilOrigin-Name: 10ac21ded4f9b6804157e5743ea07a4a3b1e4727b98564334ce1f87549bf399f
2023-01-09 05:00:16 +00:00
nekobit d20f868298 Commit some old code
FossilOrigin-Name: 97ae2bdaee07382649c07e800fe89d61c640c741627302a0e421822bffa8a8bb
2023-01-06 04:24:03 +00:00
nekobit c16d4d1e5a Fix building
FossilOrigin-Name: 23ab87adce4f3c30bb7716de45bfb359c2cb8088243ac467acc2460e98bf0f37
2022-12-11 00:22:41 +00:00
nekobit edd7a36ae9 Remove old Makefile
FossilOrigin-Name: 144c687c53b02843d83e63e9d6415e875432430b3144f4d7c437687165a39fab
2022-12-09 04:49:21 +00:00
nekobit 9ddcac5306 Finish CMake transition
FossilOrigin-Name: 6a63f03686edee983ac265f330f278b6eb8a9f1c648aaef362fa7f062d168e21
2022-12-09 04:48:30 +00:00
nekobit b25d6a9df0 Write some code
FossilOrigin-Name: c84a11a61611ca961d9cb06707556e466d489b5ead938410ba7fb5387f83f5a3
2022-12-08 19:43:38 +00:00
nekobit 631265909e Change to function?
FossilOrigin-Name: 178a95074ac7af7d4193b789e6e485cedb30eefe2c25bd2c83ca325364bc7eb0
2022-12-08 04:04:12 +00:00
nekobit 5ffd8efe04 CMP functions, some CMake that needs to be done
FossilOrigin-Name: 7d1d963fb8812052d9a10db0deb9b4d301d8666d79aba2dbbc3308ec012bf65c
2022-12-07 19:49:39 +00:00
nekobit 37ec828fa2 Link and include Mastodont
FossilOrigin-Name: 2f4c7035c43f8722e279ee9d605e3b8dfb22afe70c4e66c13e98b5892e8a0b0d
2022-12-06 13:04:44 +00:00
nekobit a1c962a853 Fix building
FossilOrigin-Name: aac82bf9e182f90c88d93f52c2c2141cfc9ab86a5d3bc97f7aa080d7e9a1b3f8
2022-12-06 04:14:35 +00:00
nekobit 9ba31b4ebe CMake work
FossilOrigin-Name: fc43382ed20bb36d754d5123c6188563555782caaffd93192c31023332d2e479
2022-12-06 02:44:51 +00:00
nekobit bfda933431 More CMake stuff
FossilOrigin-Name: d07dcffeebdce3068ada45fb7be2479b36810b6970fa36803a7beb2ddc4667e2
2022-12-05 06:00:54 +00:00
nekobit d933f9fe02 A
FossilOrigin-Name: 09a5517fd289cbc0e967755a1fd6d705bdae75d2c65ecf61dfb861695f721375
2022-12-05 04:01:44 +00:00
nekobit 2715ebb175 Important change
FossilOrigin-Name: 5bd959849cbad379e55bdfca0134d83047e4bc787245dd4280f30d0471c12332
2022-12-03 05:04:20 +00:00
nekobit 97eb61fd45 CMake stuff
FossilOrigin-Name: fe1c7dd140d5709f64904904144c835c1e8e2e2a494895b607ec54bdbab92a8c
2022-12-02 17:14:20 +00:00
nekobit bf586e1e92 App
FossilOrigin-Name: ccf9afaa8dde90b3fa084d3ac42a7b28cbf414d26f3e43af6be20807247e2cd0
2022-12-02 04:46:39 +00:00
nekobit 409f28f9cb login: Cleanup
FossilOrigin-Name: 37b224636147511617d495c35527b1ba8cc2ccde6a234c8b69de3c4af13bfd2d
2022-11-26 05:42:53 +00:00
nekobit 8fed61fdb6 Lists
FossilOrigin-Name: e33572d15d141079700fad9e58a73a7654fd00b2e8e0634067ad7a6532ff66b1
2022-11-24 15:50:21 +00:00
nekobit 56ba9b6918 conversations: Fix up
FossilOrigin-Name: da36cd4dca212d5e026bb2c6e3f2eeb0b082600f09ef1e1094a592b0560e474b
2022-11-24 05:04:15 +00:00
nekobit a08a43e7dc base_page: Finish notifs or call directly
FossilOrigin-Name: 940805ebcea555253f5b98a7cb108c56cbb428a1796cd9bd2257db351c4eb33e
2022-11-23 21:34:32 +00:00
nekobit 519941f54a path_args_create, split up base_page a bit
FossilOrigin-Name: 426bdb9d1b351ba568c81f4d1e5ba1080721dd3053e63d49043f445763fe3c8c
2022-11-23 19:49:58 +00:00
nekobit f1f797a6d4 attachments: Disable for now
FossilOrigin-Name: 8571df1890caec8f6d0b1bd724d7aeef21874a61d52ae20637a20f830e7dc8a6
2022-11-23 19:08:58 +00:00
nekobit d3c0258491 Fix the account page already. About fucking time...
FossilOrigin-Name: 6684ef5b8bb5fdbaf01fb01884a173dd29775f02b8b35d192b710c717c0380e9
2022-11-20 03:42:21 +00:00
nekobit 578a35f689 More cleanup; moving things around and stuff
FossilOrigin-Name: 0bbb0b95f97d7830eacf08b2d60ec1c9ab8e91998d75aefaf58a03327781cc54
2022-11-17 16:06:55 +00:00
nekobit 616f3eee20 Setup acct_fetch_args_cleanup
FossilOrigin-Name: c1df593b26914dd7679d43629238f9847c034cfb0123101a0acc4663c67f69b8
2022-11-17 13:01:36 +00:00
nekobit a5cfedd5f4 More sleepy cleanup
FossilOrigin-Name: b8ed9af1b63a7b22e2668b8a6a65f41250c779511c2b1f0533f4fc00ddb554bd
2022-11-17 03:51:26 +00:00
nekobit 3a1e65e7fe Change account_page type
FossilOrigin-Name: fbda59794225258a8938a7e3e4c22bc9ccc1c32ee8fa04885c3d67830bfb8aa2
2022-11-14 18:54:00 +00:00
nekobit f51561f3a7 Refactoring
FossilOrigin-Name: 35e4accfb75741d0ab855d4b775e1b943a29abe16adcd44d204814087a53f6de
2022-11-14 17:59:07 +00:00
nekobit ded0b83151 3rd clause
FossilOrigin-Name: 8766275cac121ced2142c9dee80f2c21a0337e9eb65501961807aba8fca0f252
2022-11-14 15:36:33 +00:00
nekobit 46d9153d59 Fix
FossilOrigin-Name: 066b2ea574cbe608ba83bee1d8758a53d1bc1794c8dab8e5021760908263c4b1
2022-11-14 14:27:15 +00:00
nekobit 1bcd944584 Add bugs
FossilOrigin-Name: aad31b66d4026159283cb42fe630a61d892565c3a0d95a90de7bca7aaf6be9a8
2022-11-14 14:18:35 +00:00
nekobit 56b7525991 Update arguments for callbacks
FossilOrigin-Name: 8c2b6d4c10e97a78b45219e250956f0eabc3cd2b590ecb1564f6e5654b621952
2022-11-11 20:05:20 +00:00
nekobit 9960286341 Save
FossilOrigin-Name: 15895cd406aaf2a779078ad5241203352614f235ab5494ed0744812950289d76
2022-11-10 19:47:18 +00:00
nekobit f03f49260e Accounts progress
FossilOrigin-Name: 6550ddf97d93b3b909c13f54764b679b92539dcbae11aaea314589bbd6898e4a
2022-11-09 19:48:44 +00:00
nekobit 5d0a0f0ed5 Account page fixing
FossilOrigin-Name: 630c28e3227bb7e3d233166bff7444f011c6e0ed37c4281ed3e194b4a535ad83
2022-11-09 15:48:04 +00:00
nekobit 04d4dac90e Timelines
FossilOrigin-Name: c0b3be0fe08e89ede517f8ffb3eed0ac81f0204e25b33909e0e08576395e390c
2022-11-07 14:31:44 +00:00
nekobit 9d2a19f758 Show timeline
FossilOrigin-Name: 8d149efa9a9eed8475589f640a8561c377ced7e6a08ee2c19349969979014811
2022-11-07 01:58:56 +00:00
nekobit 2874999a8d Some code
FossilOrigin-Name: dc1d1dac0324637a329c19137b2532b339b440e4c485be05dd801b2759e2275f
2022-11-07 00:11:35 +00:00
nekobit 82eb9ac9f2 Progress
FossilOrigin-Name: dc24939b1ca1f32f6ebe9e199572e6c83c701f79197df7ea908f4b8a7288fe87
2022-11-04 18:11:51 +00:00
nekobit 7802d69f8b fds
FossilOrigin-Name: 61160b5993d9cbfb16a4cd1b6daa235ab071e95aee74c1572db6e34ac250f083
2022-11-02 03:38:34 +00:00
nekobit 7168473bfa Compilation
FossilOrigin-Name: d21721a8e53b75adf39c267be103126b6eb4fbb3457a6e52d9d300235855c426
2022-11-01 14:29:26 +00:00
nekobit 8591309af1 Progress
FossilOrigin-Name: 76a93e098733f2bf1eae90faf66ebafbc07506d14c2ec9fd5c97d538f7dfa2fa
2022-11-01 02:44:23 +00:00
nekobit 9407408044 Comment out some code
FossilOrigin-Name: 5a25a51a723fbd2ce3e19bdae48ad95c638bae147b4fa77632738d3b8ae9c451
2022-10-31 18:48:48 +00:00
nekobit bf3af231c8 Async stuff
FossilOrigin-Name: 65fba45d6d6e5cb9318b881b0b137be84030afe64200f793fb7f5cf55d41b48c
2022-10-31 18:08:54 +00:00
nekobit 8c34f90655 Ignore docs
FossilOrigin-Name: b75175b329042ca2b047287d4e36f85b0b2763d8c007ecd96fc0d0265a942f02
2022-10-31 16:59:11 +00:00
nekobit d271e103c4 Change return values
FossilOrigin-Name: 131439963d2dbece2340d41df2180ebe6546280fe0aece649510e8f404135dc0
2022-10-31 12:36:39 +00:00
nekobit 7124bb35ca Remove MULTITHREADING
FossilOrigin-Name: 17eba667d38eb39c68d2dc452ceeb0866086ff70a99fc3a62c0d75355c66f369
2022-10-31 12:13:02 +00:00
nekobit eaf8771f45 Build
FossilOrigin-Name: 89d23316a0f1f697ba17c2fa264a90ae9d729b892a7c578f91192ae1ba332eed
2022-10-27 15:07:20 +00:00
93 changed files with 1830 additions and 3383 deletions

View File

@ -12,4 +12,9 @@ treebird
test/tests
scripts/*.o
templates/*.ctt
test/unit/*.bin
test/unit/*.bin
treebird.core
filec.core
compile_commands.json
build/
obj/

687
LICENSE
View File

@ -1,661 +1,26 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.
Copyright (c) 2022, Nekobit
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,9 +1,18 @@
CC ?= cc
GIT ?= git
MASTODONT_DIR = mastodont-c/
MASTODONT = $(MASTODONT_DIR)libmastodont.a
CFLAGS += -Wall -I $(MASTODONT_DIR)include/ -Wno-unused-variable -Wno-ignored-qualifiers -I/usr/include/ -I $(MASTODONT_DIR)/libs $(shell pkg-config --cflags libcurl) `perl -MExtUtils::Embed -e ccopts` -DDEBUGGING_MSTATS
LDFLAGS += -L$(MASTODONT_DIR) -lmastodont $(shell pkg-config --libs libcurl) -lfcgi -lpthread `perl -MExtUtils::Embed -e ldopts` -DDEBUGGING_MSTATS
MASTODONT_DIR = mastodont-c
ifneq ($(wildcard $(MASTODONT_DIR)/bin/Release),)
MASTODONT = $(MASTODONT_DIR)/bin/Release/
else ifneq ($(wildcard $(MASTODONT_DIR)/bin/Debug),)
MASTODONT = $(MASTODONT_DIR)/bin/Debug/
endif
CFLAGS += -Wall -g -I $(MASTODONT_DIR)/include/ -Wno-unused-variable -Wno-ignored-qualifiers \
-I/usr/include/ -I $(MASTODONT_DIR)/libs $(shell pkg-config --cflags libcurl libcjson) \
`perl -MExtUtils::Embed -e ccopts` -DDEBUGGING_MSTATS
LDFLAGS += -L$(MASTODONT) -lmastodont $(shell pkg-config --libs libcurl libcjson) -lfcgi \
-lpthread `perl -MExtUtils::Embed -e ldopts` -DDEBUGGING_MSTATS
# libpcre2-8 (?)
SRC = $(wildcard src/*.c)
OBJ = $(patsubst %.c,%.o,$(SRC))
@ -25,16 +34,16 @@ MASTODONT_URL = https://fossil.nekobit.net/mastodont-c
# Not parallel friendly
#all: $(MASTODONT_DIR) dep_build $(TARGET)
ifneq ($(strip $(SINGLE_THREADED)),)
CFLAGS += -DSINGLE_THREADED
endif
ifneq ($(strip $(SINGLE_THREADED)),)
ifneq ($(strip $(DEBUG)),)
CFLAGS += -DDEBUG
endif
all:
$(MAKE) dep_build
ifeq ($(wildcard $(MASTODONT_DIR)),)
@echo "[ERROR] Mastodont-c/ not found. Link it with ln -s in this directory."
@exit 1
endif
$(MAKE) filec
$(MAKE) make_tmpls
$(MAKE) $(TARGET)
@ -70,9 +79,6 @@ test: all $(UNIT_TESTS)
@echo " ... Tests ready"
@./test/test.pl
dep_build:
make -C $(MASTODONT_DIR)
%.o: %.c %.h $(PAGES)
$(CC) $(CFLAGS) -c $< -o $@

View File

@ -1,5 +1,3 @@
# NOTE: This software is not finished. Any bugs are likely noted
# Treebird
![Treebird logo](./meta/treebird.png)
@ -11,8 +9,7 @@ usable enough to improve the experience with JS.
Treebird uses C with FCGI, mastodont-c (library designed for Treebird, but can be used
for other applications as well), Perl, and **optional** JavaScript for the frontend (100% functional without
javascript, it only helps). Uses [RE:DOM](https://redom.js.org/) (2kb JS library) to assist with DOM
creation and native JS apis. (Already bundled)
javascript, it only helps).
## Why?

View File

@ -1,32 +1,45 @@
# Installing Treebird
This is a stub and isn't complete, please update it!
## Compiling
For the following GNU/Linux distributions, you will need the following libraries/packages:
For the following UNIX-like system, you will need the following libraries/packages:
###### Debian
`# apt install libcurl4-gnutls-dev libpcre2-dev libfcgi-dev build-essential perl libperl-dev libtemplate-perl`
`# apt install libcurl4-gnutls-dev libfcgi-dev build-essential perl libperl-dev libtemplate-perl`
###### Void GNU/Linux
`# xbps-install libcurl libcurl-devel base-devel pcre2 pcre2-devel fcgi fcgi-devel perl-Template-Toolkit`
`# xbps-install libcurl libcurl-devel base-devel fcgi fcgi-devel perl-Template-Toolkit`
###### Arch
`# pacman -S curl base-devel perl perl-template-toolkit`
###### OpenBSD
`# pkg_add curl fcgi spawn-fcgi p5-Template cjson gmake`
(**Note:** Treebird supports Pledge and Unveil!)
###### Gentoo
TODO
Create a copy of `config.def.h` at `config.h`, edit the file with your information
###### FreeBSD
Run `make`. (**hint:** Pass -j3 to speed up compilation). This will also clone mastodont-c, and compile both it and Treebird.
`# pkg install p5-Template-Toolkit fcgi-devkit curl gmake`
If you `fossil update` any changes, `make update` should be run after updating
---
Install mastodont-c. `fossil clone https://code.nekobit.net/fossil/mastodont-c`,
`premake4 gmake`, `make`, `make install`.
Create a copy of `config.def.h` at `config.h`, edit the file with your
information. Note that this setup will change in the
future.
Run `make` (or `gmake`).
## Perl dependencies manual install
@ -53,7 +66,7 @@ Run `# make install`
If this succeeds (assuming you used default variables), you can now find Treebird at the following
- `/usr/local/share/treebird/` - Contains CSS, images, and other meta files
- `/usr/local/share/treebird/` - Contains CSS, images, perl, and other meta files
- `/usr/local/bin/treebird` - Regular executable CGI file, test it by running it as is, it shouldn't spit anything out
## Development
@ -75,9 +88,14 @@ spawn-fcgi in `scripts/fcgistarter.sh`.
An example Apache configuration is available in [treebird.apache.conf](./sample/treebird.apache.conf).
## OpenHTTPd / httpd(8)
OpenBSD's httpd config file is available. Bare in mind that `slowcgi` *WILL*
not work (for now). Please use `spawn-fcgi`.
#### spawn-fcgi
`spawn-fcgi` can be used for both Apache and Nginx. Read the manual for it to see how to work it, or view
`spawn-fcgi` can be used for both Apache, OpenHTTPd (httpd(8)) and Nginx. Read the manual for it to see how to work it, or view
the testing script at `scripts/fcgistarter.sh`
- Please, at all costs, avoid FCGIWrap. It's caused nothing but headaches and has proved no real use other than

View File

@ -0,0 +1,7 @@
server "default" {
listen on * port 80
location match "/(.+).([pc]?[nsj][sg])" { root "htdocs/treebird" }
location match "^/.*$" {
fastcgi socket tcp localhost 4008
}
}

View File

@ -1,2 +1,2 @@
#!/bin/bash
#!/bin/sh
spawn-fcgi -a 127.0.0.1 -p 4008 -n treebird

View File

@ -1,26 +1,14 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
*
* Licensed under BSD 3-Clause License
*/
#include <stdlib.h>
#include "base_page.h"
#include "about.h"
void content_about(PATH_ARGS)
int content_about(PATH_ARGS)
{
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
@ -39,10 +27,11 @@ void content_about(PATH_ARGS)
render_base_page(&b, req, ssn, api);
tb_free(dup);
return 0;
}
void content_about_license(PATH_ARGS)
int content_about_license(PATH_ARGS)
{
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
@ -62,5 +51,6 @@ void content_about_license(PATH_ARGS)
render_base_page(&b, req, ssn, api);
tb_free(dup);
return 0;
}

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
*
* Licensed under BSD 3-Clause License
*/
#ifndef ABOUT_H
@ -22,7 +10,7 @@
#include "session.h"
#include "path.h"
void content_about_license(PATH_ARGS);
void content_about(PATH_ARGS);
int content_about_license(PATH_ARGS);
int content_about(PATH_ARGS);
#endif /* ABOUT_H */

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
*
* Licensed under BSD 3-Clause License
*/
#include <string.h>
@ -33,6 +21,7 @@
#include "string_helpers.h"
#include "emoji.h"
#include "timeline.h"
#include "types.h"
#define FOLLOWS_YOU_HTML "<span class=\"acct-badge\">%s</span>"
@ -43,29 +32,92 @@ struct account_args
uint8_t flags;
};
static char* accounts_page(HV* session_hv,
mastodont_t* api,
struct mstdnt_account* acct,
struct mstdnt_relationship* rel,
char* header,
struct mstdnt_storage* storage,
struct mstdnt_account* accts,
size_t accts_len)
/// Used to pair accounts and relations for requests
typedef struct _acct_relations_pair
{
// ->data will give mstdnt_accounts* as void*
mstdnt_request_cb_data* acct_data;
// ->data will give mstdnt_relationships* as void*
mstdnt_request_cb_data* rels_data;
} acct_relations_pair;
struct acct_fetch_args;
typedef void (*account_page_cb)(struct acct_fetch_args* fetch_args);
typedef struct acct_fetch_args
{
HV* session_hv;
struct request_args* req_args;
acct_relations_pair pair;
const char* id;
enum account_tab tab;
account_page_cb callback;
void* args;
} acct_fetch_args;
static void
acct_fetch_args_cleanup(acct_fetch_args* args)
{
request_args_cleanup(args->req_args);
// This should clean itself when passed to `render_base_page'
//free(session_hv);
free(args->args);
mstdnt_request_cb_cleanup(args->pair.acct_data);
mstdnt_request_cb_cleanup(args->pair.rels_data);
}
/**
* Returns the final account page, and cleans up
*
* @param args Args, will cleanup.
* @param data Page data, will cleanup.
*/
static void
account_page(acct_fetch_args* args, char* data)
{
struct base_page b = {
.category = BASE_CAT_NONE,
.content = data,
.session = args->session_hv,
.sidebar_left = NULL
};
/* Output */
render_base_page(&b,
args->req_args->req,
args->req_args->ssn,
args->req_args->api);
tb_free(data);
// Cleanup rest of the data from args
request_args_cleanup(args->req_args);
free(args);
}
static void
accounts_page(acct_fetch_args* args,
char* header,
struct mstdnt_accounts* accts)
{
char* output;
PERL_STACK_INIT;
XPUSHs(newRV_noinc((SV*)session_hv));
XPUSHs(newRV_noinc((SV*)args->session_hv));
XPUSHs(newRV_noinc((SV*)template_files));
if (acct)
mXPUSHs(newRV_noinc((SV*)perlify_account(acct)));
else ARG_UNDEFINED();
if (rel)
mXPUSHs(newRV_noinc((SV*)perlify_relationship(rel)));
if (args->pair.acct_data->data)
mXPUSHs(newRV_noinc((SV*)
perlify_account(args->pair.acct_data->data)));
else ARG_UNDEFINED();
if (accts && accts_len)
mXPUSHs(newRV_noinc((SV*)perlify_accounts(accts, accts_len)));
if (args->pair.rels_data->data)
mXPUSHs(newRV_noinc((SV*)
perlify_relationship(args->pair.rels_data->data)));
else ARG_UNDEFINED();
if (accts)
mXPUSHs(newRV_noinc((SV*)perlify_accounts(accts->accts, accts->len)));
else ARG_UNDEFINED();
// perlapi doesn't specify if a string length of 0 calls strlen so calling just to be safe...
@ -75,24 +127,31 @@ static char* accounts_page(HV* session_hv,
PERL_STACK_SCALAR_CALL("account::content_accounts");
output = PERL_GET_STACK_EXIT;
mstdnt_storage_cleanup(storage);
mstdnt_cleanup_accounts(accts, accts_len);
return output;
account_page(args, output);
}
static char* account_followers_cb(HV* session_hv,
struct session* ssn,
mastodont_t* api,
struct mstdnt_account* acct,
struct mstdnt_relationship* rel,
void* _args)
// Callback: account_followers_cb
static int
request_cb_account_follow_page(mstdnt_request_cb_data* cb_data,
void* args)
{
struct mstdnt_accounts* accts = MSTDNT_CB_DATA(cb_data);
acct_fetch_args* data = args;
accounts_page(data,
NULL,
accts);
return MSTDNT_REQUEST_DONE;
}
static void
account_followers_cb(acct_fetch_args* fetch_args)
{
struct mstdnt_args m_args;
struct session* ssn = fetch_args->req_args->ssn;
struct mstdnt_account* acct = fetch_args->pair.acct_data->data;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 };
struct mstdnt_account* accounts = NULL;
size_t accts_len = 0;
char* result;
struct mstdnt_account_args args = {
@ -104,23 +163,18 @@ static char* account_followers_cb(HV* session_hv,
.with_relationships = 0,
};
mstdnt_get_followers(api, &m_args, acct->id, &args, &storage, &accounts, &accts_len);
return accounts_page(session_hv, api, acct, rel, NULL, &storage, accounts, accts_len);
mstdnt_get_followers(fetch_args->req_args->api, &m_args,
request_cb_account_follow_page, fetch_args,
acct->id, args);
}
static char* account_following_cb(HV* session_hv,
struct session* ssn,
mastodont_t* api,
struct mstdnt_account* acct,
struct mstdnt_relationship* rel,
void* _args)
static void
account_following_cb(acct_fetch_args* fetch_args)
{
struct mstdnt_args m_args;
struct session* ssn = fetch_args->req_args->ssn;
struct mstdnt_account* acct = fetch_args->pair.acct_data->data;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 };
struct mstdnt_account* accounts = NULL;
size_t accts_len = 0;
char* result;
struct mstdnt_account_args args = {
@ -132,64 +186,105 @@ static char* account_following_cb(HV* session_hv,
.with_relationships = 0,
};
mstdnt_get_following(api, &m_args, acct->id, &args, &storage, &accounts, &accts_len);
return accounts_page(session_hv, api, acct, rel, NULL, &storage, accounts, accts_len);
mstdnt_get_following(fetch_args->req_args->api, &m_args,
request_cb_account_follow_page, fetch_args,
acct->id, args);
}
static char* account_statuses_cb(HV* session_hv,
struct session* ssn,
mastodont_t* api,
struct mstdnt_account* acct,
struct mstdnt_relationship* rel,
void* _args)
// Callback: account_statuses_cb
static int
request_cb_account_statuses(mstdnt_request_cb_data* cb_data,
void* tbargs)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_account_statuses_args* args = _args;
struct mstdnt_storage storage = { 0 };
struct mstdnt_status* statuses = NULL;
size_t statuses_len = 0;
char* result;
struct mstdnt_statuses* statuses = MSTDNT_CB_DATA(cb_data);
DESTRUCT_TB_ARGS(tbargs);
mstdnt_get_account_statuses(api, &m_args, acct->id, args, &storage, &statuses, &statuses_len);
char* result;
acct_fetch_args* data = args;
struct mstdnt_account* acct = data->pair.acct_data->data;
struct mstdnt_relationships* rel = data->pair.rels_data->data;
PERL_STACK_INIT;
XPUSHs(newRV_noinc((SV*)session_hv));
XPUSHs(newRV_noinc((SV*)data->session_hv));
XPUSHs(newRV_noinc((SV*)template_files));
mXPUSHs(newRV_noinc((SV*)perlify_account(acct)));
// Assumes one relationship (there should be one)
if (rel)
mXPUSHs(newRV_noinc((SV*)perlify_relationship(rel)));
mXPUSHs(newRV_noinc((SV*)perlify_relationship(rel->relationships)));
else ARG_UNDEFINED();
if (statuses && statuses_len)
mXPUSHs(newRV_noinc((SV*)perlify_statuses(statuses, statuses_len)));
if (statuses)
mXPUSHs(newRV_noinc((SV*)perlify_statuses(statuses->statuses,
statuses->len)));
else ARG_UNDEFINED();
PERL_STACK_SCALAR_CALL("account::content_statuses");
result = PERL_GET_STACK_EXIT;
mstdnt_storage_cleanup(&storage);
mstdnt_cleanup_statuses(statuses, statuses_len);
return result;
account_page(data, result);
return MSTDNT_REQUEST_DONE;
}
static char* account_scrobbles_cb(HV* session_hv,
struct session* ssn,
mastodont_t* api,
struct mstdnt_account* acct,
struct mstdnt_relationship* rel,
void* _args)
static void
account_statuses_cb(acct_fetch_args* fetch_args)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 };
struct mstdnt_scrobble* scrobbles = NULL;
size_t scrobbles_len = 0;
set_mstdnt_args(&m_args, fetch_args->req_args->ssn);
struct mstdnt_account* acct = fetch_args->pair.acct_data->data;
mstdnt_get_account_statuses(fetch_args->req_args->api,
&m_args,
request_cb_account_statuses,
NULL,
acct->id,
// Malloc'd earlier
*((struct mstdnt_account_statuses_args*)
fetch_args->args));
tb_free(fetch_args->args);
}
// Callback: account_scrobbles_cb
static int
request_cb_account_scrobbles(mstdnt_request_cb_data* cb_data,
void* args)
{
struct mstdnt_scrobbles* scrobbles = MSTDNT_CB_DATA(cb_data);
acct_fetch_args* data = args;
PERL_STACK_INIT;
XPUSHs(newRV_noinc((SV*)data->session_hv));
XPUSHs(newRV_noinc((SV*)template_files));
mXPUSHs(newRV_noinc((SV*)perlify_account(data->pair.acct_data->data)));
if (data->pair.rels_data)
mXPUSHs(newRV_noinc(
(SV*)perlify_relationship(data->pair.rels_data->data)));
else ARG_UNDEFINED();
if (scrobbles->scrobbles)
mXPUSHs(newRV_noinc((SV*)perlify_scrobbles(scrobbles->scrobbles,
scrobbles->len)));
else ARG_UNDEFINED();
PERL_STACK_SCALAR_CALL("account::content_scrobbles");
char* result = PERL_GET_STACK_EXIT;
// Will free
account_page(data, result);
return MSTDNT_REQUEST_DONE;
}
static void
account_scrobbles_cb(acct_fetch_args* fetch_args)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, fetch_args->req_args->ssn);
char* result;
struct mstdnt_account* acct = fetch_args->pair.acct_data->data;
struct mstdnt_get_scrobbles_args args = {
.max_id = NULL,
@ -198,36 +293,74 @@ static char* account_scrobbles_cb(HV* session_hv,
.offset = 0,
.limit = 20
};
mstdnt_get_scrobbles(api, &m_args, acct->id, &args, &storage, &scrobbles, &scrobbles_len);
PERL_STACK_INIT;
XPUSHs(newRV_noinc((SV*)session_hv));
XPUSHs(newRV_noinc((SV*)template_files));
mXPUSHs(newRV_noinc((SV*)perlify_account(acct)));
if (rel)
mXPUSHs(newRV_noinc((SV*)perlify_relationship(rel)));
else ARG_UNDEFINED();
if (scrobbles && scrobbles_len)
mXPUSHs(newRV_noinc((SV*)perlify_scrobbles(scrobbles, scrobbles_len)));
else ARG_UNDEFINED();
PERL_STACK_SCALAR_CALL("account::content_scrobbles");
result = PERL_GET_STACK_EXIT;
mstdnt_storage_cleanup(&storage);
return result;
mstdnt_get_scrobbles(fetch_args->req_args->api, &m_args,
request_cb_account_scrobbles, fetch_args,
acct->id, args);
}
void get_account_info(mastodont_t* api, struct session* ssn)
{
#if 0
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
if (ssn->cookies.access_token.is_set && mstdnt_verify_credentials(api, &m_args, &(ssn->acct), &(ssn->acct_storage)) == 0)
if (ssn->cookies.access_token.is_set && mstdnt_verify_credentials(api, &m_args, NULL, NULL, &(ssn->acct), &(ssn->acct_storage)) == 0)
{
ssn->logged_in = 1;
}
#endif
}
static void
pass_account_info(acct_fetch_args* args)
{
HV* session_hv = perlify_session(args->req_args->ssn);
args->session_hv = session_hv;
// Now get the data we requested originally
args->callback(args);
}
// Callback: fetch_account_page
#if 0
static int
request_cb_account_page_relationships(mstdnt_request_cb_data* cb_data,
void* tbargs)
{
DESTRUCT_TB_ARGS(tbargs);
acct_fetch_args* data = args;
data->pair.rels_data = cb_data;
// TODO if this fails (it definitely can), then set to 0x1
if (data->pair.rels_data->data && data->pair.acct_data->data)
{
pass_account_info(data);
}
return MSTDNT_REQUEST_DATA_NOCLEANUP;
}
#endif
// Callback: fetch_account_page
static int
request_cb_account_page_acct(mstdnt_request_cb_data* cb_data,
void* tbargs)
{
DESTRUCT_TB_ARGS(tbargs);
acct_fetch_args* data = args;
data->pair.acct_data = cb_data;
#if 0
// Relationships may fail
mstdnt_get_relationships(api,
&m_args,
request_cb_account_page_relationships,
f_arg,
&(acct.id),
1);
#endif
pass_account_info(data);
return MSTDNT_REQUEST_DATA_NOCLEANUP;
}
/**
@ -242,157 +375,158 @@ void get_account_info(mastodont_t* api, struct session* ssn)
* @param tab Current tab to focus
* @param callback Calls back with a perlified session, session and api as you passed in, the account,
* the relationship, and additional arguments passed
* @return 1, don't end request
*/
static void fetch_account_page(FCGX_Request* req,
struct session* ssn,
mastodont_t* api,
char* id,
void* args,
enum account_tab tab,
char* (*callback)(HV* ssn_hv, struct session* ssn, mastodont_t* api, struct mstdnt_account* acct, struct mstdnt_relationship* rel, void* args))
static int
fetch_account_page(FCGX_Request* req,
struct session* ssn,
mastodont_t* api,
char* id,
void* args,
enum account_tab tab,
account_page_cb callback)
{
struct mstdnt_storage storage = { 0 },
relations_storage = { 0 };
struct mstdnt_account acct = { 0 };
struct mstdnt_relationship* relationships = NULL;
size_t relationships_len = 0;
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
int lookup_type = config_experimental_lookup ? MSTDNT_LOOKUP_ACCT : MSTDNT_LOOKUP_ID;
// Make empty
acct_fetch_args* f_arg = tb_calloc(1, sizeof(acct_fetch_args));
f_arg->id = id;
f_arg->args = args;
f_arg->tab = tab;
f_arg->callback = callback;
mstdnt_get_account(api, &m_args, lookup_type, id, &acct, &storage);
// Relationships may fail
mstdnt_get_relationships(api, &m_args, &(acct.id), 1, &relations_storage, &relationships, &relationships_len);
HV* session_hv = perlify_session(ssn);
char* data = callback(session_hv, ssn, api, &acct, relationships, args);
struct base_page b = {
.category = BASE_CAT_NONE,
.content = data,
.session = session_hv,
.sidebar_left = NULL
};
render_base_page(&b, req, ssn, api);
struct request_args* req_args =
request_args_create(req, ssn, api, f_arg);
f_arg->req_args = req_args;
/* Output */
mstdnt_cleanup_account(&acct);
mstdnt_cleanup_relationships(relationships);
mstdnt_storage_cleanup(&storage);
mstdnt_storage_cleanup(&relations_storage);
tb_free(data);
}
void content_account_statuses(PATH_ARGS)
{
struct mstdnt_account_statuses_args args = {
.pinned = 0,
.only_media = 0,
.with_muted = 0,
.exclude_reblogs = 0,
.exclude_replies = 0,
.tagged = NULL,
.max_id = keystr(ssn->post.max_id),
.min_id = keystr(ssn->post.min_id),
.since_id = NULL,
.offset = keyint(ssn->query.offset),
.limit = 20,
};
mstdnt_get_account(api,
&m_args,
request_cb_account_page_acct,
f_arg,
lookup_type,
id);
fetch_account_page(req, ssn, api, data[0], &args, ACCT_TAB_STATUSES, account_statuses_cb);
return 1;
}
void content_account_followers(PATH_ARGS)
int content_account_statuses(PATH_ARGS)
{
fetch_account_page(req, ssn, api, data[0], NULL, ACCT_TAB_NONE, account_followers_cb);
}
void content_account_following(PATH_ARGS)
{
fetch_account_page(req, ssn, api, data[0], NULL, ACCT_TAB_NONE, account_following_cb);
}
void content_account_scrobbles(PATH_ARGS)
{
fetch_account_page(req, ssn, api, data[0], NULL, ACCT_TAB_SCROBBLES, account_scrobbles_cb);
}
void content_account_pinned(PATH_ARGS)
{
struct mstdnt_account_statuses_args args = {
.pinned = 1,
.only_media = 0,
.with_muted = 0,
.exclude_reblogs = 0,
.exclude_replies = 0,
.tagged = NULL,
.max_id = keystr(ssn->post.max_id),
.min_id = keystr(ssn->post.min_id),
.since_id = NULL,
.offset = 0,
.limit = 20,
};
struct mstdnt_account_statuses_args* args =
tb_calloc(1, sizeof(struct mstdnt_account_statuses_args));
args->max_id = keystr(ssn->post.max_id);
args->min_id = keystr(ssn->post.min_id);
args->offset = keyint(ssn->query.offset);
fetch_account_page(req, ssn, api, data[0], &args, ACCT_TAB_PINNED, account_statuses_cb);
return fetch_account_page(req, ssn, api, data[0], args, ACCT_TAB_STATUSES, account_statuses_cb);
}
void content_account_media(PATH_ARGS)
int content_account_followers(PATH_ARGS)
{
struct mstdnt_account_statuses_args args = {
.pinned = 0,
.only_media = 1,
.with_muted = 0,
.exclude_reblogs = 0,
.exclude_replies = 0,
.tagged = NULL,
.max_id = keystr(ssn->post.max_id),
.min_id = keystr(ssn->post.min_id),
.since_id = NULL,
.offset = 0,
.limit = 20,
};
fetch_account_page(req, ssn, api, data[0], &args, ACCT_TAB_MEDIA, account_statuses_cb);
return fetch_account_page(req, ssn, api, data[0], NULL, ACCT_TAB_NONE, account_followers_cb);
}
void content_account_action(PATH_ARGS)
int content_account_following(PATH_ARGS)
{
return fetch_account_page(req, ssn, api, data[0], NULL, ACCT_TAB_NONE, account_following_cb);
}
int content_account_scrobbles(PATH_ARGS)
{
return fetch_account_page(req, ssn, api, data[0], NULL, ACCT_TAB_SCROBBLES, account_scrobbles_cb);
}
int content_account_pinned(PATH_ARGS)
{
struct mstdnt_account_statuses_args* args =
tb_calloc(1, sizeof(struct mstdnt_account_statuses_args));
args->pinned = MSTDNT_TRUE;
args->max_id = keystr(ssn->post.max_id);
args->min_id = keystr(ssn->post.min_id);
args->limit = 20;
return fetch_account_page(req, ssn, api, data[0], args, ACCT_TAB_PINNED, account_statuses_cb);
}
int content_account_media(PATH_ARGS)
{
struct mstdnt_account_statuses_args* args =
tb_calloc(1, sizeof(struct mstdnt_account_statuses_args));
args->only_media = 1;
args->max_id = keystr(ssn->post.max_id);
args->min_id = keystr(ssn->post.min_id);
args->limit = 20;
return fetch_account_page(req, ssn, api, data[0], args, ACCT_TAB_MEDIA, account_statuses_cb);
}
static int
request_cb_content_account_action(mstdnt_request_cb_data* cb_data, void* tbargs)
{
mstdnt_relationship* rel = MSTDNT_CB_DATA(cb_data);
DESTRUCT_TB_ARGS(tbargs);
char* referer = GET_ENV("HTTP_REFERER", req);
struct mstdnt_storage storage = { 0 };
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_relationship acct = { 0 };
if (strcmp(data[1], "follow") == 0)
mstdnt_follow_account(api, &m_args, data[0], &storage, &acct);
else if (strcmp(data[1], "unfollow") == 0)
mstdnt_unfollow_account(api, &m_args, data[0], &storage, &acct);
else if (strcmp(data[1], "mute") == 0)
mstdnt_mute_account(api, &m_args, data[0], &storage, &acct);
else if (strcmp(data[1], "unmute") == 0)
mstdnt_unmute_account(api, &m_args, data[0], &storage, &acct);
else if (strcmp(data[1], "block") == 0)
mstdnt_block_account(api, &m_args, data[0], &storage, &acct);
else if (strcmp(data[1], "unblock") == 0)
mstdnt_unblock_account(api, &m_args, data[0], &storage, &acct);
else if (strcmp(data[1], "subscribe") == 0)
mstdnt_subscribe_account(api, &m_args, data[0], &storage, &acct);
else if (strcmp(data[1], "unsubscribe") == 0)
mstdnt_unsubscribe_account(api, &m_args, data[0], &storage, &acct);
mstdnt_storage_cleanup(&storage);
redirect(req, REDIRECT_303, referer);
return MSTDNT_REQUEST_DONE;
}
void content_account_bookmarks(PATH_ARGS)
int
content_account_action(PATH_ARGS)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct request_args* cb_args =
request_args_create(req, ssn, api, NULL);
if (strcmp(data[1], "follow") == 0)
return mstdnt_follow_account(api, &m_args,
request_cb_content_account_action, cb_args, data[0]);
else if (strcmp(data[1], "unfollow") == 0)
return mstdnt_unfollow_account(api, &m_args,
request_cb_content_account_action, cb_args, data[0]);
else if (strcmp(data[1], "mute") == 0)
return mstdnt_mute_account(api, &m_args,
request_cb_content_account_action, cb_args, data[0]);
else if (strcmp(data[1], "unmute") == 0)
return mstdnt_unmute_account(api, &m_args,
request_cb_content_account_action, cb_args, data[0]);
else if (strcmp(data[1], "block") == 0)
return mstdnt_block_account(api, &m_args,
request_cb_content_account_action, cb_args, data[0]);
else if (strcmp(data[1], "unblock") == 0)
return mstdnt_unblock_account(api, &m_args,
request_cb_content_account_action, cb_args, data[0]);
else if (strcmp(data[1], "subscribe") == 0)
return mstdnt_subscribe_account(api, &m_args,
request_cb_content_account_action, cb_args, data[0]);
else if (strcmp(data[1], "unsubscribe") == 0)
return mstdnt_unsubscribe_account(api, &m_args,
request_cb_content_account_action, cb_args, data[0]);
}
static int
request_cb_content_bookmarks(mstdnt_request_cb_data* cb_data, void* tbargs)
{
struct mstdnt_statuses* statuses = MSTDNT_CB_DATA(cb_data);
DESTRUCT_TB_ARGS(tbargs);
content_timeline(req, ssn, api,
statuses->statuses, statuses->len,
BASE_CAT_BOOKMARKS, "Bookmarks", 0, 1);
finish_free_request(req);
return MSTDNT_REQUEST_DONE;
}
int content_account_bookmarks(PATH_ARGS)
{
size_t statuses_len = 0;
struct mstdnt_status* statuses = NULL;
struct mstdnt_storage storage = { 0 };
struct mstdnt_bookmarks_args args = {
.max_id = keystr(ssn->post.max_id),
.since_id = NULL,
@ -402,13 +536,20 @@ void content_account_bookmarks(PATH_ARGS)
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
mstdnt_get_bookmarks(api, &m_args, &args, &storage, &statuses, &statuses_len);
struct request_args* cb_args =
request_args_create(req, ssn, api, NULL);
return mstdnt_get_bookmarks(api,
&m_args,
request_cb_content_bookmarks,
cb_args,
args);
content_timeline(req, ssn, api, &storage, statuses, statuses_len, BASE_CAT_BOOKMARKS, "Bookmarks", 0, 1);
}
void content_account_blocked(PATH_ARGS)
int content_account_blocked(PATH_ARGS)
{
#if 0
struct mstdnt_account_args args = {
.max_id = keystr(ssn->post.max_id),
.since_id = NULL,
@ -423,7 +564,7 @@ void content_account_blocked(PATH_ARGS)
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
mstdnt_get_blocks(api, &m_args, &args, &storage, &accts, &accts_len);
mstdnt_get_blocks(api, &m_args, NULL, NULL, &args, &storage, &accts, &accts_len);
HV* session_hv = perlify_session(ssn);
char* result = accounts_page(session_hv, api, NULL, NULL, "Blocked users", &storage, accts, accts_len);
@ -437,10 +578,33 @@ void content_account_blocked(PATH_ARGS)
render_base_page(&b, req, ssn, api);
tb_free(result);
#endif
}
void content_account_muted(PATH_ARGS)
// Callback: content_account_favourites
static int
request_cb_content_mutes(mstdnt_request_cb_data* cb_data, void* tbargs)
{
#if 0
struct mstdnt_statuses* statuses = MSTDNT_CB_DATA(cb_data);
DESTRUCT_TB_ARGS(tbargs);
HV* session_hv = perlify_session(ssn);
accounts_page(session_hv,
ssn,
api,
&storage,
statuses->statuses, statuses->len,
BASE_CAT_BOOKMARKS, "Favorites", 0, 1);
finish_free_request(req);
return MSTDNT_REQUEST_DONE;
#endif
}
int content_account_muted(PATH_ARGS)
{
#if 0
struct mstdnt_account_args args = {
.max_id = keystr(ssn->post.max_id),
.since_id = NULL,
@ -449,49 +613,58 @@ void content_account_muted(PATH_ARGS)
.limit = 20,
.with_relationships = 0,
};
struct mstdnt_storage storage = { 0 };
struct mstdnt_account* accts = NULL;
size_t accts_len = 0;
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
mstdnt_get_mutes(api, &m_args, &args, &storage, &accts, &accts_len);
HV* session_hv = perlify_session(ssn);
char* result = accounts_page(session_hv, api, NULL, NULL, "Muted users", &storage, accts, accts_len);
struct base_page b = {
.category = BASE_CAT_NONE,
.content = result,
.session = session_hv,
.sidebar_left = NULL
};
render_base_page(&b, req, ssn, api);
tb_free(result);
struct request_args* cb_args =
request_args_create(req, ssn, api, NULL);
mstdnt_get_mutes(api, &m_args,
request_cb_content_account_muted,
cb_args, args);
#endif
}
void content_account_favourites(PATH_ARGS)
// Callback: content_account_favourites
static int
request_cb_content_favorites(mstdnt_request_cb_data* cb_data, void* tbargs)
{
struct mstdnt_statuses* statuses = MSTDNT_CB_DATA(cb_data);
DESTRUCT_TB_ARGS(tbargs);
content_timeline(req, ssn, api,
statuses->statuses, statuses->len,
BASE_CAT_BOOKMARKS, "Favorites", 0, 1);
finish_free_request(req);
return MSTDNT_REQUEST_DONE;
}
int
content_account_favourites(PATH_ARGS)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
size_t statuses_len = 0;
struct mstdnt_status* statuses = NULL;
struct mstdnt_storage storage = { 0 };
struct mstdnt_favourites_args args = {
.min_id = keystr(ssn->post.min_id),
.limit = 20,
};
mstdnt_get_favourites(api, &m_args, &args, &storage, &statuses, &statuses_len);
content_timeline(req, ssn, api, &storage, statuses, statuses_len, BASE_CAT_BOOKMARKS, "Favorites", 0, 1);
struct request_args* cb_args =
request_args_create(req, ssn, api, NULL);
return mstdnt_get_favourites(api,
&m_args,
request_cb_content_favorites,
cb_args,
args);
}
PERLIFY_MULTI(account, accounts, mstdnt_account)
HV* perlify_account(const struct mstdnt_account* acct)
HV*
perlify_account(const struct mstdnt_account* acct)
{
if (!acct) return NULL;
HV* acct_hv = newHV();
@ -520,7 +693,8 @@ HV* perlify_account(const struct mstdnt_account* acct)
return acct_hv;
}
HV* perlify_relationship(const struct mstdnt_relationship* rel)
HV*
perlify_relationship(const struct mstdnt_relationship* rel)
{
if (!rel) return NULL;
HV* rel_hv = newHV();

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef ACCOUNT_H
@ -58,17 +46,17 @@ struct account_page
void get_account_info(mastodont_t* api, struct session* ssn);
void content_account_followers(PATH_ARGS);
void content_account_following(PATH_ARGS);
void content_account_statuses(PATH_ARGS);
void content_account_scrobbles(PATH_ARGS);
void content_account_pinned(PATH_ARGS);
void content_account_blocked(PATH_ARGS);
void content_account_muted(PATH_ARGS);
void content_account_media(PATH_ARGS);
void content_account_action(PATH_ARGS);
void content_account_favourites(PATH_ARGS);
void content_account_bookmarks(PATH_ARGS);
int content_account_followers(PATH_ARGS);
int content_account_following(PATH_ARGS);
int content_account_statuses(PATH_ARGS);
int content_account_scrobbles(PATH_ARGS);
int content_account_pinned(PATH_ARGS);
int content_account_blocked(PATH_ARGS);
int content_account_muted(PATH_ARGS);
int content_account_media(PATH_ARGS);
int content_account_action(PATH_ARGS);
int content_account_favourites(PATH_ARGS);
int content_account_bookmarks(PATH_ARGS);
HV* perlify_account(const struct mstdnt_account* acct);
AV* perlify_accounts(const struct mstdnt_account* accounts, size_t len);

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "applications.h"

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef APPLICATIONS_H

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <string.h>
@ -24,7 +12,6 @@
#include "attachments.h"
#include "string_helpers.h"
struct attachments_args
{
struct session* ssn;
@ -38,6 +25,7 @@ int try_upload_media(struct mstdnt_storage** storage,
struct mstdnt_attachment** attachments,
char*** media_ids)
{
#if 0
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
size_t size = keyfile(ssn->post.files).array_size;
@ -65,10 +53,9 @@ int try_upload_media(struct mstdnt_storage** storage,
};
if (mstdnt_upload_media(api,
&m_args,
&args,
*storage + i,
*attachments + i))
&m_args,
request_cb_try_upload_media, upload_media_cb_args,
args))
{
for (size_t j = 0; j < i; ++j)
{
@ -97,23 +84,28 @@ int try_upload_media(struct mstdnt_storage** storage,
}
return 0;
#endif
}
void cleanup_media_storages(struct session* ssn, struct mstdnt_storage* storage)
{
#if 0
if (!FILES_READY(ssn)) return;
for (size_t i = 0; i < keyfile(ssn->post.files).array_size; ++i)
mstdnt_storage_cleanup(storage + i);
tb_free(storage);
#endif
}
void cleanup_media_ids(struct session* ssn, char** media_ids)
{
#if 0
if (!FILES_READY(ssn)) return;
if (!media_ids) return;
for (size_t i = 0; i < keyfile(ssn->post.files).array_size; ++i)
tb_free(media_ids[i]);
tb_free(media_ids);
#endif
}
HV* perlify_attachment(const struct mstdnt_attachment* const attachment)
@ -133,7 +125,7 @@ HV* perlify_attachment(const struct mstdnt_attachment* const attachment)
PERLIFY_MULTI(attachment, attachments, mstdnt_attachment)
void api_attachment_create(PATH_ARGS)
int api_attachment_create(PATH_ARGS)
{
struct mstdnt_storage *att_storage = NULL;
struct mstdnt_attachment* attachments = NULL;

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef ATTACHMENTS_H
@ -34,7 +22,7 @@ int try_upload_media(struct mstdnt_storage** storage,
char*** media_ids);
void cleanup_media_storages(struct session* ssn, struct mstdnt_storage* storage);
void cleanup_media_ids(struct session* ssn, char** media_ids);
void api_attachment_create(PATH_ARGS);
int api_attachment_create(PATH_ARGS);
// Perl
HV* perlify_attachment(const struct mstdnt_attachment* const attachment);

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
@ -31,55 +19,26 @@
#include "cgi.h"
#include "global_cache.h"
#define BODY_STYLE "style=\"background:url('%s');\""
void render_base_page(struct base_page* page, FCGX_Request* req, struct session* ssn, mastodont_t* api)
static void
_render_base_page(struct base_page* page,
FCGX_Request* req,
struct session* ssn,
struct mstdnt_notifications* notifs)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 };
struct mstdnt_notification* notifs = NULL;
size_t notifs_len = 0;
// Fetch notification (if not iFrame)
if (keystr(ssn->cookies.logged_in) && keystr(ssn->cookies.access_token) &&
!ssn->config.notif_embed)
{
struct mstdnt_notifications_args args = {
.exclude_types = 0,
.account_id = NULL,
.exclude_visibilities = 0,
.include_types = 0,
.with_muted = 1,
.max_id = NULL,
.min_id = NULL,
.since_id = NULL,
.offset = 0,
.limit = 8,
};
mstdnt_get_notifications(
api,
&m_args,
&args,
&storage,
&notifs,
&notifs_len
);
}
PERL_STACK_INIT;
HV* real_ssn = page->session ? page->session : perlify_session(ssn);
HV* real_ssn = page->session ? page->session :
perlify_session(ssn);
mXPUSHs(newRV_noinc((SV*)real_ssn));
mXPUSHs(newRV_inc((SV*)template_files));
mXPUSHs(newSVpv(page->content, 0));
if (notifs && notifs_len)
if (notifs)
{
mXPUSHs(newRV_noinc(perlify_notifications(notifs, notifs_len)));
mXPUSHs(newRV_noinc(
(SV*)perlify_notifications(notifs->notifs, notifs->len)));
}
else ARG_UNDEFINED();
@ -90,18 +49,77 @@ void render_base_page(struct base_page* page, FCGX_Request* req, struct session*
send_result(req, NULL, "text/html", dup, 0);
mstdnt_cleanup_notifications(notifs, notifs_len);
mstdnt_storage_cleanup(&storage);
tb_free(dup);
}
// Callback: render_base_page
static int
request_cb_base_page(mstdnt_request_cb_data* cb_data,
void* args)
{
#if 0
struct mstdnt_notifications* notifs = MSTDNT_CB_DATA(cb_data);
struct path_args_data* path_data = args;
// ->data is the page data
_render_base_page(path_data->data,
path_data->req,
path_data->ssn,
notifs);
path_args_data_destroy(path_data);
#endif
return MSTDNT_REQUEST_DONE;
}
void
render_base_page(struct base_page* page,
FCGX_Request* req,
struct session* ssn,
mastodont_t* api)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
// Fetch notification (if not iFrame)
if (keystr(ssn->cookies.logged_in) &&
keystr(ssn->cookies.access_token) &&
!ssn->config.notif_embed)
{
struct path_args_data* path_data =
path_args_data_create(req, ssn, api, page);
mstdnt_get_notifications(
api,
&m_args,
request_cb_base_page, path_data,
(struct mstdnt_notifications_args)
{
.exclude_types = 0,
.account_id = NULL,
.exclude_visibilities = 0,
.include_types = 0,
.with_muted = 1,
.max_id = NULL,
.min_id = NULL,
.since_id = NULL,
.offset = 0,
.limit = 8,
});
}
else {
// Render it as is, if IFrame is disabled
// TODO might get account data at this point
_render_base_page(page, req, ssn, NULL);
}
}
void send_result(FCGX_Request* req, char* status, char* content_type, char* data, size_t data_len)
{
if (data_len == 0) data_len = strlen(data);
#ifdef SINGLE_THREADED
#ifdef CGI_MODE
printf(
#else
pthread_mutex_lock(&print_mutex);
FCGX_FPrintF(req->out,
#endif
"Status: %s\r\n"
@ -110,10 +128,9 @@ void send_result(FCGX_Request* req, char* status, char* content_type, char* data
status ? status : "200 OK",
content_type ? content_type : "text/html",
data_len);
#ifdef SINGLE_THREADED
#ifdef CGI_MODE
puts(data);
#else
FCGX_PutStr(data, data_len, req->out);
pthread_mutex_unlock(&print_mutex);
#endif
}

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef BASE_PAGE_H

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
/* #ifndef IMPORT_CGI_H */

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <stdlib.h>
@ -26,31 +14,23 @@
#include "error.h"
#include "base_page.h"
void content_chats(PATH_ARGS)
// Callback: request_cb_content_chats
static int
request_cb_content_chats(mstdnt_request_cb_data* cb_data,
void* args)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_chat* chats = NULL;
size_t chats_len = 0;
struct mstdnt_storage storage = { 0 };
struct mstdnt_chats_args args = {
.with_muted = MSTDNT_TRUE,
.max_id = keystr(ssn->post.max_id),
.since_id = NULL,
.min_id = keystr(ssn->post.min_id),
.offset = keyint(ssn->query.offset),
.limit = 20,
};
mstdnt_get_chats_v2(api, &m_args, &args, &storage, &chats, &chats_len);
struct mstdnt_chats* chats = MSTDNT_CB_DATA(cb_data);
struct path_args_data* path_data = args;
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
HV* session_hv = perlify_session(path_data->ssn);
XPUSHs(newRV_noinc((SV*)session_hv));
XPUSHs(newRV_noinc((SV*)template_files));
if (chats)
mXPUSHs(newRV_noinc((SV*)perlify_chats(chats, chats_len)));
mXPUSHs(newRV_noinc((SV*)perlify_chats(chats->chats, chats->len)));
else ARG_UNDEFINED();
PERL_STACK_SCALAR_CALL("chat::content_chats");
@ -66,18 +46,37 @@ void content_chats(PATH_ARGS)
};
// Outpuot
render_base_page(&b, req, ssn, api);
render_base_page(&b, path_data->req, path_data->ssn, path_data->api);
// Cleanup
mstdnt_storage_cleanup(&storage);
mstdnt_cleanup_chats(chats, chats_len);
tb_free(dup);
path_args_data_destroy(args);
return MSTDNT_REQUEST_DONE;
}
void content_chat_view(PATH_ARGS)
int content_chats(PATH_ARGS)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
mstdnt_get_chats_v2(api, &m_args,
request_cb_content_chats,
path_args_data_create(req, ssn, api, NULL),
(struct mstdnt_chats_args)
{
.with_muted = MSTDNT_TRUE,
.max_id = keystr(ssn->post.max_id),
.since_id = NULL,
.min_id = keystr(ssn->post.min_id),
.offset = keyint(ssn->query.offset),
.limit = 20,
});
}
int content_chat_view(PATH_ARGS)
{
#if 0
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_message* messages = NULL;
/* struct mstdnt_account acct; */
size_t messages_len = 0;
@ -93,8 +92,8 @@ void content_chat_view(PATH_ARGS)
.limit = 20,
};
mstdnt_get_chat_messages(api, &m_args, data[0], &args, &storage, &messages, &messages_len);
int chat_code = mstdnt_get_chat(api, &m_args, data[0],
mstdnt_get_chat_messages(api, &m_args, NULL, NULL, data[0], &args, &storage, &messages, &messages_len);
int chat_code = mstdnt_get_chat(api, &m_args, NULL, NULL, data[0],
&storage_chat, &chat);
PERL_STACK_INIT;
@ -128,6 +127,7 @@ void content_chat_view(PATH_ARGS)
mstdnt_cleanup_chat(&chat);
mstdnt_cleanup_messages(messages);
tb_free(dup);
#endif
}
HV* perlify_chat(const struct mstdnt_chat* chat)

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef CONVERSATIONS_H
@ -23,8 +11,8 @@
#include <mastodont.h>
#include "session.h"
void content_chats(PATH_ARGS);
void content_chat_view(PATH_ARGS);
int content_chats(PATH_ARGS);
int content_chat_view(PATH_ARGS);
AV* perlify_chats(const struct mstdnt_chat* chats, size_t chats_len);
HV* perlify_chat(const struct mstdnt_chat* chat);

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "cookie.h"

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef COOKIE_H

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <fcgi_stdio.h>

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef EASPRINTF_H

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "emoji.h"
@ -66,7 +54,7 @@ static char* construct_emoji_voidwrap(void* passed, size_t index, size_t* res)
#define EMOJI_PICKER_ARGS(this_index) { .status_id = status_id, .index = this_index }
void content_emoji_picker(PATH_ARGS)
int content_emoji_picker(PATH_ARGS)
{
char* picker = construct_emoji_picker(NULL, NULL);

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef EMOJI_H
@ -34,7 +22,7 @@ enum emoji_picker_cat
};
char* construct_emoji(struct emoji_info* emoji, char* status_id, size_t* size);
void content_emoji_picker(PATH_ARGS);
int content_emoji_picker(PATH_ARGS);
char* construct_emoji_picker(char* status_id, size_t* size);
// Perl

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef EMOJI_INFO_H

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "../config.h"

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef EMOJI_REACTION_H

View File

@ -1,25 +1,13 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef ENV_H
#define ENV_H
#ifdef SINGLE_THREADED
#ifdef CGI_MODE
#define GET_ENV(var, reqp) getenv(var)
#else
#define GET_ENV(var, reqp) FCGX_GetParam(var, req->envp)

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <stdlib.h>
#include "base_page.h"

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef ERROR_H

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <stdio.h>

View File

@ -1,21 +1,10 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#if 0
#include "../config.h"
#include "global_cache.h"
@ -28,8 +17,8 @@ void load_instance_info_cache(mastodont_t* api)
.token = 0,
.flags = config_library_flags,
};
mstdnt_instance_panel(api, &m_args, &(g_cache.panel_html));
mstdnt_terms_of_service(api, &m_args, &(g_cache.tos_html));
mstdnt_instance_panel(api, &m_args, NULL, NULL, &(g_cache.panel_html));
mstdnt_terms_of_service(api, &m_args, NULL, NULL, &(g_cache.tos_html));
}
void free_instance_info_cache()
@ -37,3 +26,5 @@ void free_instance_info_cache()
mstdnt_fetch_results_cleanup(&(g_cache.panel_html));
mstdnt_fetch_results_cleanup(&(g_cache.tos_html));
}
#endif

View File

@ -1,25 +1,14 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef GLOBAL_CACHE_H
#define GLOBAL_CACHE_H
#include <mastodont.h>
#if 0
struct global_cache
{
struct mstdnt_fetch_results tos_html;
@ -30,5 +19,6 @@ extern struct global_cache g_cache;
void load_instance_info_cache(mastodont_t* api);
void free_instance_info_cache();
#endif
#endif /* GLOBAL_CACHE_H */

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "global_perl.h"

View File

@ -1,23 +1,13 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef GLOBAL_PERL_H
#define GLOBAL_PERL_H
/* Libperl has lots of warnings... */
#include <EXTERN.h>
#include <perl.h>
#include "memory.h"
@ -69,7 +59,7 @@ extern PerlInterpreter* my_perl;
extern HV* template_files;
extern pthread_mutex_t perllock_mutex;
#ifndef SINGLE_THREADED
#ifdef MULTI_THREADED
#define perl_lock() do { pthread_mutex_lock(&perllock_mutex); } while (0)
#define perl_unlock() do { pthread_mutex_unlock(&perllock_mutex); } while (0)
#else

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "math.h"

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef HASHTAG_H

View File

@ -1,21 +1,68 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <stdio.h>
#include <stdarg.h>
/* These following two functions use the classic printf to stdout. */
void
print_treebird_logo(void)
{
printf(" ...----'''''----...\n"
" ''''' '''''\n"
" ,,'''' '''',\n"
" ,,''' ''',,\n"
" ,,'' '',,\n"
" ,'' '',\n"
" ,,' .;clll:,. ',,\n"
" ,'' .:xkkkxoodo;. '',\n"
" '' 'dkkkxxooxkc. ',\n"
" '' .okkkkkkkkkxoolc:'. ''\n"
" '' .:oxkkkkkkkkkkkkxo:'. ''\n"
"'' .okkkkkkkkkkkkkkkxdc;.. ''\n"
";' .okkkkkkkkkkkkkkkkkkkd:. ';\n"
"; ;dkkkkkkkkkkkxdxkkkkxdc. ;\n"
"; .,:ldkkxdoodl;,:oxkkxl. ;\n"
"; .colc:'. .,cc. ,oc....;d:. ..,;'. ;\n"
"; .dxc;cdo,,oxdxc. .c:. .;c,. .... ;\n"
";' .lxc. ,dxxkddx:. ...',;;;;:odl;;:ldl;,,,;;;,,'... ';\n"
"-' .:doccdxodkkxolodxxkkkkkkkxxxdooolcc::;,'.. '-\n"
" '' .,ldkxddkkkkkkkkkxol:;,,..... ;'\n"
" '' .':oxkkkkkkkkxdl;'.. '''\n"
" '''cdxkkkkkkkkxl:'. '''\n"
" ''kkkkkkkxl;. :''\n"
" '''kkkd:. .''\n"
" ''':. .'''\n"
" ''' ''''\n"
" '''' ''''\n"
" '''''. .':''''\n"
" ''''',..________..,'''''\n"
" _____ _ '' _ _____ _____\n"
" |_ _| __ ___ ___| |__ (_)_ __ __| | | ___| ____|\n"
" | || '__/ _ \\/ _ \\ '_ \\| | '__/ _` | | |_ | _|\n"
" | || | | __/ __/ |_) | | | | (_| | | _| | |___\n"
" |_||_| \\___|\\___|_.__/|_|_| \\__,_| |_| |_____|\n\n"
" Thank you for trying this software!\n"
" To use it, it must be 'deployed' with an FCGI daemon.\n"
" Press ^C to quit.\n");
}
int
debug(char const* msg, ...)
{
int res;
va_list ap;
va_start(ap, msg);
printf("[DEBUG] ");
res = vprintf(msg, ap);
puts("");
va_end(ap);
return res;
}
#include "../config.h"
#include "helpers.h"

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef HELPERS_H
@ -22,5 +10,7 @@
#include "session.h"
void set_mstdnt_args(struct mstdnt_args* args, struct session* ssn);
void print_treebird_logo();
int debug(char const* msg, ...);
#endif /* HELPERS_H */

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "http.h"

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef HTTP_H

View File

@ -1,26 +1,14 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <stdlib.h>
#include "timeline.h"
void content_index(FCGX_Request* req, struct session* ssn, mastodont_t* api)
int content_index(FCGX_Request* req, struct session* ssn, mastodont_t* api)
{
// Check logins
content_tl_home(req, ssn, api, NULL);
return content_tl_home(req, ssn, api, NULL);
}

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef INDEX_H
@ -21,6 +9,6 @@
#include <mastodont.h>
#include "session.h"
void content_index(FCGX_Request* req, struct session* ssn, mastodont_t* api);
int content_index(FCGX_Request* req, struct session* ssn, mastodont_t* api);
#endif // INDEX_H

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "global_perl.h"

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef KEY_H

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef TREEBIRD_L10N_H

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <stdlib.h>
@ -30,33 +18,19 @@
#include "string_helpers.h"
#include "http.h"
void content_lists(PATH_ARGS)
static int
request_cb_get_lists(mstdnt_request_cb_data* cb_data,
void* args)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_list* lists = NULL;
size_t lists_len = 0;
struct mstdnt_storage storage = { 0 };
if (ssn->post.title.is_set)
{
struct mstdnt_storage create_storage = { 0 };
struct mstdnt_list_args args = {
.title = keystr(ssn->post.title),
.replies_policy = MSTDNT_LIST_REPLIES_POLICY_LIST,
};
mstdnt_create_list(api, &m_args, &args, &create_storage, NULL);
mstdnt_storage_cleanup(&create_storage);
}
mstdnt_get_lists(api, &m_args, &storage, &lists, &lists_len);
struct mstdnt_lists* lists = MSTDNT_CB_DATA(cb_data);
struct path_args_data* path_data = args;
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
HV* session_hv = perlify_session(path_data->ssn);
XPUSHs(newRV_noinc((SV*)session_hv));
XPUSHs(newRV_noinc((SV*)template_files));
if (lists)
mXPUSHs(newRV_noinc((SV*)perlify_lists(lists, lists_len)));
mXPUSHs(newRV_noinc((SV*)perlify_lists(lists->lists, lists->len)));
PERL_STACK_SCALAR_CALL("lists::content_lists");
@ -71,19 +45,45 @@ void content_lists(PATH_ARGS)
};
// Output
render_base_page(&b, req, ssn, api);
render_base_page(&b, path_data->req, path_data->ssn, path_data->api);
// Cleanup
mstdnt_storage_cleanup(&storage);
mstdnt_cleanup_lists(lists);
tb_free(dup);
path_args_data_destroy(args);
return MSTDNT_REQUEST_DONE;
}
void list_edit(PATH_ARGS)
int content_lists(PATH_ARGS)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct path_args_data* path_data = path_args_data_create(req,
ssn,
api,
NULL);
if (ssn->post.title.is_set)
{
struct mstdnt_storage create_storage = { 0 };
struct mstdnt_list_args args = {
.title = keystr(ssn->post.title),
.replies_policy = MSTDNT_LIST_REPLIES_POLICY_LIST,
};
// TODO
mstdnt_create_list(api, &m_args, NULL, NULL, args);
mstdnt_storage_cleanup(&create_storage);
}
mstdnt_get_lists(api, &m_args, request_cb_get_lists, path_data);
}
int list_edit(PATH_ARGS)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 };
char* referer = getenv("HTTP_REFERER");
char* id = data[0];
@ -93,14 +93,13 @@ void list_edit(PATH_ARGS)
};
mstdnt_update_list(api,
&m_args,
id,
&args,
&storage,
NULL);
&m_args,
NULL,
NULL,
id,
args);
redirect(req, REDIRECT_303, referer);
mstdnt_storage_cleanup(&storage);
}
HV* perlify_list(const struct mstdnt_list* list)

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef LISTS_H
@ -23,9 +11,9 @@
#include "session.h"
/** Creates the main lists view */
void content_lists(PATH_ARGS);
int content_lists(PATH_ARGS);
/** Creates a list and then redirects */
void list_edit(PATH_ARGS);
int list_edit(PATH_ARGS);
/** Converts list to perl hash */
HV* perlify_list(const struct mstdnt_list* list);

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "global_perl.h"

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef LOCAL_CONFIG_H

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <stdlib.h>
@ -75,20 +63,20 @@ void set_config_int(FCGX_Request* req,
// Shorthand for the arguments passed into functions below
#define LOAD_CFG_SIM(strcookie, varname) req, ssn, &(ssn->config.varname), (strcookie), &(ssn->post.varname), &(ssn->cookies.varname), page
struct mstdnt_storage* load_config(FCGX_Request* req,
struct session* ssn,
mastodont_t* api,
enum config_page page)
void load_config(FCGX_Request* req,
struct session* ssn,
mastodont_t* api,
enum config_page page)
{
struct mstdnt_attachment* attachments = NULL;
struct mstdnt_storage* storage = NULL;
size_t attachments_len = 0;
if (ssn->post.set.is_set)
{
try_upload_media(&storage, ssn, api, &attachments, NULL);
}
struct key atm = { .type.s = attachments ? attachments[0].url : NULL, .is_set = attachments ? 1 : 0 };
set_config_str(req, ssn, &(ssn->config.background_url), "background_url", &(atm), &(ssn->cookies.background_url), page, CONFIG_APPEARANCE);
/* struct mstdnt_attachment* attachments = NULL; */
/* struct mstdnt_storage* storage = NULL; */
/* size_t attachments_len = 0; */
/* if (ssn->post.set.is_set) */
/* { */
/* try_upload_media(&storage, ssn, api, &attachments, NULL); */
/* } */
/* struct key atm = { .type.s = attachments ? attachments[0].url : NULL, .is_set = attachments ? 1 : 0 }; */
/* set_config_str(req, ssn, &(ssn->config.background_url), "background_url", &(atm), &(ssn->cookies.background_url), page, CONFIG_APPEARANCE); */
set_config_int(LOAD_CFG_SIM("sidebaropacity", sidebar_opacity), CONFIG_APPEARANCE);
set_config_str(LOAD_CFG_SIM("theme", theme), CONFIG_APPEARANCE);
set_config_int(LOAD_CFG_SIM("jsactions", jsactions), CONFIG_GENERAL);
@ -106,6 +94,4 @@ struct mstdnt_storage* load_config(FCGX_Request* req,
set_config_int(LOAD_CFG_SIM("notifembed", notif_embed), CONFIG_GENERAL);
set_config_int(LOAD_CFG_SIM("interact_img", interact_img), CONFIG_GENERAL);
set_config_int(LOAD_CFG_SIM("lang", lang), CONFIG_GENERAL);
return storage;
}

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef LOCAL_CONFIG_SET_H
@ -79,9 +67,9 @@ void set_config_int(FCGX_Request* req,
* @param page Page enum, to ensure that config changes on different pages don't effect other cookies
* @return Storage if files were uploaded, must free. This might change
*/
struct mstdnt_storage* load_config(FCGX_Request* req,
struct session* ssn,
mastodont_t* api,
enum config_page page);
void load_config(FCGX_Request* req,
struct session* ssn,
mastodont_t* api,
enum config_page page);
#endif // LOCAL_CONFIG_SET_H

View File

@ -1,24 +1,13 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "login.h"
#include <string.h>
#include <stdlib.h>
#include "fcgiapp.h"
#include "helpers.h"
#include "query.h"
#include "base_page.h"
@ -32,7 +21,42 @@
#define LOGIN_SCOPE "read+write+follow+push"
static void apply_access_token(REQUEST_T req, char* token)
static void
render_login_page(REQUEST_T req,
struct session* ssn,
mastodont_t* api,
char const* error)
{
char* page;
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
XPUSHs(newRV_noinc((SV*)session_hv));
XPUSHs(newRV_noinc((SV*)template_files));
if (error)
mXPUSHs(newSVpv(error, 0));
PERL_STACK_SCALAR_CALL("login::content_login");
page = PERL_GET_STACK_EXIT;
struct base_page b = {
.category = BASE_CAT_NONE,
.content = page,
.session = session_hv,
.sidebar_left = NULL
};
// Output
render_base_page(&b, req, ssn, api);
// Cleanup
tb_free(page);
}
static void
apply_access_token(REQUEST_T req, char* token)
{
PRINTF("Set-Cookie: access_token=%s; Path=/; Max-Age=31536000\r\n", token);
PUT("Set-Cookie: logged_in=t; Path=/; Max-Age=31536000\r\n");
@ -41,13 +65,116 @@ static void apply_access_token(REQUEST_T req, char* token)
config_url_prefix[0] != '\0' ? config_url_prefix : "/");
}
void content_login_oauth(PATH_ARGS)
static int
request_cb_oauth_token(struct mstdnt_request_cb_data* cb_data,
void* args)
{
struct mstdnt_oauth_token* token = MSTDNT_CB_DATA(cb_data);
struct path_args_data* path_data = args;
if (cb_data->storage.error)
{
debug("Error: %s", cb_data->storage.error);
render_login_page(path_data->req, path_data->ssn, path_data->api, cb_data->storage.error);
path_args_data_destroy(path_data);
return MSTDNT_REQUEST_DONE;
}
char const* url_link = path_data->ssn->m_args.url;
// Needed for PRINTF statements, will probably get removed later
FCGX_Request* req = path_data->req;
if (url_link)
{
PRINTF("Set-Cookie: instance_url=%s; Path=/; Max-Age=31536000\r\n", url_link);
}
else {
// Clears the cookie
PUT("Set-Cookie: instance_url=; Path=/; Max-Age=-1\r\n");
}
apply_access_token(req, token->access_token);
path_args_data_destroy(path_data);
return MSTDNT_REQUEST_DONE;
}
// Callback: mstdnt_register_app
static int
request_cb_register_app(struct mstdnt_request_cb_data* cb_data,
void* args)
{
struct mstdnt_app* app = MSTDNT_CB_DATA(cb_data);
struct path_args_data* path_data = args;
mstdnt_obtain_oauth_token(path_data->api,
&path_data->ssn->m_args,
request_cb_oauth_token,
path_data,
(struct mstdnt_application_args)
{
.grant_type = "password",
.client_id = app->client_id,
.client_secret = app->client_secret,
.redirect_uri = NULL,
.scope = LOGIN_SCOPE,
.code = NULL,
.username = keystr(path_data->ssn->post.username),
.password = keystr(path_data->ssn->post.password)
});
debug("Login from username: %s", keystr(path_data->ssn->post.username));
//path_args_data_destroy(path_data);
return MSTDNT_REQUEST_DATA_NOCLEANUP;
}
// Registers an app, then proceeds to login
static int
register_app(PATH_ARGS)
{
// Getting the client id/secret
struct mstdnt_application_args args_app = {
.client_name = "Treebird",
.redirect_uris = "http://localhost/",
.scopes = LOGIN_SCOPE,
.website = NULL
};
// Check if the username contains an @ symbol
char* address = strstr(keystr(ssn->post.username), "%40");
// If this check fails, we just restore the URL.
const char* orig_url = ssn->m_args.url;
char* url_link = NULL;
// If it does, set the instance name
if (address)
{
// Let is viewable as username
*address = '\0';
address += sizeof("%40")-1;
easprintf(&url_link, "https://%s/", address);
ssn->m_args.url = url_link;
}
else {
// Reset to instance url
ssn->m_args.url = config_instance_url;
}
mstdnt_register_app(api,
&ssn->m_args,
request_cb_register_app,
path_args_data_create(req, ssn, api, NULL),
args_app);
}
int
content_login_oauth(PATH_ARGS)
{
#if 0
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 }, oauth_storage = { 0 };
struct mstdnt_app app;
struct mstdnt_oauth_token token;
const char* orig_url = m_args.url;
char* redirect_url = getenv("SERVER_NAME");
char* decode_url = NULL;
@ -58,41 +185,36 @@ void content_login_oauth(PATH_ARGS)
if (keystr(ssn->query.code))
{
struct mstdnt_application_args args_token = {
.grant_type = "authorization_code",
.client_id = keystr(ssn->cookies.client_id),
.client_secret = keystr(ssn->cookies.client_secret),
.redirect_uri = urlify_redirect_url,
.scope = LOGIN_SCOPE,
.code = keystr(ssn->query.code),
};
if (mstdnt_obtain_oauth_token(api,
&m_args,
&args_token,
&oauth_storage,
&token) == 0)
{
apply_access_token(req, token.access_token);
}
mstdnt_obtain_oauth_token(api,
&m_args,
request_cb_oauth_token,
path_args_data_create(req, ssn, api, NULL),
(struct mstdnt_application_args)
{
.grant_type = "authorization_code",
.client_id = keystr(ssn->cookies.client_id),
.client_secret = keystr(ssn->cookies.client_secret),
.redirect_uri = urlify_redirect_url,
.scope = LOGIN_SCOPE,
.code = keystr(ssn->query.code),
});
}
else if (keystr(ssn->post.instance))
{
decode_url = curl_easy_unescape(api->curl, keystr(ssn->post.instance), 0, NULL);
m_args.url = decode_url;
struct mstdnt_application_args args_app = {
.client_name = "Treebird",
.redirect_uris = urlify_redirect_url,
.scopes = "read+write+follow+push",
.website = keystr(ssn->post.instance)
};
if (mstdnt_register_app(api,
&m_args,
&args_app,
&storage,
&app) == 0)
mstdnt_register_app(api,
&m_args,
NULL,
NULL,
(struct mstdnt_application_rags)
{
.client_name = "Treebird",
.redirect_uris = urlify_redirect_url,
.scopes = "read+write+follow+push",
.website = keystr(ssn->post.instance)
});
{
char* url;
char* encode_id = curl_easy_escape(api->curl, app.client_id, 0);
@ -115,119 +237,26 @@ void content_login_oauth(PATH_ARGS)
redirect(req, REDIRECT_303, config_url_prefix &&
config_url_prefix[0] != '\0' ? config_url_prefix : "/");
mstdnt_storage_cleanup(&storage);
mstdnt_storage_cleanup(&oauth_storage);
if (urlify_redirect_url) tb_free(urlify_redirect_url);
if (decode_url) curl_free(decode_url);
#endif
}
void content_login(PATH_ARGS)
int
content_login(PATH_ARGS)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 }, oauth_store = { 0 };
struct mstdnt_app app;
struct mstdnt_oauth_token token;
char* error = NULL;
char* page;
set_mstdnt_args(&ssn->m_args, ssn);
if (keystr(ssn->post.username) && keystr(ssn->post.password))
// Check if the user logged in
if (keystr(ssn->post.username) &&
keystr(ssn->post.password))
{
// Getting the client id/secret
struct mstdnt_application_args args_app = {
.client_name = "Treebird",
.redirect_uris = "http://localhost/",
.scopes = LOGIN_SCOPE,
.website = NULL
};
// Check if the username contains an @ symbol
char* address = strstr(keystr(ssn->post.username), "%40");
// If it fails, we need to restore
const char* orig_url = m_args.url;
char* url_link = NULL;
if (address)
{
// Let is viewable as username
*address = '\0';
address += sizeof("%40")-1;
easprintf(&url_link, "https://%s/", address);
m_args.url = url_link;
}
else {
// Reset to instance url
m_args.url = config_instance_url;
}
if (mstdnt_register_app(api, &m_args, &args_app, &storage, &app) != 0)
{
// error = construct_error(oauth_store.error, E_ERROR, 1, NULL);
}
else {
struct mstdnt_application_args args_token = {
.grant_type = "password",
.client_id = app.client_id,
.client_secret = app.client_secret,
.redirect_uri = NULL,
.scope = LOGIN_SCOPE,
.code = NULL,
.username = keystr(ssn->post.username),
.password = keystr(ssn->post.password)
};
if (mstdnt_obtain_oauth_token(api,
&m_args,
&args_token,
&oauth_store,
&token) != 0 && oauth_store.error)
{
//error = construct_error(oauth_store.error, E_ERROR, 1, NULL);
}
else {
if (url_link)
{
PRINTF("Set-Cookie: instance_url=%s; Path=/; Max-Age=31536000\r\n", url_link);
} else
// Clear
PUT("Set-Cookie: instance_url=; Path=/; Max-Age=-1\r\n");
apply_access_token(req, token.access_token);
tb_free(url_link);
return;
}
}
if (url_link)
{
// Restore and cleanup, an error occured
m_args.url = orig_url;
tb_free(url_link);
}
register_app(PATH_ARGS_PASS);
return 1;
}
else {
render_login_page(req, ssn, api, NULL);
return 0;
}
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
XPUSHs(newRV_noinc((SV*)session_hv));
XPUSHs(newRV_noinc((SV*)template_files));
if (storage.error || oauth_store.error)
mXPUSHs(newSVpv(storage.error ? storage.error : oauth_store.error, 0));
PERL_STACK_SCALAR_CALL("login::content_login");
page = PERL_GET_STACK_EXIT;
struct base_page b = {
.category = BASE_CAT_NONE,
.content = page,
.session = session_hv,
.sidebar_left = NULL
};
// Output
render_base_page(&b, req, ssn, api);
// Cleanup
mstdnt_storage_cleanup(&storage);
mstdnt_storage_cleanup(&oauth_store);
tb_free(page);
}

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef LOGIN_H
@ -23,7 +11,7 @@
#include "session.h"
#include "path.h"
void content_login_oauth(PATH_ARGS);
void content_login(PATH_ARGS);
int content_login_oauth(PATH_ARGS);
int content_login(PATH_ARGS);
#endif // LOGIN_H

View File

@ -1,22 +1,13 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "global_perl.h"
#ifdef __OpenBSD__
# include <unistd.h>
#endif
#include <pthread.h>
#include <string.h>
#include "memory.h"
@ -47,15 +38,13 @@
#include "request.h"
#include "cgi.h"
#define THREAD_COUNT 20
// Allow dynamic loading for Perl
static void xs_init (pTHX);
void boot_DynaLoader (pTHX_ CV* cv);
#ifdef DEBUG
static int quit = 0;
static void exit_treebird(PATH_ARGS)
static int exit_treebird(PATH_ARGS)
{
quit = 1;
exit(1);
@ -68,10 +57,15 @@ static void exit_treebird(PATH_ARGS)
static struct path_info paths[] = {
{ "/config/general", content_config_general },
{ "/config/appearance", content_config_appearance },
/* { "/config/account", content_config_account }, */
//{ "/config/account", content_config_account },
{ "/config", content_config },
// API
{ "/treebird_api/v1/attachment", api_attachment_create },
{ "/login/oauth", content_login_oauth },
{ "/login", content_login },
{ "/user/:/action/:", content_account_action },
{ "/user/:", content_account_statuses },
{ "/@:/scrobbles", content_account_scrobbles },
@ -81,6 +75,10 @@ static struct path_info paths[] = {
{ "/@:/followers", content_account_followers },
{ "/@:/statuses", content_account_statuses },
{ "/@:", content_account_statuses },
{ "/favourites", content_account_favourites },
{ "/blocked", content_account_blocked },
{ "/muted", content_account_muted },
{ "/status/:/react/:", content_status_react },
{ "/status/:/react", status_emoji },
{ "/status/create", content_status_create },
@ -91,50 +89,54 @@ static struct path_info paths[] = {
{ "/status/:/reblogged_by", status_view_reblogs },
{ "/status/:", status_view },
{ "/notice/:", notice_redirect },
{ "/treebird_api/v1/interact", api_status_interact },
{ "/about/license", content_about_license },
{ "/about", content_about },
{ "/search/statuses", content_search_statuses },
{ "/search/accounts", content_search_accounts },
{ "/search/hashtags", content_search_hashtags },
{ "/search", content_search_all },
{ "/emoji_picker", content_emoji_picker },
{ "/lists/edit/:", list_edit },
{ "/lists/for/:", content_tl_list },
{ "/lists", content_lists },
{ "/local", content_tl_local },
{ "/federated", content_tl_federated },
{ "/direct", content_tl_direct },
{ "/bookmarks", content_account_bookmarks },
{ "/favourites", content_account_favourites },
{ "/blocked", content_account_blocked },
{ "/muted", content_account_muted },
{ "/lists/for/:", content_tl_list },
{ "/tag/:", content_tl_tag },
{ "/notifications_compact", content_notifications_compact },
{ "/notification/:/read", content_notifications_read },
{ "/notification/:/delete", content_notifications_clear },
{ "/notifications/read", content_notifications_read },
{ "/notifications/clear", content_notifications_clear },
{ "/notifications", content_notifications },
{ "/tag/:", content_tl_tag },
{ "/treebird_api/v1/notifications", api_notifications },
{ "/chats/:", content_chat_view },
{ "/chats", content_chats },
#ifdef DEBUG
{ "/quit", exit_treebird },
{ "/exit", exit_treebird },
#endif
// Debug, but cool to see
{ "/memory_stats", content_memory_stats },
// API
{ "/treebird_api/v1/notifications", api_notifications },
{ "/treebird_api/v1/interact", api_status_interact },
{ "/treebird_api/v1/attachment", api_attachment_create },
#endif
};
static void application(mastodont_t* api, REQUEST_T req)
static int application(mastodont_t* api, REQUEST_T req)
{
int rc;
propagate_memory();
// Default config
struct session ssn = {
static struct session ssn_def = {
.config = {
.theme = "treebird20",
.lang = L10N_EN_US,
@ -161,63 +163,93 @@ static void application(mastodont_t* api, REQUEST_T req)
.acct_storage = { 0 },
.logged_in = 0,
};
// Make our own from copy
struct session* ssn = malloc(sizeof(struct session));
memcpy(ssn, &ssn_def, sizeof(struct session));
// Load cookies
char* cookies_str = read_cookies_env(req, &(ssn.cookies));
char* post_str = read_post_data(req, &(ssn.post));
char* get_str = read_get_data(req, &(ssn.query));
ssn->cookies_str = read_cookies_env(req, &(ssn->cookies));
ssn->post_str = read_post_data(req, &(ssn->post));
ssn->get_str = read_get_data(req, &(ssn->query));
// Read config options
enum config_page page = CONFIG_GENERAL;
char* path_info = GET_ENV("PATH_INFO", req);
if (path_info && strcmp(path_info, "/config/appearance") == 0)
page = CONFIG_APPEARANCE;
struct mstdnt_storage* attachments = load_config(req, &ssn, api, page);
load_config(req, ssn, api, page);
// Load current account information
get_account_info(api, &ssn);
//get_account_info(api, ssn);
handle_paths(req, &ssn, api, paths, sizeof(paths)/sizeof(paths[0]));
rc = handle_paths(req, ssn, api, paths, sizeof(paths)/sizeof(paths[0]));
// Cleanup
if (cookies_str) tb_free(cookies_str);
if (post_str) tb_free(post_str);
if (get_str) tb_free(get_str);
free_files(&(keyfile(ssn.post.files)));
if (ssn.logged_in) mstdnt_cleanup_account(&(ssn.acct));
mstdnt_storage_cleanup(&(ssn.acct_storage));
if (attachments)
cleanup_media_storages(&ssn, attachments);
// This is a direct page, no requests made, so cleanup now
if (rc == 0)
{
debug("Direct page, cleaning up...");
session_cleanup(ssn);
}
return rc;
}
#ifndef SINGLE_THREADED
static void* threaded_fcgi_start(void* arg)
#ifndef CGI_MODE
static void fcgi_start(mastodont_t* api)
{
mastodont_t* api = arg;
int rc;
FCGX_Request req;
FCGX_InitRequest(&req, 0, 0);
FCGX_Request* req;
while (1)
{
static pthread_mutex_t accept_mutex = PTHREAD_MUTEX_INITIALIZER;
req = malloc(sizeof(FCGX_Request));
if (FCGX_InitRequest(req, 0, 0) != 0)
{
free(req);
continue;
}
pthread_mutex_lock(&accept_mutex);
rc = FCGX_Accept_r(&req);
pthread_mutex_unlock(&accept_mutex);
if (rc < 0) break;
struct mstdnt_fd fds = {
// The docs says not to use this directly, but we don't care
// what the docs say :^)
.fd = req->listen_sock,
.events = MSTDNT_POLLIN,
.revents = 0
};
application(api, &req);
// Will poll until we get a request
int res = mstdnt_await(api, 0, &fds, 1);
FCGX_Finish_r(&req);
if (fds.revents != 0)
{
rc = FCGX_Accept_r(req);
if (rc < 0) break;
rc = application(api, req);
if (rc == 0)
{
FCGX_Finish_r(req);
free(req);
}
}
else {
FCGX_Finish_r(req);
free(req);
}
}
return NULL;
}
#else
void cgi_start(mastodont_t* api)
{
while (FCGI_Accept() >= 0 && quit == 0)
while (FCGI_Accept() >= 0
#ifdef DEBUG
&& quit == 0)
#else
)
#endif
{
application(api, NULL);
}
@ -235,10 +267,29 @@ void xs_init(pTHX)
int main(int argc, char **argv, char **env)
{
#ifndef NO_EASTER_EGG
if (getenv("TERM"))
{
print_treebird_logo();
}
#endif
#ifdef __OpenBSD__
if (pledge("stdio rpath inet dns unveil prot_exec", "") == -1)
{
perror("pledge");
exit(2);
}
#endif
// Global init
mstdnt_global_curl_init();
#ifndef SINGLE_THREADED
FCGX_Init();
#ifndef CGI_MODE
if (FCGX_Init() != 0)
{
exit(1);
}
#endif
// Initialize Perl
@ -255,10 +306,8 @@ int main(int argc, char **argv, char **env)
init_template_files(aTHX);
// Setup mstdnt hooks to use Perl functions
struct mstdnt_hooks hooks = {
.malloc = tb_malloc,
// Not sure how this differs from tb_free? That's undefined... (but used elsewhere in the code just fine)
.free = tb_free,
.calloc = tb_calloc,
.realloc = tb_realloc,
@ -269,27 +318,19 @@ int main(int argc, char **argv, char **env)
mastodont_t api;
mstdnt_init(&api);
// Fetch information about the current instance
load_instance_info_cache(&api);
#ifndef SINGLE_THREADED
// Start thread pool
pthread_t id[THREAD_COUNT];
for (unsigned i = 0; i < THREAD_COUNT; ++i)
pthread_create(&id[i], NULL, threaded_fcgi_start, &api);
// load_instance_info_cache(&api);
#ifndef CGI_MODE
// Hell, let's not sit around here either
threaded_fcgi_start(&api);
fcgi_start(&api);
// Blocks
FCGX_ShutdownPending();
for (unsigned i = 0; i < THREAD_COUNT; ++i)
pthread_join(id[i], NULL);
#else
cgi_start(&api);
#endif
free_instance_info_cache();
// free_instance_info_cache();
mstdnt_global_curl_cleanup();
mstdnt_cleanup(&api);

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef TREEBIRD_MATH_H

View File

@ -1,23 +1,10 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <stdlib.h>
#include <malloc.h>
#include "memory.h"
#ifdef __GLIBC__

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
/* Everything seen here is info for the super curious, and does not really

View File

@ -1,26 +1,14 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "memory_page.h"
#include "base_page.h"
#include "memory.h"
void content_memory_stats(PATH_ARGS)
int content_memory_stats(PATH_ARGS)
{
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef MEMORY_PAGE_H
@ -22,6 +10,6 @@
#include "session.h"
#include "path.h"
void content_memory_stats(PATH_ARGS);
int content_memory_stats(PATH_ARGS);
#endif // MEMORY_PAGE_H

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <ctype.h>
@ -25,7 +13,8 @@
#include "mime.h"
#include "string.h"
char* get_mime_boundary(char* content_type_str, char** bound)
char*
get_mime_boundary(char* content_type_str, char** bound)
{
// If neither values are set, get out
if (!content_type_str)
@ -71,14 +60,16 @@ error:
return NULL;
}
static char* strnws(char* str)
static char*
strnws(char* str)
{
for (; isblank(*str); ++str);
return str;
}
// Function assumes character is at ';' char
static char* read_key(char** r, char* key)
static char*
read_key(char** r, char* key)
{
char* val, *read_val;
size_t key_len = strlen(key);

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef MIME_H

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <string.h>
@ -30,15 +18,49 @@
#include "error.h"
#include "emoji.h"
#include "account.h"
#include "types.h"
#include "../config.h"
void content_notifications(PATH_ARGS)
// Callback: content_notifications
static int
request_cb_content_notifications(mstdnt_request_cb_data* cb_data,
void* tbargs)
{
struct mstdnt_notifications* notifs = MSTDNT_CB_DATA(cb_data);
DESTRUCT_TB_ARGS(tbargs);
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
mXPUSHs(newRV_inc((SV*)session_hv));
mXPUSHs(newRV_inc((SV*)template_files));
if (notifs)
mXPUSHs(newRV_noinc((SV*)perlify_notifications(notifs->notifs,
notifs->len)));
// ARGS
PERL_STACK_SCALAR_CALL("notifications::content_notifications");
// Duplicate so we can free the TMPs
char* dup = PERL_GET_STACK_EXIT;
struct base_page b = {
.category = BASE_CAT_NOTIFICATIONS,
.content = dup,
.session = session_hv,
.sidebar_left = NULL
};
// Output
render_base_page(&b, req, ssn, api);
tb_free(dup);
finish_free_request(req);
return MSTDNT_REQUEST_DONE;
}
int content_notifications(PATH_ARGS)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 };
struct mstdnt_notification* notifs = NULL;
size_t notifs_len = 0;
struct mstdnt_notifications_args args = {
.exclude_types = 0,
@ -53,44 +75,49 @@ void content_notifications(PATH_ARGS)
.limit = 20,
};
struct request_args* cb_args =
request_args_create(req, ssn, api, NULL);
if (keystr(ssn->cookies.logged_in))
mstdnt_get_notifications(api, &m_args, &args, &storage, &notifs, &notifs_len);
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
mXPUSHs(newRV_inc((SV*)session_hv));
mXPUSHs(newRV_inc((SV*)template_files));
if (notifs)
mXPUSHs(newRV_noinc((SV*)perlify_notifications(notifs, notifs_len)));
// ARGS
PERL_STACK_SCALAR_CALL("notifications::content_notifications");
// Duplicate so we can free the TMPs
char* dup = PERL_GET_STACK_EXIT;
struct base_page b = {
.category = BASE_CAT_NOTIFICATIONS,
.content = dup,
.session = session_hv,
.sidebar_left = NULL
};
// Output
render_base_page(&b, req, ssn, api);
mstdnt_storage_cleanup(&storage);
mstdnt_cleanup_notifications(notifs, notifs_len);
tb_free(dup);
{
mstdnt_get_notifications(api, &m_args, request_cb_content_notifications,
cb_args, args);
return 1;
}
return 0;
}
void content_notifications_compact(PATH_ARGS)
int
request_cb_content_notifications_compact(mstdnt_request_cb_data* cb_data,
void* tbargs)
{
struct mstdnt_notifications* notifs = MSTDNT_CB_DATA(cb_data);
DESTRUCT_TB_ARGS(tbargs);
char* page;
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
mXPUSHs(newRV_noinc((SV*)session_hv));
mXPUSHs(newRV_inc((SV*)template_files));
if (notifs)
mXPUSHs(newRV_noinc((SV*)perlify_notifications(notifs->notifs,
notifs->len)));
PERL_STACK_SCALAR_CALL("notifications::embed_notifications");
page = PERL_GET_STACK_EXIT;
send_result(req, NULL, NULL, page, 0);
tb_free(page);
finish_free_request(req);
return MSTDNT_REQUEST_DONE;
}
int content_notifications_compact(PATH_ARGS)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
char* page;
struct mstdnt_storage storage = { 0 };
struct mstdnt_notification* notifs = NULL;
size_t notifs_len = 0;
if (keystr(ssn->cookies.logged_in))
{
@ -107,65 +134,55 @@ void content_notifications_compact(PATH_ARGS)
.limit = 20,
};
mstdnt_get_notifications(api, &m_args, &args, &storage, &notifs, &notifs_len);
struct request_args* cb_args =
request_args_create(req, ssn, api, NULL);
mstdnt_get_notifications(api,
&m_args,
request_cb_content_notifications_compact,
cb_args,
args);
return 1;
}
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
mXPUSHs(newRV_noinc((SV*)session_hv));
mXPUSHs(newRV_inc((SV*)template_files));
if (notifs)
mXPUSHs(newRV_noinc((SV*)perlify_notifications(notifs, notifs_len)));
PERL_STACK_SCALAR_CALL("notifications::embed_notifications");
page = PERL_GET_STACK_EXIT;
send_result(req, NULL, NULL, page, 0);
mstdnt_storage_cleanup(&storage);
mstdnt_cleanup_notifications(notifs, notifs_len);
tb_free(page);
return 0;
}
void content_notifications_clear(PATH_ARGS)
int content_notifications_clear(PATH_ARGS)
{
char* referer = GET_ENV("HTTP_REFERER", req);
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 };
// User wants to remove a specific notification
if (data)
{
mstdnt_notification_dismiss(api, &m_args, &storage, data[0]);
}
else {
mstdnt_notifications_clear(api, &m_args, &storage);
}
mstdnt_notification_dismiss(api, &m_args, NULL, NULL, data[0]);
else
mstdnt_notifications_clear(api, &m_args, NULL, NULL);
mstdnt_storage_cleanup(&storage);
redirect(req, REDIRECT_303, referer);
return 0;
}
void content_notifications_read(PATH_ARGS)
int content_notifications_read(PATH_ARGS)
{
char* referer = GET_ENV("HTTP_REFERER", req);
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 };
if (data)
{
struct mstdnt_notifications_args args = { .id = data[0] };
mstdnt_notifications_read(api, &m_args, &args, &storage, NULL);
mstdnt_notifications_read(api, &m_args, NULL, NULL,
(struct mstdnt_notifications_args){ 0 });
}
else {
struct mstdnt_notifications_args args = { .max_id = keystr(ssn->post.max_id) };
mstdnt_notifications_read(api, &m_args, &args, &storage, NULL);
mstdnt_notifications_read(api, &m_args, NULL, NULL,
(struct mstdnt_notifications_args){ 0 });
}
mstdnt_storage_cleanup(&storage);
redirect(req, REDIRECT_303, referer);
return 0;
}
// Converts it into a perl struct
@ -200,7 +217,8 @@ HV* perlify_notification(const struct mstdnt_notification* const notif)
PERLIFY_MULTI(notification, notifications, mstdnt_notification)
void api_notifications(PATH_ARGS)
// TODO
int api_notifications(PATH_ARGS)
{
send_result(req, NULL, "application/json", "{\"status\":0}", 0);
}

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef NOTIFICATIONS_H
@ -25,12 +13,12 @@
#include "cgi.h"
// Page contents
void content_notifications(PATH_ARGS);
void content_notifications_compact(PATH_ARGS);
void content_notifications_clear(PATH_ARGS);
void content_notifications_read(PATH_ARGS);
int content_notifications(PATH_ARGS);
int content_notifications_compact(PATH_ARGS);
int content_notifications_clear(PATH_ARGS);
int content_notifications_read(PATH_ARGS);
void api_notifications(PATH_ARGS);
int api_notifications(PATH_ARGS);
HV* perlify_notification(const struct mstdnt_notification* const notif);
AV* perlify_notifications(const struct mstdnt_notification* const notif, size_t len);

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "page_config.h"
@ -40,7 +28,7 @@ enum config_category
CONFIG_CAT_ACCOUNT
};
void content_config_general(PATH_ARGS)
int content_config_general(PATH_ARGS)
{
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
@ -64,7 +52,7 @@ void content_config_general(PATH_ARGS)
}
void content_config_appearance(PATH_ARGS)
int content_config_appearance(PATH_ARGS)
{
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
@ -87,7 +75,7 @@ void content_config_appearance(PATH_ARGS)
tb_free(dup);
}
void content_config(PATH_ARGS)
int content_config(PATH_ARGS)
{
redirect(req, REDIRECT_303, "/config/general");
}

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef PAGE_CONFIG_H
@ -24,9 +12,9 @@
#include "session.h"
#include "cgi.h"
void content_config_appearance(PATH_ARGS);
void content_config_general(PATH_ARGS);
//void content_config_account(PATH_ARGS);
void content_config(PATH_ARGS);
int content_config_appearance(PATH_ARGS);
int content_config_general(PATH_ARGS);
//int content_config_account(PATH_ARGS);
int content_config(PATH_ARGS);
#endif // PAGE_CONFIG_H

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <string.h>
@ -22,13 +10,15 @@
#include "index.h"
#include "account.h"
#include "error.h"
#include "session.h"
#include "helpers.h"
int parse_path(REQUEST_T req,
struct session* ssn,
mastodont_t* api,
struct path_info* path_info)
{
int res = 0;
int res = -1;
int fail = 0, fin = 0;
char* p = path_info->path + 1;
char* p2 = GET_ENV("PATH_INFO", req) + 1;
@ -85,11 +75,11 @@ int parse_path(REQUEST_T req,
breakpt:
if (!fail)
{
path_info->callback(req, ssn, api, data);
res = path_info->callback(req, ssn, api, data);
}
else
{
res = 1;
res = -1;
}
// Cleanup
@ -101,26 +91,56 @@ breakpt:
return res;
}
void handle_paths(REQUEST_T req,
struct path_args_data*
path_args_data_create(REQUEST_T req,
struct session* ssn,
mastodont_t* api,
void* data)
{
struct path_args_data* _data = malloc(sizeof(struct path_args_data));
if (!_data)
{
perror("malloc");
}
_data->req = req;
_data->ssn = ssn;
_data->api = api;
_data->data = data;
return _data;
}
void
path_args_data_destroy(struct path_args_data* refs)
{
session_cleanup(refs->ssn);
FCGX_Finish_r(refs->req);
free(refs->req);
}
int handle_paths(REQUEST_T req,
struct session* ssn,
mastodont_t* api,
struct path_info* paths,
size_t paths_len)
{
int res;
char* path = GET_ENV("PATH_INFO", req);
// "default" path
if (path == NULL || (path && strcmp(path, "/") == 0))
// "default" path OpenBSD httpd likes to return this one vv
if (path == NULL || (path && (strcmp(path, "/") == 0 || strcmp(path, "") == 0)))
{
content_index(req, ssn, api);
return content_index(req, ssn, api);
}
else { // Generic path
debug("Path: %s", path);
for (size_t i = 0; i < paths_len; ++i)
{
if (parse_path(req, ssn, api, paths + i) == 0)
return;
if ((res = parse_path(req, ssn, api, paths + i)) != -1)
return res;
}
// Fell out, return 404
content_not_found(req, ssn, api, path);
return 0;
}
}

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef PATH_H
@ -26,14 +14,48 @@
#include "request.h"
#define PATH_ARGS REQUEST_T req, struct session* ssn, mastodont_t* api, char** data
#define PATH_ARGS_PASS req, ssn, api, data
struct path_info
{
char* path;
void (*callback)(PATH_ARGS);
int (*callback)(PATH_ARGS);
};
void handle_paths(
/// Struct for use with mastodont-c, passed as an argument usually
struct path_args_data
{
REQUEST_T req;
struct session* ssn;
mastodont_t* api;
/// Need to manually free this or whatever
void* data;
};
/**
* Allocates a path_args_data struct.
*
* Used for mastodont-c callbacks essentially.
*
* @param req Request.
* @param ssn Session data.
* @param api API data. Usually a reference.
* @param data Any custom data, must be manually free'd
* @return Allocated struct, or NULL on error. Free with path_args_data_destroy
*/
struct path_args_data* path_args_data_create(REQUEST_T req,
struct session* ssn,
mastodont_t* api,
void* data);
/**
* Destroys the path args and struct created by @struct path_args_data_create
*
* @param ref To be destroyed.
*/
void path_args_data_destroy(struct path_args_data* ref);
int handle_paths(
REQUEST_T req,
struct session* ssn,
mastodont_t* api,

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "query.h"
@ -143,7 +131,7 @@ char* read_post_data(REQUEST_T req, struct post_values* post)
}
// fread should be a macro to FCGI_fread, which is set by FCGI_Accept in previous definitions
#ifndef SINGLE_THREADED
#ifndef CGI_MODE
size_t len = FCGX_GetStr(post_query, content_length, req->in);
#else
size_t len = fread(post_query, 1, content_length, stdin);
@ -218,7 +206,7 @@ char* parse_query(char* begin, struct http_query_info* info)
char* try_handle_post(REQUEST_T req, void (*call)(struct http_query_info*, void*), void* arg)
{
char* request_method = GET_ENV("REQUEST_METHOD", req);
char* request_method = GET_ENV("REQUEST_ETHOD", req);
char* post_query = NULL, * p_query_read;
struct http_query_info info;
@ -232,7 +220,7 @@ char* try_handle_post(REQUEST_T req, void (*call)(struct http_query_info*, void*
puts("Malloc error!");
return NULL;
}
#ifdef SINGLE_THREADED
#ifdef CGI_MODE
int size = read(STDIN_FILENO, post_query, content_length);
#else
int size = FCGX_GetStr(post_query, content_length, req->in);

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef QUERY_H

View File

@ -1,21 +1,16 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <stdlib.h>
#include "request.h"
pthread_mutex_t print_mutex = PTHREAD_MUTEX_INITIALIZER;
#ifndef CGI_MODE
void finish_free_request(REQUEST_T req)
{
FCGX_Finish_r(req);
free(req);
}
#endif // CGI_MODE

View File

@ -1,39 +1,25 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef REQUEST_H
#define REQUEST_H
#include <pthread.h>
extern pthread_mutex_t print_mutex;
#ifdef SINGLE_THREADED
#ifdef CGI_MODE
#define PRINTF(str, ...) printf(str, __VA_ARGS__)
#define PUT(str) printf(str)
#define REQUEST_T void*
#else
#define PRINTF(str, ...) do { pthread_mutex_lock(&print_mutex); \
FCGX_FPrintF(req->out, str, __VA_ARGS__); \
pthread_mutex_unlock(&print_mutex); } while (0);
#define PUT(str) do { pthread_mutex_lock(&print_mutex); \
FCGX_FPrintF(req->out, str); \
pthread_mutex_unlock(&print_mutex); } while (0);
#include <fcgiapp.h>
#define PRINTF(str, ...) do { FCGX_FPrintF(req->out, str, __VA_ARGS__); } while (0);
#define PUT(str) do { FCGX_FPrintF(req->out, str); } while (0);
#define REQUEST_T FCGX_Request*
#endif
#endif // CGI_MODE
void
finish_free_request(REQUEST_T req);
#endif /* REQUEST_H */

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "scrobble.h"

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef SCROBBLE_H

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <stdlib.h>
@ -29,8 +17,9 @@
#include "error.h"
#include "account.h"
void content_search_all(PATH_ARGS)
int content_search_all(PATH_ARGS)
{
#if 0
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 };
@ -75,7 +64,7 @@ void content_search_all(PATH_ARGS)
return;
}
mstdnt_search(api, &m_args, keystr(ssn->query.query), &storage, &args, &results);
mstdnt_search(api, &m_args, NULL, NULL, keystr(ssn->query.query), &storage, &args, &results);
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
@ -100,10 +89,12 @@ void content_search_all(PATH_ARGS)
mstdnt_cleanup_search_results(&results);
mstdnt_storage_cleanup(&storage);
tb_free(dup);
#endif
}
void content_search_statuses(PATH_ARGS)
int content_search_statuses(PATH_ARGS)
{
#if 0
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
char* statuses_html;
@ -122,7 +113,7 @@ void content_search_statuses(PATH_ARGS)
};
struct mstdnt_search_results results = { 0 };
mstdnt_search(api, &m_args, keystr(ssn->query.query), &storage, &args, &results);
mstdnt_search(api, &m_args, NULL, NULL, keystr(ssn->query.query), &storage, &args, &results);
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
@ -147,10 +138,12 @@ void content_search_statuses(PATH_ARGS)
mstdnt_cleanup_search_results(&results);
mstdnt_storage_cleanup(&storage);
tb_free(dup);
#endif
}
void content_search_accounts(PATH_ARGS)
int content_search_accounts(PATH_ARGS)
{
#if 0
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 };
@ -168,7 +161,7 @@ void content_search_accounts(PATH_ARGS)
};
struct mstdnt_search_results results = { 0 };
mstdnt_search(api, &m_args, keystr(ssn->query.query), &storage, &args, &results);
mstdnt_search(api, &m_args, NULL, NULL, keystr(ssn->query.query), &storage, &args, &results);
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
@ -193,10 +186,12 @@ void content_search_accounts(PATH_ARGS)
mstdnt_cleanup_search_results(&results);
mstdnt_storage_cleanup(&storage);
tb_free(dup);
#endif
}
void content_search_hashtags(PATH_ARGS)
int content_search_hashtags(PATH_ARGS)
{
#if 0
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 };
@ -214,17 +209,19 @@ void content_search_hashtags(PATH_ARGS)
};
struct mstdnt_search_results results = { 0 };
mstdnt_search(api, &m_args, keystr(ssn->query.query), &storage, &args, &results);
mstdnt_search(api, &m_args, NULL, NULL, keystr(ssn->query.query), &storage, &args, &results);
// TODO
mstdnt_cleanup_search_results(&results);
mstdnt_storage_cleanup(&storage);
// tb_free(dup);
#endif
}
HV* perlify_search_results(struct mstdnt_search_results* results)
{
#if 0
if (!results) return NULL;
HV* search_hv = newHV();
@ -233,4 +230,5 @@ HV* perlify_search_results(struct mstdnt_search_results* results)
// TODO tags
return search_hv;
#endif
}

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef SEARCH_H
@ -23,10 +11,10 @@
#include "path.h"
#include "global_perl.h"
void content_search_all(PATH_ARGS);
void content_search_statuses(PATH_ARGS);
void content_search_accounts(PATH_ARGS);
void content_search_hashtags(PATH_ARGS);
int content_search_all(PATH_ARGS);
int content_search_statuses(PATH_ARGS);
int content_search_accounts(PATH_ARGS);
int content_search_hashtags(PATH_ARGS);
HV* perlify_search_results(struct mstdnt_search_results* results);
#endif /* SEARCH_H */

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "account.h"
@ -50,3 +38,14 @@ HV* perlify_session(struct session* ssn)
return ssn_hv;
}
void session_cleanup(struct session* ssn)
{
tb_free(ssn->cookies_str);
tb_free(ssn->post_str);
tb_free(ssn->get_str);
free_files(&(keyfile(ssn->post.files)));
if (ssn->logged_in) mstdnt_cleanup_account(&(ssn->acct));
mstdnt_storage_cleanup(&(ssn->acct_storage));
/* if (attachments) */
/* cleanup_media_storages(ssn, attachments); */
}

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef SESSION_H
@ -24,6 +12,8 @@
#include "local_config.h"
#include "cookie.h"
/* One per connection, contains all the data for a connection
* as it travels along */
struct session
{
struct post_values post;
@ -33,10 +23,17 @@ struct session
int logged_in;
struct mstdnt_account acct;
struct mstdnt_storage acct_storage;
struct mstdnt_args m_args;
char* cookies_str;
char* post_str;
char* get_str;
};
const char* const get_instance(struct session* ssn);
const char* const get_token(struct session* ssn);
HV* perlify_session(struct session* ssn);
void session_cleanup(struct session* ssn);
#endif // SESSION_H

View File

@ -1,25 +1,13 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <stdlib.h>
#include <string.h>
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
/* #define PCRE2_CODE_UNIT_WIDTH 8 */
/* #include <pcre2.h> */
#include "helpers.h"
#include "http.h"
#include "base_page.h"
@ -35,6 +23,7 @@
#include "../config.h"
#include "string.h"
#include "emoji.h"
#include "types.h"
#include "account.h"
#define ACCOUNT_INTERACTIONS_LIMIT 11
@ -51,8 +40,7 @@ int try_post_status(struct session* ssn, mastodont_t* api)
// a MIME post request
m_args.flags ^= MSTDNT_FLAG_NO_URI_SANITIZE;
struct mstdnt_storage storage = { 0 }, *att_storage = NULL;
#if 0
char** files = NULL;
size_t files_len = 0;
struct mstdnt_attachment* attachments = NULL;
@ -62,9 +50,11 @@ int try_post_status(struct session* ssn, mastodont_t* api)
// Upload images
if (!ssn->post.file_ids.is_set)
try_upload_media(&att_storage, ssn, api, &attachments, &media_ids);
else
{
try_upload_media(&att_storage, ssn, api, &attachments, &media_ids);
return 1;
}
else {
// Parse json file ids
json_ids = cJSON_Parse(keystr(ssn->post.file_ids));
json_ids_len = cJSON_GetArraySize(json_ids);
@ -82,30 +72,34 @@ int try_post_status(struct session* ssn, mastodont_t* api)
}
}
#endif
// Cookie copy and read
struct mstdnt_status_args args = {
.content_type = "text/plain",
.expires_in = 0,
.in_reply_to_conversation_id = NULL,
.in_reply_to_id = keystr(ssn->post.replyid),
.language = NULL,
.media_ids = media_ids,
.media_ids_len = (!ssn->post.file_ids.is_set ? keyfile(ssn->post.files).array_size :
mstdnt_create_status(api, &m_args, NULL, NULL,
(struct mstdnt_status_args)
{
.content_type = "text/plain",
.expires_in = 0,
.in_reply_to_conversation_id = NULL,
.in_reply_to_id = keystr(ssn->post.replyid),
.language = NULL,
/*
.media_ids = media_ids,
.media_ids_len = (!ssn->post.file_ids.is_set ? keyfile(ssn->post.files).array_size :
(json_ids ? json_ids_len : 0)),
.poll = NULL,
.preview = 0,
.scheduled_at = NULL,
.sensitive = 0,
.spoiler_text = NULL,
.status = keystr(ssn->post.content),
.visibility = keystr(ssn->post.visibility),
};
*/
.media_ids = NULL,
.media_ids_len = 0,
.poll = NULL,
.preview = 0,
.scheduled_at = NULL,
.sensitive = 0,
.spoiler_text = NULL,
.status = keystr(ssn->post.content),
.visibility = keystr(ssn->post.visibility),
});
#if 0
// Finally, create (no error checking)
mstdnt_create_status(api, &m_args, &args, &storage);
mstdnt_storage_cleanup(&storage);
if (att_storage)
cleanup_media_storages(ssn, att_storage);
@ -116,6 +110,7 @@ int try_post_status(struct session* ssn, mastodont_t* api)
tb_free(attachments);
if (json_ids) cJSON_Delete(json_ids);
#endif
return 0;
}
@ -123,17 +118,13 @@ int try_react_status(struct session* ssn, mastodont_t* api, char* id, char* emoj
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 };
struct mstdnt_status status = { 0 };
mstdnt_status_emoji_react(api, &m_args, id, emoji, &storage, &status);
mstdnt_status_emoji_react(api, &m_args, NULL, NULL, id, emoji);
mstdnt_cleanup_status(&status);
mstdnt_storage_cleanup(&storage);
return 0;
}
void content_status_create(PATH_ARGS)
int content_status_create(PATH_ARGS)
{
char* referer = getenv("HTTP_REFERER");
@ -142,7 +133,7 @@ void content_status_create(PATH_ARGS)
redirect(req, REDIRECT_303, referer);
}
void content_status_react(PATH_ARGS)
int content_status_react(PATH_ARGS)
{
char* referer = getenv("HTTP_REFERER");
@ -156,40 +147,39 @@ int try_interact_status(struct session* ssn, mastodont_t* api, char* id)
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
int res = 0;
struct mstdnt_storage storage = { 0 };
if (!(keystr(ssn->post.itype) && id)) return 1;
// Pretty up the type
if (strcmp(keystr(ssn->post.itype), "like") == 0 ||
strcmp(keystr(ssn->post.itype), "likeboost") == 0)
res = mstdnt_favourite_status(api, &m_args, id, &storage, NULL);
res = mstdnt_favourite_status(api, &m_args, NULL, NULL, id);
// Not else if because possibly a like-boost
if (strcmp(keystr(ssn->post.itype), "repeat") == 0 ||
strcmp(keystr(ssn->post.itype), "likeboost") == 0)
res = mstdnt_reblog_status(api, &m_args, id, &storage, NULL);
res = mstdnt_reblog_status(api, &m_args, NULL, NULL, id);
else if (strcmp(keystr(ssn->post.itype), "bookmark") == 0)
res = mstdnt_bookmark_status(api, &m_args, id, &storage, NULL);
res = mstdnt_bookmark_status(api, &m_args, NULL, NULL, id);
else if (strcmp(keystr(ssn->post.itype), "pin") == 0)
res = mstdnt_pin_status(api, &m_args, id, &storage, NULL);
res = mstdnt_pin_status(api, &m_args, NULL, NULL, id);
else if (strcmp(keystr(ssn->post.itype), "mute") == 0)
res = mstdnt_mute_conversation(api, &m_args, id, &storage, NULL);
res = mstdnt_mute_conversation(api, &m_args, NULL, NULL, id);
else if (strcmp(keystr(ssn->post.itype), "delete") == 0)
res = mstdnt_delete_status(api, &m_args, id, &storage, NULL);
res = mstdnt_delete_status(api, &m_args, NULL, NULL, id);
else if (strcmp(keystr(ssn->post.itype), "unlike") == 0)
res = mstdnt_unfavourite_status(api, &m_args, id, &storage, NULL);
res = mstdnt_unfavourite_status(api, &m_args, NULL, NULL, id);
else if (strcmp(keystr(ssn->post.itype), "unrepeat") == 0)
res = mstdnt_unreblog_status(api, &m_args, id, &storage, NULL);
res = mstdnt_unreblog_status(api, &m_args, NULL, NULL, id);
else if (strcmp(keystr(ssn->post.itype), "unbookmark") == 0)
res = mstdnt_unbookmark_status(api, &m_args, id, &storage, NULL);
res = mstdnt_unbookmark_status(api, &m_args, NULL, NULL, id);
else if (strcmp(keystr(ssn->post.itype), "unpin") == 0)
res = mstdnt_unpin_status(api, &m_args, id, &storage, NULL);
res = mstdnt_unpin_status(api, &m_args, NULL, NULL, id);
else if (strcmp(keystr(ssn->post.itype), "unmute") == 0)
res = mstdnt_unmute_conversation(api, &m_args, id, &storage, NULL);
res = mstdnt_unmute_conversation(api, &m_args, NULL, NULL, id);
mstdnt_storage_cleanup(&storage);
return res;
}
#if 0
char* get_in_reply_to(mastodont_t* api,
struct session* ssn,
struct mstdnt_status* status,
@ -201,22 +191,24 @@ char* get_in_reply_to(mastodont_t* api,
struct mstdnt_account acct = { 0 };
int res = mstdnt_get_account(api,
&m_args,
1,
status->in_reply_to_account_id,
&acct,
&storage);
&m_args,
NULL, NULL,
1,
status->in_reply_to_account_id,
&acct,
&storage);
char* html = "TODO";
// char* html = construct_in_reply_to(status, res == 0 ? &acct : NULL, size);
// char* html = construct_in_reply_to(status, res == 0 ? &acct : NULL, size);
if (res == 0) mstdnt_cleanup_account(&acct);
mstdnt_storage_cleanup(&storage);
return html;
}
#endif
void status_interact(PATH_ARGS)
int status_interact(PATH_ARGS)
{
char* referer = GET_ENV("HTTP_REFERER", req);
@ -225,7 +217,7 @@ void status_interact(PATH_ARGS)
redirect(req, REDIRECT_303, referer);
}
void api_status_interact(PATH_ARGS)
int api_status_interact(PATH_ARGS)
{
if (try_interact_status(ssn, api, keystr(ssn->post.id)) == 0)
{
@ -235,50 +227,74 @@ void api_status_interact(PATH_ARGS)
send_result(req, NULL, "application/json", "{\"status\":\"Couldn't load status\"}", 0);
}
void status_view(PATH_ARGS)
int status_view(PATH_ARGS)
{
content_status(req, ssn, api, data, STATUS_FOCUSED);
}
void status_emoji(PATH_ARGS)
int status_emoji(PATH_ARGS)
{
content_status(req, ssn, api, data, STATUS_FOCUSED | STATUS_EMOJI_PICKER);
}
void status_reply(PATH_ARGS)
int status_reply(PATH_ARGS)
{
content_status(req, ssn, api, data, STATUS_FOCUSED | STATUS_REPLY);
}
void status_view_reblogs(PATH_ARGS)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_account* reblogs = NULL;
struct mstdnt_storage storage = { 0 };
size_t reblogs_len = 0;
char* status_id = data[0];
mstdnt_status_reblogged_by(api,
&m_args,
status_id,
&storage,
&reblogs,
&reblogs_len);
content_status_interactions(
static int
request_cb_status_view_reblogs(mstdnt_request_cb_data* cb_data, void* tbargs)
{
struct mstdnt_accounts* accts = MSTDNT_CB_DATA(cb_data);
DESTRUCT_TB_ARGS(tbargs);
content_status_interactions(
req,
ssn,
api,
"Reblogs",
reblogs,
reblogs_len);
accts->accts,
accts->len);
mstdnt_storage_cleanup(&storage);
mstdnt_cleanup_accounts(reblogs, reblogs_len);
finish_free_request(req);
return MSTDNT_REQUEST_DONE;
}
void status_view_favourites(PATH_ARGS)
int status_view_reblogs(PATH_ARGS)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
char* status_id = data[0];
mstdnt_status_reblogged_by(api,
&m_args,
NULL, NULL,
status_id);
return 0;
}
static int
request_cb_status_view_favourites(mstdnt_request_cb_data* cb_data, void* tbargs)
{
struct mstdnt_accounts* accts = MSTDNT_CB_DATA(cb_data);
DESTRUCT_TB_ARGS(tbargs);
content_status_interactions(
req,
ssn,
api,
"Favorites",
accts->accts,
accts->len);
finish_free_request(req);
return MSTDNT_REQUEST_DONE;
}
int
status_view_favourites(PATH_ARGS)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
@ -287,23 +303,15 @@ void status_view_favourites(PATH_ARGS)
size_t favourites_len = 0;
char* status_id = data[0];
mstdnt_status_favourited_by(api,
&m_args,
status_id,
&storage,
&favourites,
&favourites_len);
content_status_interactions(
req,
ssn,
api,
"Favorites",
favourites,
favourites_len);
struct request_args* cb_args =
request_args_create(req, ssn, api, NULL);
mstdnt_storage_cleanup(&storage);
mstdnt_cleanup_accounts(favourites, favourites_len);
mstdnt_status_favourited_by(api,
&m_args,
request_cb_status_view_favourites, cb_args,
status_id);
return 0;
}
void content_status_interactions(FCGX_Request* req,
@ -340,6 +348,7 @@ void content_status_interactions(FCGX_Request* req,
void content_status(PATH_ARGS, uint8_t flags)
{
#if 0
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = {0}, status_storage = {0};
@ -351,13 +360,14 @@ void content_status(PATH_ARGS, uint8_t flags)
size_t stat_before_len = 0, stat_after_len = 0;
try_post_status(ssn, api);
mstdnt_get_status(api, &m_args, data[0], &status_storage, &status);
mstdnt_get_status(api, &m_args, NULL, NULL, data[0], &status_storage, &status);
mstdnt_get_status_context(api,
&m_args,
data[0],
&storage,
&statuses_before, &statuses_after,
&stat_before_len, &stat_after_len);
&m_args,
NULL, NULL,
data[0],
&storage,
&statuses_before, &statuses_after,
&stat_before_len, &stat_after_len);
if ((flags & STATUS_EMOJI_PICKER) == STATUS_EMOJI_PICKER)
picker = construct_emoji_picker(status.id, &picker_len);
@ -399,14 +409,15 @@ void content_status(PATH_ARGS, uint8_t flags)
mstdnt_cleanup_statuses(statuses_before, stat_before_len);
mstdnt_cleanup_statuses(statuses_after, stat_after_len);
mstdnt_cleanup_status(&status);
mstdnt_cleanup_status(&status, 0);
mstdnt_storage_cleanup(&storage);
mstdnt_storage_cleanup(&status_storage);
tb_free(dup);
tb_free(picker);
#endif
}
void notice_redirect(PATH_ARGS)
int notice_redirect(PATH_ARGS)
{
char* url;
easprintf(&url, "%s/status/%s", config_url_prefix, data[0]);

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef STATUS_H
@ -49,20 +37,22 @@ struct interact_profile_args
int try_post_status(struct session* ssn, mastodont_t* api);
int try_interact_status(struct session* ssn, mastodont_t* api, char* id);
void content_status_create(PATH_ARGS);
void content_status_react(PATH_ARGS);
int content_status_create(PATH_ARGS);
int content_status_react(PATH_ARGS);
// HTML Builders
// Reply to
#if 0
/** Deprecated: May be used in the future for Mastodon only */
char* get_in_reply_to(mastodont_t* api,
struct session* ssn,
struct mstdnt_status* status,
size_t* size);
#endif
void status_view_reblogs(PATH_ARGS);
void status_view_favourites(PATH_ARGS);
int status_view_reblogs(PATH_ARGS);
int status_view_favourites(PATH_ARGS);
void content_status_interactions(FCGX_Request* req,
struct session* ssn,
@ -72,10 +62,10 @@ void content_status_interactions(FCGX_Request* req,
size_t accts_len);
// Status frontends
void status_view(PATH_ARGS);
void status_reply(PATH_ARGS);
void status_interact(PATH_ARGS);
void status_emoji(PATH_ARGS);
int status_view(PATH_ARGS);
int status_reply(PATH_ARGS);
int status_interact(PATH_ARGS);
int status_emoji(PATH_ARGS);
// Above wraps to the below function
void content_status(PATH_ARGS, uint8_t flags);
@ -83,10 +73,10 @@ void content_status(PATH_ARGS, uint8_t flags);
void cleanup_media_ids(struct session* ssn, char** media_ids);
// Redirects
void notice_redirect(PATH_ARGS);
int notice_redirect(PATH_ARGS);
// API
void api_status_interact(PATH_ARGS);
int api_status_interact(PATH_ARGS);
// Perl
HV* perlify_status_pleroma(const struct mstdnt_status_pleroma* pleroma);

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#define _XOPEN_SOURCE

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef TREE_STRING_H

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include <fcgi_stdio.h>

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef STRING_HELPERS_H

View File

@ -1,16 +0,0 @@
/* BEGIN Status_test */
struct mstdnt_status status_test = {
.account = {
.avatar = "/treebird_logo.png",
.display_name = "Test user",
.acct = "user@test.com",
},
.content = "Hello world<br><br>Hi",
};
before_html = construct_status(&status_test, NULL);
stat_html = construct_status(&status_test, NULL);
after_html = construct_status(&status_test, NULL);
/* END Status_test */

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#include "global_perl.h"
@ -29,17 +17,18 @@
#include "query.h"
#include "error.h"
#include "string_helpers.h"
#include "types.h"
void content_timeline(REQUEST_T req,
struct session* ssn,
mastodont_t* api,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses,
size_t statuses_len,
enum base_category cat,
char* header_text,
int show_post_box,
int fake_timeline)
void
content_timeline(REQUEST_T req,
struct session* ssn,
mastodont_t* api,
struct mstdnt_status* statuses,
size_t statuses_len,
enum base_category cat,
char* header_text,
int show_post_box,
int fake_timeline)
{
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
@ -73,18 +62,104 @@ void content_timeline(REQUEST_T req,
render_base_page(&b, req, ssn, api);
// Cleanup
mstdnt_storage_cleanup(storage);
mstdnt_cleanup_statuses(statuses, statuses_len);
tb_free(dup);
}
void tl_home(REQUEST_T req, struct session* ssn, mastodont_t* api, int local)
// Callback: tl_home
static int
request_cb_tl_home(mstdnt_request_cb_data* cb_data, void* tbargs)
{
struct mstdnt_statuses* statuses = MSTDNT_CB_DATA(cb_data);
DESTRUCT_TB_ARGS(tbargs);
content_timeline(req, ssn, api,// cb_data->storage,
statuses->statuses, statuses->len,
BASE_CAT_HOME, NULL, 1, 0);
finish_free_request(req);
return MSTDNT_REQUEST_DONE;
}
// Callback: tl_local
static int
request_cb_tl_local(mstdnt_request_cb_data* cb_data, void* tbargs)
{
struct mstdnt_statuses* statuses = MSTDNT_CB_DATA(cb_data);
DESTRUCT_TB_ARGS(tbargs);
content_timeline(req, ssn, api,// cb_data->storage,
statuses->statuses, statuses->len,
BASE_CAT_LOCAL, NULL, 1, 0);
finish_free_request(req);
return MSTDNT_REQUEST_DONE;
}
// Callback: tl_public
static int
request_cb_tl_public(mstdnt_request_cb_data* cb_data, void* tbargs)
{
struct mstdnt_statuses* statuses = MSTDNT_CB_DATA(cb_data);
DESTRUCT_TB_ARGS(tbargs);
content_timeline(req, ssn, api,// cb_data->storage,
statuses->statuses, statuses->len,
BASE_CAT_FEDERATED, NULL, 1, 0);
finish_free_request(req);
return MSTDNT_REQUEST_DONE;
}
// Callback: tl_list
static int
request_cb_tl_list(mstdnt_request_cb_data* cb_data, void* tbargs)
{
struct mstdnt_statuses* statuses = MSTDNT_CB_DATA(cb_data);
DESTRUCT_TB_ARGS(tbargs);
content_timeline(req, ssn, api,// cb_data->storage,
statuses->statuses, statuses->len,
BASE_CAT_LISTS, NULL, 0, 0);
finish_free_request(req);
return MSTDNT_REQUEST_DONE;
}
// Callback: tl_direct
static int
request_cb_tl_direct(mstdnt_request_cb_data* cb_data, void* tbargs)
{
struct mstdnt_statuses* statuses = MSTDNT_CB_DATA(cb_data);
DESTRUCT_TB_ARGS(tbargs);
content_timeline(req, ssn, api,// cb_data->storage,
statuses->statuses, statuses->len,
BASE_CAT_DIRECT, NULL, 0, 0);
finish_free_request(req);
return MSTDNT_REQUEST_DONE;
}
// Callback: tl_direct
static int
request_cb_tl_tags(mstdnt_request_cb_data* cb_data, void* tbargs)
{
struct mstdnt_statuses* statuses = MSTDNT_CB_DATA(cb_data);
DESTRUCT_TB_ARGS(tbargs);
content_timeline(req, ssn, api,// cb_data->storage,
statuses->statuses, statuses->len,
BASE_CAT_NONE, NULL, 0, 0);
finish_free_request(req);
return MSTDNT_REQUEST_DONE;
}
int
tl_home(REQUEST_T req, struct session* ssn, mastodont_t* api, int local)
{
struct mstdnt_args m_args = { 0 };
set_mstdnt_args(&m_args, ssn);
size_t statuses_len = 0;
struct mstdnt_status* statuses = NULL;
struct mstdnt_storage storage = { 0 };
struct mstdnt_timeline_args args = {
.with_muted = MSTDNT_TRUE,
@ -104,18 +179,18 @@ void tl_home(REQUEST_T req, struct session* ssn, mastodont_t* api, int local)
try_post_status(ssn, api);
mstdnt_timeline_home(api, &m_args, &args, &storage, &statuses, &statuses_len);
content_timeline(req, ssn, api, &storage, statuses, statuses_len, BASE_CAT_HOME, NULL, 1, 0);
struct request_args* cb_args =
request_args_create(req, ssn, api, NULL);
return mstdnt_timeline_home(api, &m_args, request_cb_tl_home,
cb_args, args);
}
void tl_direct(REQUEST_T req, struct session* ssn, mastodont_t* api)
int
tl_direct(REQUEST_T req, struct session* ssn, mastodont_t* api)
{
struct mstdnt_args m_args = { 0 };
set_mstdnt_args(&m_args, ssn);
size_t statuses_len = 0;
struct mstdnt_status* statuses = NULL;
struct mstdnt_storage storage = { 0 };
struct mstdnt_timeline_args args = {
.with_muted = 1,
@ -132,18 +207,22 @@ void tl_direct(REQUEST_T req, struct session* ssn, mastodont_t* api)
try_post_status(ssn, api);
mstdnt_timeline_direct(api, &m_args, &args, &storage, &statuses, &statuses_len);
content_timeline(req, ssn, api, &storage, statuses, statuses_len, BASE_CAT_DIRECT, "Direct", 0, 0);
struct request_args* cb_args =
request_args_create(req, ssn, api, NULL);
return mstdnt_timeline_direct(api, &m_args, request_cb_tl_direct,
cb_args, args);
}
void tl_public(REQUEST_T req, struct session* ssn, mastodont_t* api, int local, enum base_category cat)
int
tl_public(REQUEST_T req,
struct session* ssn,
mastodont_t* api,
int local,
enum base_category cat)
{
struct mstdnt_args m_args = { 0 };
set_mstdnt_args(&m_args, ssn);
size_t statuses_len = 0;
struct mstdnt_status* statuses = NULL;
struct mstdnt_storage storage = { 0 };
struct mstdnt_timeline_args args = {
.with_muted = MSTDNT_TRUE,
@ -162,18 +241,21 @@ void tl_public(REQUEST_T req, struct session* ssn, mastodont_t* api, int local,
try_post_status(ssn, api);
mstdnt_timeline_public(api, &m_args, &args, &storage, &statuses, &statuses_len);
content_timeline(req, ssn, api, &storage, statuses, statuses_len, cat, NULL, 1, 0);
struct request_args* cb_args =
request_args_create(req, ssn, api, NULL);
return mstdnt_timeline_public(api, &m_args, request_cb_tl_public,
cb_args, args);
}
void tl_list(REQUEST_T req, struct session* ssn, mastodont_t* api, char* list_id)
int
tl_list(REQUEST_T req,
struct session* ssn,
mastodont_t* api,
char* list_id)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
size_t statuses_len = 0;
struct mstdnt_status* statuses = NULL;
struct mstdnt_storage storage = { 0 };
struct mstdnt_timeline_args args = {
.max_id = keystr(ssn->post.max_id),
@ -189,20 +271,22 @@ void tl_list(REQUEST_T req, struct session* ssn, mastodont_t* api, char* list_id
try_post_status(ssn, api);
mstdnt_timeline_list(api, &m_args, list_id, &args, &storage, &statuses, &statuses_len);
content_timeline(req, ssn, api, &storage, statuses, statuses_len, BASE_CAT_LISTS, "List timeline", 0, 0);
struct request_args* cb_args =
request_args_create(req, ssn, api, NULL);
return mstdnt_timeline_list(api, &m_args, request_cb_tl_list, cb_args,
list_id, args);
}
void tl_tag(REQUEST_T req, struct session* ssn, mastodont_t* api, char* tag_id)
int
tl_tag(REQUEST_T req,
struct session* ssn,
mastodont_t* api,
char* tag_id)
{
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
char* header;
size_t statuses_len = 0;
struct mstdnt_status* statuses = NULL;
struct mstdnt_storage storage = { 0 };
struct mstdnt_timeline_args args = {
.max_id = keystr(ssn->post.max_id),
@ -216,46 +300,52 @@ void tl_tag(REQUEST_T req, struct session* ssn, mastodont_t* api, char* tag_id)
.limit = 20,
};
mstdnt_timeline_tag(api, &m_args, tag_id, &args, &storage, &statuses, &statuses_len);
struct request_args* cb_args =
request_args_create(req, ssn, api, NULL);
easprintf(&header, "Hashtag - #%s", tag_id);
content_timeline(req, ssn, api, &storage, statuses, statuses_len, BASE_CAT_NONE, header, 0, 0);
tb_free(header);
return mstdnt_timeline_tag(api, &m_args, request_cb_tl_tags, cb_args,
tag_id, args);
}
void content_tl_home(PATH_ARGS)
int
content_tl_home(PATH_ARGS)
{
if (keystr(ssn->cookies.logged_in))
tl_home(req, ssn, api, 0);
return tl_home(req, ssn, api, 0);
else
content_tl_federated(req, ssn, api, data);
return content_tl_federated(req, ssn, api, data);
}
void content_tl_direct(PATH_ARGS)
int
content_tl_direct(PATH_ARGS)
{
(void)data;
tl_direct(req, ssn, api);
return tl_direct(req, ssn, api);
}
void content_tl_federated(PATH_ARGS)
int
content_tl_federated(PATH_ARGS)
{
(void)data;
tl_public(req, ssn, api, 0, BASE_CAT_FEDERATED);
return tl_public(req, ssn, api, 0, BASE_CAT_FEDERATED);
}
void content_tl_local(PATH_ARGS)
int
content_tl_local(PATH_ARGS)
{
(void)data;
tl_public(req, ssn, api, 1, BASE_CAT_LOCAL);
return tl_public(req, ssn, api, 1, BASE_CAT_LOCAL);
}
void content_tl_list(PATH_ARGS)
int
content_tl_list(PATH_ARGS)
{
tl_list(req, ssn, api, data[0]);
return tl_list(req, ssn, api, data[0]);
}
void content_tl_tag(PATH_ARGS)
int
content_tl_tag(PATH_ARGS)
{
tl_tag(req, ssn, api, data[0]);
return tl_tag(req, ssn, api, data[0]);
}

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef TIMELINE_H
@ -27,39 +15,39 @@
#include "request.h"
/** Wrapper for content_tl_federated */
void tl_home(REQUEST_T req, struct session* ssn, mastodont_t* api, int local);
int tl_home(REQUEST_T req, struct session* ssn, mastodont_t* api, int local);
/** Wrapper for content_tl_direct */
void tl_direct(REQUEST_T req, struct session* ssn, mastodont_t* api);
int tl_direct(REQUEST_T req, struct session* ssn, mastodont_t* api);
/** Wrapper for content_tl_federated */
void tl_public(REQUEST_T req, struct session* ssn, mastodont_t* api, int local, enum base_category cat);
int tl_public(REQUEST_T req, struct session* ssn, mastodont_t* api, int local, enum base_category cat);
/** Wrapper for content_tl_list */
void tl_list(REQUEST_T req, struct session* ssn, mastodont_t* api, char* list_id);
int tl_list(REQUEST_T req, struct session* ssn, mastodont_t* api, char* list_id);
/** Wrapper for content_tl_tag */
void tl_tag(REQUEST_T req, struct session* ssn, mastodont_t* api, char* tag);
int tl_tag(REQUEST_T req, struct session* ssn, mastodont_t* api, char* tag);
/* ------------------------------------------------ */
/** Federated timeline */
void content_tl_federated(PATH_ARGS);
int content_tl_federated(PATH_ARGS);
/** Home timeline. Shows federated timeline if not logged in */
void content_tl_home(PATH_ARGS);
int content_tl_home(PATH_ARGS);
/** Direct message timeline */
void content_tl_direct(PATH_ARGS);
int content_tl_direct(PATH_ARGS);
/** Local/instance timeline */
void content_tl_local(PATH_ARGS);
int content_tl_local(PATH_ARGS);
/** List timeline */
void content_tl_list(PATH_ARGS);
int content_tl_list(PATH_ARGS);
/** Hashtag timeline */
void content_tl_tag(PATH_ARGS);
int content_tl_tag(PATH_ARGS);
/**
* Used to create generic timeline content. This timeline includes other features
@ -70,8 +58,6 @@ void content_tl_tag(PATH_ARGS);
* @param req This request
* @param ssn This session
* @param api The api
* @param storage The storage for statuses, will be cleaned up in this function, do NOT
* cleanup yourself.
* @param statuses The statuses, will be cleaned up in this function, do NOT cleanup yourself.
* @param statuses_len Length of `statuses`
* @param cat The category to "highlight" on the sidebar
@ -81,7 +67,6 @@ void content_tl_tag(PATH_ARGS);
void content_timeline(REQUEST_T req,
struct session* ssn,
mastodont_t* api,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses,
size_t statuses_len,
enum base_category cat,

29
src/types.c Normal file
View File

@ -0,0 +1,29 @@
/*
* Treebird - Lightweight frontend for Pleroma
*
* Licensed under the BSD 3-Clause License
*/
#include "types.h"
#include <fcgiapp.h>
struct request_args*
request_args_create(REQUEST_T req, struct session* ssn, mastodont_t* api, void* _args)
{
struct request_args* args = malloc(sizeof(struct request_args));
if (!args)
perror("request_args_create: malloc");
args->req = req;
args->ssn = ssn;
args->args = _args;
return args;
}
void request_args_cleanup(struct request_args* args)
{
FCGX_Finish_r(args->req);
free(args->req);
free(args->ssn);
}

36
src/types.h Normal file
View File

@ -0,0 +1,36 @@
/*
* Treebird - Lightweight frontend for Pleroma
*
* Licensed under the BSD 3-Clause License
*/
#ifndef TB_TYPES_H
#define TB_TYPES_H
#include <mastodont.h>
#include "types.h"
#include "session.h"
struct request_args
{
REQUEST_T req;
struct session* ssn;
mastodont_t* api;
void* args;
};
#define DESTRUCT_TB_ARGS(_args) \
REQUEST_T req = ((struct request_args*)_args)->req; \
struct session* ssn = ((struct request_args*)_args)->ssn; \
mastodont_t* api = ((struct request_args*)_args)->api; \
void* args = ((struct request_args*)_args)->args; \
(void)req; \
(void)ssn; \
(void)api; \
(void)args;
struct request_args*
request_args_create(REQUEST_T req, struct session* ssn, mastodont_t* api, void* args);
void request_args_cleanup(struct request_args* req);
#endif // TB_TYPES_H

View File

@ -1,680 +1,3 @@
<div class="simple-page">
<h1>License</h1>
<h3 style="text-align: center;">GNU AFFERO GENERAL PUBLIC LICENSE</h3>
<p style="text-align: center;">Version 3, 19 November 2007</p>
<p>Copyright &copy; 2007 Free Software Foundation,
Inc. &lt;<a href="https://fsf.org/">https://fsf.org/</a>&gt;
<br />
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.</p>
<h4 id="preamble">Preamble</h4>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>The precise terms and conditions for copying, distribution and
modification follow.</p>
<h4 id="terms">TERMS AND CONDITIONS</h4>
<h4 id="section0">0. Definitions.</h4>
<p>&quot;This License&quot; refers to version 3 of the GNU Affero General Public
License.</p>
<p>&quot;Copyright&quot; also means copyright-like laws that apply to other kinds
of works, such as semiconductor masks.</p>
<p>&quot;The Program&quot; refers to any copyrightable work licensed under this
License. Each licensee is addressed as &quot;you&quot;. &quot;Licensees&quot; and
&quot;recipients&quot; may be individuals or organizations.</p>
<p>To &quot;modify&quot; 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 &quot;modified version&quot; of the
earlier work or a work &quot;based on&quot; the earlier work.</p>
<p>A &quot;covered work&quot; means either the unmodified Program or a work based
on the Program.</p>
<p>To &quot;propagate&quot; 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.</p>
<p>To &quot;convey&quot; 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.</p>
<p>An interactive user interface displays &quot;Appropriate Legal Notices&quot;
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.</p>
<h4 id="section1">1. Source Code.</h4>
<p>The &quot;source code&quot; for a work means the preferred form of the work
for making modifications to it. &quot;Object code&quot; means any non-source
form of a work.</p>
<p>A &quot;Standard Interface&quot; 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.</p>
<p>The &quot;System Libraries&quot; 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
&quot;Major Component&quot;, 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.</p>
<p>The &quot;Corresponding Source&quot; 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.</p>
<p>The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.</p>
<p>The Corresponding Source for a work in source code form is that
same work.</p>
<h4 id="section2">2. Basic Permissions.</h4>
<p>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.</p>
<p>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.</p>
<p>Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.</p>
<h4 id="section3">3. Protecting Users' Legal Rights From Anti-Circumvention Law.</h4>
<p>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.</p>
<p>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.</p>
<h4 id="section4">4. Conveying Verbatim Copies.</h4>
<p>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.</p>
<p>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.</p>
<h4 id="section5">5. Conveying Modified Source Versions.</h4>
<p>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:</p>
<ul>
<li>a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.</li>
<li>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
&quot;keep intact all notices&quot;.</li>
<li>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.</li>
<li>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.</li>
</ul>
<p>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
&quot;aggregate&quot; 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.</p>
<h4 id="section6">6. Conveying Non-Source Forms.</h4>
<p>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:</p>
<ul>
<li>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.</li>
<li>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.</li>
<li>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.</li>
<li>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.</li>
<li>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.</li>
</ul>
<p>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.</p>
<p>A &quot;User Product&quot; is either (1) a &quot;consumer product&quot;, 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, &quot;normally used&quot; 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.</p>
<p>&quot;Installation Information&quot; 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.</p>
<p>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).</p>
<p>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.</p>
<p>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.</p>
<h4 id="section7">7. Additional Terms.</h4>
<p>&quot;Additional permissions&quot; 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.</p>
<p>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.</p>
<p>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:</p>
<ul>
<li>a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or</li>
<li>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</li>
<li>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</li>
<li>d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or</li>
<li>e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or</li>
<li>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.</li>
</ul>
<p>All other non-permissive additional terms are considered &quot;further
restrictions&quot; 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.</p>
<p>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.</p>
<p>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.</p>
<h4 id="section8">8. Termination.</h4>
<p>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).</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<h4 id="section9">9. Acceptance Not Required for Having Copies.</h4>
<p>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.</p>
<h4 id="section10">10. Automatic Licensing of Downstream Recipients.</h4>
<p>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.</p>
<p>An &quot;entity transaction&quot; 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.</p>
<p>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.</p>
<h4 id="section11">11. Patents.</h4>
<p>A &quot;contributor&quot; 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 &quot;contributor version&quot;.</p>
<p>A contributor's &quot;essential patent claims&quot; 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, &quot;control&quot; includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.</p>
<p>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.</p>
<p>In the following three paragraphs, a &quot;patent license&quot; 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 &quot;grant&quot; such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.</p>
<p>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. &quot;Knowingly relying&quot; 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.</p>
<p>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.</p>
<p>A patent license is &quot;discriminatory&quot; 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.</p>
<p>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.</p>
<h4 id="section12">12. No Surrender of Others' Freedom.</h4>
<p>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.</p>
<h4 id="section13">13. Remote Network Interaction; Use with the GNU General Public License.</h4>
<p>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.</p>
<p>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.</p>
<h4 id="section14">14. Revised Versions of this License.</h4>
<p>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.</p>
<p>Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero
General Public License &quot;or any later version&quot; 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.</p>
<p>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.</p>
<p>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.</p>
<h4 id="section15">15. Disclaimer of Warranty.</h4>
<p>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 &quot;AS IS&quot; 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.</p>
<h4 id="section16">16. Limitation of Liability.</h4>
<p>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.</p>
<h4 id="section17">17. Interpretation of Sections 15 and 16.</h4>
<p>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.</p>
<p>END OF TERMS AND CONDITIONS</p>
<h4 id="howto">How to Apply These Terms to Your New Programs</h4>
<p>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.</p>
<p>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 &quot;copyright&quot; line and a pointer to where the full notice is found.</p>
<pre> &lt;one line to give the program's name and a brief idea of what it does.&gt;
Copyright (C) &lt;year&gt; &lt;name of author&gt;
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 &lt;https://www.gnu.org/licenses/&gt;.
</pre>
<p>Also add information on how to contact you by electronic and paper mail.</p>
<p>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 &quot;Source&quot; 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.</p>
<p>You should also get your employer (if you work as a programmer) or school,
if any, to sign a &quot;copyright disclaimer&quot; for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
&lt;<a href="https://www.gnu.org/licenses/">https://www.gnu.org/licenses/</a>&gt;.</p>
</div>

View File

@ -1,19 +1,7 @@
/*
* Treebird - Lightweight frontend for Pleroma
* Copyright (C) 2022 Nekobit
*
* 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/>.
* Licensed under the BSD 3-Clause License
*/
#ifndef TEST_H