Subversion Repositories RepoView

Rev

Rev 32 | Rev 42 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 32 Rev 39
Line 1... Line 1...
1
/* $Id: modern.c 32 2024-08-22 01:58:10Z nishi $ */
1
/* $Id: modern.c 39 2024-08-22 03:38:21Z nishi $ */
2
 
2
 
3
#include "rv_query.h"
3
#include "rv_query.h"
4
 
4
 
5
#include "rv_util.h"
5
#include "rv_util.h"
6
#include "rv_version.h"
6
#include "rv_version.h"
Line 12... Line 12...
12
 
12
 
13
#ifdef USE_ENSCRIPT
13
#ifdef USE_ENSCRIPT
14
#include "rv_enscript.h"
14
#include "rv_enscript.h"
15
#endif
15
#endif
16
 
16
 
-
 
17
#ifdef USE_AVATAR
-
 
18
#include "rv_avatar.h"
-
 
19
#endif
-
 
20
 
17
#include <stdio.h>
21
#include <stdio.h>
18
#include <stdlib.h>
22
#include <stdlib.h>
19
#include <string.h>
23
#include <string.h>
-
 
24
#include <unistd.h>
20
 
25
 
21
extern char* buffer;
26
extern char* buffer;
22
void add_data(char** data, const char* txt);
27
void add_data(char** data, const char* txt);
23
void render_stuff();
28
void render_stuff();
24
 
29
 
Line 206... Line 211...
206
	add_data(&page, "</tr>\n");
211
	add_data(&page, "</tr>\n");
207
	free(query);
212
	free(query);
208
	free(urlpath);
213
	free(urlpath);
209
}
214
}
210
 
215
 
-
 
216
void generate_avatar(void) {
-
 
217
	if(user != NULL) {
-
 
218
		char* tmp = rv_strcat3(AVATAR_ROOT, "/", user);
-
 
219
		char* path = rv_strcat(tmp, ".png");
-
 
220
		free(tmp);
-
 
221
		if(access(path, F_OK) != 0) {
-
 
222
			rv_avatar_generate(path, user);
-
 
223
		}
-
 
224
		free(path);
-
 
225
	}
-
 
226
}
-
 
227
 
211
void render_page(void) {
228
void render_page(void) {
212
	rv_load_query('Q');
229
	rv_load_query('Q');
213
	char* query = rv_get_query("page");
230
	char* query = rv_get_query("page");
214
	if(query == NULL) query = "welcome";
231
	if(query == NULL) query = "welcome";
215
 
232
 
-
 
233
#ifdef USE_AVATAR
-
 
234
	generate_avatar();
-
 
235
#endif
-
 
236
 
216
	if(strcmp(query, "welcome") == 0) {
237
	if(strcmp(query, "welcome") == 0) {
217
		title = rv_strdup("Welcome");
238
		title = rv_strdup("Welcome");
218
		desc = rv_strdup("Welcome to " INSTANCE_NAME ".");
239
		desc = rv_strdup("Welcome to " INSTANCE_NAME ".");
219
		page = rv_strcat3("Welcome to " INSTANCE_NAME ".<br>This instance is running RepoView version ", rv_get_version(), ".");
240
		page = rv_strcat3("Welcome to " INSTANCE_NAME ".<br>This instance is running RepoView version ", rv_get_version(), ".");
220
#ifdef ALLOW_SIGNUP
241
#ifdef ALLOW_SIGNUP
Line 354... Line 375...
354
		desc = rv_strdup("You manage your information here.");
375
		desc = rv_strdup("You manage your information here.");
355
		if(user == NULL) {
376
		if(user == NULL) {
356
			page = rv_strdup("It looks like you are not logged in.<br>Want to <a href=\"");
377
			page = rv_strdup("It looks like you are not logged in.<br>Want to <a href=\"");
357
			add_data(&page, INSTANCE_ROOT);
378
			add_data(&page, INSTANCE_ROOT);
358
			add_data(&page, "/?page=login\">log in</a>?\n");
379
			add_data(&page, "/?page=login\">log in</a>?\n");
-
 
380
		} else {
-
 
381
			page = rv_strdup("");
-
 
382
			add_data(&page, "<h2 id=\"youricon\">Your Icon</h2>\n");
-
 
383
			add_data(&page, "<a href=\"");
-
 
384
			add_data(&page, WWW_AVATAR_ROOT);
-
 
385
			add_data(&page, "/");
-
 
386
			add_data(&page, user);
-
 
387
			add_data(&page, ".png\"><img src=\"");
-
 
388
			add_data(&page, WWW_AVATAR_ROOT);
-
 
389
			add_data(&page, "/");
-
 
390
			add_data(&page, user);
-
 
391
			add_data(&page, ".png\" alt=\"Your Icon\"></a>");
-
 
392
			add_data(&page, "<form action=\"");
-
 
393
			add_data(&page, INSTANCE_ROOT);
-
 
394
			add_data(&page, "/?page=uploadpfp\" method=\"POST\" enctype=\"multipart/form-data\">\n");
-
 
395
			add_data(&page, "	<input type=\"file\" name=\"pfp\">\n");
-
 
396
			add_data(&page, "	<input type=\"submit\" value=\"Upload\">\n");
-
 
397
			add_data(&page, "</form>\n");
359
		}
398
		}
360
#endif
399
#endif
361
	} else if(strcmp(query, "myrepo") == 0) {
400
	} else if(strcmp(query, "myrepo") == 0) {
362
		title = rv_strdup("My Repositories");
401
		title = rv_strdup("My Repositories");
363
		desc = rv_strdup("You manage your repositories here.");
402
		desc = rv_strdup("You manage your repositories here.");
Line 692... Line 731...
692
 
731
 
693
	if(title == NULL) title = rv_strdup("");
732
	if(title == NULL) title = rv_strdup("");
694
	if(desc == NULL) desc = rv_strdup("");
733
	if(desc == NULL) desc = rv_strdup("");
695
	if(page == NULL) page = rv_strdup("");
734
	if(page == NULL) page = rv_strdup("");
696
	if(nav == NULL) nav = rv_strdup("");
735
	if(nav == NULL) nav = rv_strdup("");
-
 
736
 
-
 
737
#ifdef USE_AVATAR
-
 
738
	generate_avatar();
-
 
739
#endif
-
 
740
 
697
	render_stuff();
741
	render_stuff();
698
freeall:
742
freeall:
699
	free(page);
743
	free(page);
700
	free(desc);
744
	free(desc);
701
	free(title);
745
	free(title);