Compare commits
3 Commits
c3e8efd394
...
2cb5bf79e0
Author | SHA1 | Date |
---|---|---|
nekobit | 2cb5bf79e0 | |
nekobit | fa92ac39d4 | |
nekobit | 3a9dfa3dc9 |
|
@ -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?
|
||||
|
||||
|
|
|
@ -16,6 +16,12 @@ For the following UNIX-like system, you will need the following libraries/packag
|
|||
|
||||
`# 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
|
||||
|
@ -24,16 +30,16 @@ TODO
|
|||
|
||||
`# pkg install p5-Template-Toolkit fcgi-devkit curl gmake`
|
||||
|
||||
---
|
||||
|
||||
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
|
||||
(Premake will remind you of this). Note that this setup will change in the
|
||||
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 `premake4 gmake`. This will generate a gmake build file.
|
||||
|
||||
Then run `make`. (**hint:** Pass -j3 to speed up compilation).
|
||||
Run `make` (or `gmake`).
|
||||
|
||||
## Perl dependencies manual install
|
||||
|
||||
|
@ -82,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
|
||||
|
|
32
src/login.c
32
src/login.c
|
@ -24,7 +24,8 @@
|
|||
static void
|
||||
render_login_page(REQUEST_T req,
|
||||
struct session* ssn,
|
||||
mastodont_t* api)
|
||||
mastodont_t* api,
|
||||
char const* error)
|
||||
{
|
||||
char* page;
|
||||
|
||||
|
@ -32,10 +33,9 @@ render_login_page(REQUEST_T req,
|
|||
HV* session_hv = perlify_session(ssn);
|
||||
XPUSHs(newRV_noinc((SV*)session_hv));
|
||||
XPUSHs(newRV_noinc((SV*)template_files));
|
||||
#if 0
|
||||
if (storage.error || oauth_store.error)
|
||||
mXPUSHs(newSVpv(storage.error ? storage.error : oauth_store.error, 0));
|
||||
#endif
|
||||
|
||||
if (error)
|
||||
mXPUSHs(newSVpv(error, 0));
|
||||
|
||||
PERL_STACK_SCALAR_CALL("login::content_login");
|
||||
|
||||
|
@ -72,6 +72,14 @@ request_cb_oauth_token(struct mstdnt_request_cb_data* cb_data,
|
|||
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
|
||||
|
@ -84,11 +92,9 @@ request_cb_oauth_token(struct mstdnt_request_cb_data* cb_data,
|
|||
// Clears the cookie
|
||||
PUT("Set-Cookie: instance_url=; Path=/; Max-Age=-1\r\n");
|
||||
}
|
||||
|
||||
|
||||
apply_access_token(req, token->access_token);
|
||||
|
||||
tb_free(url_link);
|
||||
|
||||
path_args_data_destroy(path_data);
|
||||
return MSTDNT_REQUEST_DONE;
|
||||
}
|
||||
|
@ -116,8 +122,9 @@ request_cb_register_app(struct mstdnt_request_cb_data* cb_data,
|
|||
.username = keystr(path_data->ssn->post.username),
|
||||
.password = keystr(path_data->ssn->post.password)
|
||||
});
|
||||
|
||||
return MSTDNT_REQUEST_DONE;
|
||||
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
|
||||
|
@ -131,6 +138,7 @@ register_app(PATH_ARGS)
|
|||
.scopes = LOGIN_SCOPE,
|
||||
.website = NULL
|
||||
};
|
||||
|
||||
|
||||
// Check if the username contains an @ symbol
|
||||
char* address = strstr(keystr(ssn->post.username), "%40");
|
||||
|
@ -245,8 +253,10 @@ content_login(PATH_ARGS)
|
|||
keystr(ssn->post.password))
|
||||
{
|
||||
register_app(PATH_ARGS_PASS);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
render_login_page(req, ssn, api);
|
||||
render_login_page(req, ssn, api, NULL);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
46
src/status.c
46
src/status.c
|
@ -31,7 +31,6 @@
|
|||
|
||||
int try_post_status(struct session* ssn, mastodont_t* api)
|
||||
{
|
||||
#if 0
|
||||
if (!(keystr(ssn->post.content))) return 1;
|
||||
struct mstdnt_args m_args;
|
||||
set_mstdnt_args(&m_args, ssn);
|
||||
|
@ -41,6 +40,7 @@ int try_post_status(struct session* ssn, mastodont_t* api)
|
|||
// a MIME post request
|
||||
m_args.flags ^= MSTDNT_FLAG_NO_URI_SANITIZE;
|
||||
|
||||
#if 0
|
||||
char** files = NULL;
|
||||
size_t files_len = 0;
|
||||
struct mstdnt_attachment* attachments = NULL;
|
||||
|
@ -72,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, NULL, NULL, args);
|
||||
|
||||
mstdnt_storage_cleanup(&storage);
|
||||
|
||||
if (att_storage)
|
||||
cleanup_media_storages(ssn, att_storage);
|
||||
|
||||
|
|
Loading…
Reference in New Issue