Add start of account page, create owner account page routes, make /owner/actor look for application/ld+json before providing JSON-LD object, refactor to view/owner_actor.json.template to use g_server_name instead of hardcoding my test server into the calling function

master
teknomunk 1 year ago
parent 494c0eec6d
commit db8ffe1e38

@ -2,7 +2,12 @@
#include "http_server/http_request.h"
#include "model/server.h"
#include "view/layout.h"
#include <stdio.h>
#include <string.h>
static void write_public_key( FILE* f )
{
@ -17,9 +22,8 @@ static void write_public_key( FILE* f )
}
}
static void handle_owner_actor( struct http_request* req )
static bool handle_owner_actor( struct http_request* req )
{
const char* server = "apogee.polaris-1.work";
struct account* owner_account = account_from_id(0);
http_request_send_headers( req, 200, "application/activity+json", true );
@ -27,13 +31,33 @@ static void handle_owner_actor( struct http_request* req )
#define RENDER
#include "src/view/owner_actor.json.inc"
#undef RENDER
return true;
}
static bool show_owner_profile_page( struct http_request* req )
{
struct account* account = account_from_id(0);
const char* title = "Apogee";
http_request_send_headers( req, 200, "text/html", true );
FILE* f = http_request_get_response_body(req);
#define RENDER
#include "src/view/account_page.html.inc"
#undef RENDER
return true;
}
bool route_owner( struct http_request* req )
{
if( http_request_route( req, "/actor" ) ) {
handle_owner_actor(req);
return true;
if( http_request_route_term( req, "/actor" ) ) {
const char* accept = http_request_get_header( req, "Accept" );
if( 0 == strcmp(accept,"application/ld+json")) {
return handle_owner_actor(req);
}
return show_owner_profile_page(req);
}
return false;

@ -0,0 +1,3 @@
%( view_begin_layout(f,title); )
<h1>%s{ account->display_name }</h1>
%( view_end_layout(f); )

@ -0,0 +1,17 @@
#include "layout.h"
void view_begin_layout( FILE* f, const char* title )
{
#define RENDER
#define BEGIN
#include "src/view/layout.html.inc"
#undef BEGIN
#undef RENDER
}
void view_end_layout( FILE* f )
{
#define RENDER
#include "src/view/layout.html.inc"
#undef RENDER
}

@ -0,0 +1,7 @@
#pragma once
#include <stdio.h>
void view_begin_layout( FILE* f, const char* title );
void view_end_layout( FILE* f );

@ -0,0 +1,12 @@
%( #ifdef BEGIN )
<html>
<head>
<title>%s{title}</title>
</head>
<body>
%( #else )
</body>
</html>
%( #endif )

@ -4,14 +4,14 @@
"https://w3id.org/security/v1"
],
"id": "https://%s{server}/owner/actor",
"id": "https://%s{g_server_name}/owner/actor",
"type": "Person",
"preferredUsername": "%s{owner_account->handle}",
"inbox": "https://%s{server}/inbox",
"inbox": "https://%s{g_server_name}/inbox",
"publicKey": {
"id": "https://%s{server}/owner/actor#main-key",
"owner": "https://%s{server}/owner/actor",
"id": "https://%s{g_server_name}/owner/actor#main-key",
"owner": "https://%s{g_server_name}/owner/actor",
"publicKeyPem": "%( write_public_key(f); )"
}
}

Loading…
Cancel
Save