summaryrefslogtreecommitdiff
path: root/cite.c
diff options
context:
space:
mode:
Diffstat (limited to 'cite.c')
-rw-r--r--cite.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/cite.c b/cite.c
index 6c9852b..d131f4f 100644
--- a/cite.c
+++ b/cite.c
@@ -22,13 +22,21 @@ typedef struct {
Movie movies[64] = {0};
CURL *curl = NULL;
-static void print_style(void)
+static void print_style(int boring_css)
{
puts("<!DOCTYPE html>");
puts("<html>");
puts("<head>");
puts("<meta charset=\"UTF-8\">");
- puts("<link rel='stylesheet' type='text/css' href='https://kdx.re/theme.css'/>");
+ if (boring_css)
+ puts("<style>img{max-width: 100%;}body{margin:40px auto;"
+ "max-width:550px;line-height:1.6;font-size:18px;"
+ "font-family:sans-serif;color:#444;}h1,h2,h3{"
+ "line-height:1.2;padding-top: 14px;}</style>");
+ else
+ puts("<link rel='stylesheet' type='text/css' "
+ "href='https://kdx.re/theme.css'/>");
+ /* doq's style */
puts("</head>");
}
@@ -65,12 +73,16 @@ static void print_movie(Movie *movie, int hide_fr)
printf("\n");
}
-static void download_poster(Movie *movie)
+static void download_poster(Movie *movie, int skip)
{
char out_path[512];
char *last_slash = movie->poster;
while (strchr(last_slash, '/') != NULL)
last_slash = strchr(last_slash, '/') + 1;
+ if (skip) {
+ strcpy(movie->poster, last_slash);
+ return;
+ }
strcpy(out_path, "cite/");
strcat(out_path, last_slash);
FILE *const fp = fopen(out_path, "wb");
@@ -199,7 +211,7 @@ static int append_movie_times(Movie *movie, const xmlNode *node)
int main(int argc, char **argv)
{
- if (argc != 3)
+ if (argc != 5)
return 1;
xmlDoc *const document = xmlReadFile(argv[1], NULL, 0);
if (document == NULL) {
@@ -231,11 +243,11 @@ int main(int argc, char **argv)
append_movie_times(movie, mov);
}
}
- print_style();
+ print_style(atoi(argv[3]));
puts("<body>");
puts("<h1><a href=\"http://www.citebd.org/spip.php?film2912\">cinéma de la cité</a></h1>");
for (Movie *movie = movies; movie->id != 0; movie++) {
- download_poster(movie);
+ download_poster(movie, atoi(argv[4]));
print_movie(movie, atoi(argv[2]));
}
puts("</body>");