Subversion Repositories RepoView

Rev

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

Rev 9 Rev 10
Line 1... Line 1...
1
/* $Id: modern.c 9 2024-08-21 02:02:13Z nishi $ */
1
/* $Id: modern.c 10 2024-08-21 02:13:48Z 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 18... Line 18...
18
void render_stuff();
18
void render_stuff();
19
 
19
 
20
char* title = NULL;
20
char* title = NULL;
21
char* desc = NULL;
21
char* desc = NULL;
22
char* page = NULL;
22
char* page = NULL;
-
 
23
char* nav = NULL;
23
extern char* user;
24
extern char* user;
24
 
25
 
25
void render_page(void) {
26
void render_page(void) {
26
	rv_load_query('Q');
27
	rv_load_query('Q');
27
	char* query = rv_get_query("page");
28
	char* query = rv_get_query("page");
Line 100... Line 101...
100
		desc = rv_strdup("You manage your repositories here.");
101
		desc = rv_strdup("You manage your repositories here.");
101
		if(user == NULL) {
102
		if(user == NULL) {
102
			page = rv_strdup("It looks like you are not logged in.<br>Want to <a href=\"");
103
			page = rv_strdup("It looks like you are not logged in.<br>Want to <a href=\"");
103
			add_data(&page, INSTANCE_ROOT);
104
			add_data(&page, INSTANCE_ROOT);
104
			add_data(&page, "/?page=login\">log in</a>?\n");
105
			add_data(&page, "/?page=login\">log in</a>?\n");
-
 
106
		} else {
-
 
107
			nav = rv_strdup("");
-
 
108
			add_data(&nav, "<li><a href=\"#createrepo\">Create a repository</a></li>\n");
-
 
109
			add_data(&nav, "<li><a href=\"#repolist\">Repository List</a></li>\n");
-
 
110
			page = rv_strdup("");
-
 
111
			add_data(&page, "<h2 id=\"createrepo\">Create a repository</h2>\n");
-
 
112
			add_data(&page, "<form action=\"");
-
 
113
			add_data(&page, INSTANCE_ROOT);
-
 
114
			add_data(&page, "/?page=createrepo\" method=\"POST\">\n");
-
 
115
			add_data(&page, "	<table border=\"0\">\n");
-
 
116
			add_data(&page, "		<tr>\n");
-
 
117
			add_data(&page, "			<th>Repository name</th>\n");
-
 
118
			add_data(&page, "			<td>\n");
-
 
119
			add_data(&page, "				<input name=\"name\">\n");
-
 
120
			add_data(&page, "			</td>\n");
-
 
121
			add_data(&page, "			<td><input type=\"submit\" value=\"Create\"></td>\n");
-
 
122
			add_data(&page, "		</tr>\n");
-
 
123
			add_data(&page, "	</table>\n");
-
 
124
			add_data(&page, "</form>\n");
-
 
125
			add_data(&page, "<h2 id=\"repolist\">Repository List</h2>\n");
105
		}
126
		}
106
	} else if(strcmp(query, "logout") == 0) {
127
	} else if(strcmp(query, "logout") == 0) {
107
		title = rv_strdup("Logout");
128
		title = rv_strdup("Logout");
108
		desc = rv_strdup("You can log out from your account here.");
129
		desc = rv_strdup("You can log out from your account here.");
109
		if(user == NULL) {
130
		if(user == NULL) {
Line 122... Line 143...
122
	}
143
	}
123
 
144
 
124
	if(title == NULL) title = rv_strdup("");
145
	if(title == NULL) title = rv_strdup("");
125
	if(desc == NULL) desc = rv_strdup("");
146
	if(desc == NULL) desc = rv_strdup("");
126
	if(page == NULL) page = rv_strdup("");
147
	if(page == NULL) page = rv_strdup("");
-
 
148
	if(nav == NULL) nav = rv_strdup("");
127
	render_stuff();
149
	render_stuff();
128
	free(page);
150
	free(page);
129
	free(desc);
151
	free(desc);
130
	free(title);
152
	free(title);
-
 
153
	free(nav);
131
}
154
}
132
 
155
 
133
char* escape(const char* str) {
156
char* escape(const char* str) {
134
	char* r = malloc(1);
157
	char* r = malloc(1);
135
	r[0] = 0;
158
	r[0] = 0;
Line 322... Line 345...
322
	add_data(&buffer, "		</div>\n");
345
	add_data(&buffer, "		</div>\n");
323
	add_data(&buffer, "		<div id=\"content\">\n");
346
	add_data(&buffer, "		<div id=\"content\">\n");
324
	add_data(&buffer, "			<div id=\"pageindex\">\n");
347
	add_data(&buffer, "			<div id=\"pageindex\">\n");
325
	add_data(&buffer, "				<h3>Page Menu</h3>\n");
348
	add_data(&buffer, "				<h3>Page Menu</h3>\n");
326
	add_data(&buffer, "				<ul>\n");
349
	add_data(&buffer, "				<ul>\n");
-
 
350
	add_data(&buffer, nav);
327
	add_data(&buffer, "				</ul>\n");
351
	add_data(&buffer, "				</ul>\n");
328
	add_data(&buffer, "			</div>\n");
352
	add_data(&buffer, "			</div>\n");
329
	add_data(&buffer, "			<div id=\"pagecontent\">\n");
353
	add_data(&buffer, "			<div id=\"pagecontent\">\n");
330
	add_data(&buffer, page);
354
	add_data(&buffer, page);
331
	add_data(&buffer, "				<div class=\"fixfloat\"></div>\n");
355
	add_data(&buffer, "				<div class=\"fixfloat\"></div>\n");