aboutsummaryrefslogtreecommitdiff
path: root/wiki.c
diff options
context:
space:
mode:
authorthe little girl <yui@blekksprut.net>2014-09-05 20:29:17 +0900
committerthe little girl <yui@blekksprut.net>2014-09-05 20:29:17 +0900
commita484c4e818bef249a8af571a0f0725bd9d128ff9 (patch)
tree6d9b20c65897c992fac9e4decebe3097bc7e7b8c /wiki.c
parent104dfc911b9ddb984fd6f9c0886b174b03208850 (diff)
downloadukulele-a484c4e818bef249a8af571a0f0725bd9d128ff9.tar.xz
fikse litt og litt
Diffstat (limited to 'wiki.c')
-rw-r--r--wiki.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/wiki.c b/wiki.c
index f30c6c3..bfb384a 100644
--- a/wiki.c
+++ b/wiki.c
@@ -39,12 +39,14 @@ void head(char *page, char *link, char *what) {
printf("<title>%s · %s</title>\n", title, page);
printf("<link rel='stylesheet' type='text/css' href='%s/wiki.css'>\n", base);
printf("<script src='%s/wiki.js'></script>\n", base);
+ printf("<h1>");
if(link && what && !strcmp(what, "rediger"))
- printf("<h1><a data-text='%s' href='%s'>%s</a></h1>\n", what, link, page);
+ printf("<a data-text='%s' href='%s'>%s</a>", what, link, page);
else if(link && what)
- printf("<h1><a data-text='%s' href='%s/%s'>%s</a></h1>\n", what, base, link, page);
+ printf("<a data-text='%s' href='%s/%s'>%s</a>", what, base, link, page);
else
- printf("<h1>%s</h1>\n", page);
+ printf("%s", page);
+ printf("</h1>\n");
}
void foot(int file) {
@@ -57,18 +59,14 @@ void foot(int file) {
printf("<a href='%s/%s'>%s</a> ", script, links[i][1], links[i][0]);
}
if(!file) return;
- printf("<span style='float: right'>");
- printf("%s ", id);
- printf("<a href='?t'>text/plain</a>");
- printf("</span>\n");
+ printf("<span class='f'>%s <a href='?t'>text/plain</a></span>\n", id);
}
char *clean(char *p) {
char *dup = strdup(basename(p));
char *x = dup;
while(*x) {
- if(*x == '-')
- *x = ' ';
+ if(*x == '-') *x = ' ';
x++;
}
return dup;
@@ -79,6 +77,7 @@ int legit(char *page) {
if(!strcmp(page, "/")) return 0;
if(strstr(page, "..")) return 0;
if(strcspn(page, badchars) < strlen(page)) return 0;
+ // strlen(page)
return 1;
}
@@ -91,17 +90,18 @@ int problem(int status, char *message) {
int redirect(char *path) {
printf("Status: 303\n");
- if(*path == '?')
- printf("Location: %s\n\n", path);
- else
- printf("Location: %s/%s\n\n", script, path);
+ switch(*path) {
+ case '?': printf("Location: %s\n\n", path); break;
+ // case '#':
+ default: printf("Location: %s/%s\n\n", script, path); break;
+ }
return 0;
}
int unauthorized(int status) {
printf("Status: %d\n", status);
if(status == 401)
- printf("WWW-Authenticate: Basic realm='Kya'\n");
+ printf("WWW-Authenticate: Basic realm='%s'\n", realm);
printf("Content-Type: text/plain; charset=utf-8\n\n");
printf("No.\n");
return 1;
@@ -128,17 +128,17 @@ int edit(char *path) {
return 0;
}
+// v fæl
int store(char *raw, int len) {
char *dir = dirname(strdup(raw));
char *id = basename(strdup(raw));
if(chdir(dir))
return problem(404, "Not found");
char path[strlen(id) + strlen(loft) + 256];
- time_t epoch = time(NULL);
- snprintf(path, 512, "%s/%s.%d", loft, id, (int) epoch);
+ int epoch = time(NULL);
+ snprintf(path, strlen(id) + strlen(loft) + 256, "%s/%s.%d", loft, id, epoch);
FILE *fp = fopen(path, "w");
- if(!fp) return redirect("FFFF");
-
+ if(!fp) return redirect("#");
int pos = 0;
unsigned int decoded;
char buffer[3] = { 0 };