head 1.8; access; symbols; locks; strict; comment @ * @; 1.8 date 2005.06.03.19.09.35; author krh; state Exp; branches; next 1.7; commitid 629942a0aaec4567; 1.7 date 2004.10.13.18.24.11; author cworth; state Exp; branches; next 1.6; 1.6 date 2004.05.21.22.37.56; author pippin; state Exp; branches; next 1.5; 1.5 date 2004.05.21.16.09.41; author pippin; state Exp; branches; next 1.4; 1.4 date 2004.05.20.15.17.34; author pippin; state Exp; branches; next 1.3; 1.3 date 2004.05.20.15.06.38; author pippin; state Exp; branches; next 1.2; 1.2 date 2004.05.20.14.33.23; author pippin; state Exp; branches; next 1.1; 1.1 date 2004.05.18.21.54.57; author pippin; state Exp; branches; next ; desc @@ 1.8 log @2005-06-03 Kristian Høgsberg * cairo_snippets_html.c: Update html snippets. * snippets/pattern_fill.cairo: Remove this, was accidentally committed. @ text @/* html index generator for cairo_snippets * (c) Øyvind Kolås 2004, placed in the public domain */ #include "snippets.h" #define TEMPLATE_DIR "html/" #define OUTPUT_DIR "snippets/" void write_index (void); void write_all (void); void write_html (int snippet_no); static void embed_file (FILE *file, const char *filename); int main (int argc, char **argv) { int i; for (i=0;i\n"); /* if (active==-1) fprintf (file, "all <---
\n"); else fprintf (file, "all
\n"); */ for (i=0;i%s\n", snippet_name[i], snippet_name[i]); else fprintf (file, "
%s\n
", snippet_name[i], snippet_name[i]); } fprintf (file, "\n"); } void write_index(void) { FILE *file= fopen (OUTPUT_DIR "index.html", "w"); embed_file (file, TEMPLATE_DIR "header.html_template"); do_index (file, -2); embed_file (file, TEMPLATE_DIR "index.html_template"); embed_file (file, TEMPLATE_DIR "footer.html_template"); fclose (file); } void write_all(void) { int i=0; FILE *file= fopen (OUTPUT_DIR "snippets.html", "w"); embed_file (file, TEMPLATE_DIR "header.html_template"); fprintf (file, "

Renderings done using the cairo api, and their corresponding drawing instructions.

\n"); fprintf (file, "\n"); fprintf (file, "
"); for (i=0;i\n"); fprintf (file, "\n", name,name,name); fprintf (file, "
\n", name); fprintf (file, "
");

            while (*c){
                    switch (*c){
                        case '<':
                            fprintf (file, "<");
                            break;
                        case '>':
                            fprintf (file, ">");
                            break;
                        case '&':
                            fprintf (file, "&");
                            break;
                        default:
                            fprintf (file, "%c", *c);
                    }
                    c++;
            }

            fprintf (file, "       
\n"); fprintf (file, "

\n"); } fprintf (file, ""); embed_file (file, TEMPLATE_DIR "footer.html_template"); fclose (file); } void write_html(int snippet_no) { FILE *file; const char *name=snippet_name[snippet_no]; char htmlfile[1024]; sprintf (htmlfile, OUTPUT_DIR "%s.html", name); file = fopen (htmlfile, "w"); embed_file (file, TEMPLATE_DIR "header.html_template"); do_index (file, snippet_no); if (snippet_no>0) { fprintf (file, "\n", snippet_name [snippet_no-1]); } if (snippet_no+1next\n", snippet_name [snippet_no+1]); } { const char *c=&snippet_source[snippet_no][0]; fprintf (file, "
\n"); /*fprintf (file, "\n", name,name);*/ fprintf (file, "
\n", name); fprintf (file, "
");
            while (*c){
                    switch (*c){
                        case '<':
                            fprintf (file, "<");
                            break;
                        case '>':
                            fprintf (file, ">");
                            break;
                        case '&':
                            fprintf (file, "&");
                            break;
                        default:
                            fprintf (file, "%c", *c);
                    }
                    c++;
            }
            fprintf (file, "
\n"); fprintf (file, "
\n"); } embed_file (file, TEMPLATE_DIR "footer.html_template"); fclose (file); } static void embed_file (FILE *file, const char *filename) { FILE *input_file = fopen (filename, "r"); int read; char c; if (!input_file) { fprintf (stderr, "unable to read embedded file '%s'\n", filename); exit (-1); } while ((read=fread (&c, 1,1, input_file))){ switch (c){ default: fprintf (file, "%c", c); } } fclose (input_file); } @ 1.7 log @ * cairo_snippets_html.c (do_index): index() is a C library function, rename to do_index(). * Makefile: Add -g -Wall -O2, to get good warnings. * cairo_snippets_html.c prepare_snippets.c: Fix warnings. * cairo_snippets_png.c: Allow individual snippet names to be specified on the command line. @ text @d7 3 d47 1 a47 1 fprintf (file, "
 %s\n
", snippet_name[i], snippet_name[i]); d49 1 a49 1 fprintf (file, "
 %s\n
", d59 1 a59 1 FILE *file= fopen ("index.html", "w"); d61 1 a61 1 embed_file (file, "header.html_template"); d63 2 a64 2 embed_file (file, "index.html_template"); embed_file (file, "footer.html_template"); d72 1 a72 1 FILE *file= fopen ("snippets.html", "w"); d74 1 a74 1 embed_file (file, "header.html_template"); d108 1 a108 1 embed_file (file, "footer.html_template"); d120 1 a120 1 sprintf (htmlfile, "%s.html", name); d123 1 a123 1 embed_file (file, "header.html_template"); d163 1 a163 1 embed_file (file, "footer.html_template"); @ 1.6 log @finalized the changes to the snippets part of the website @ text @d32 1 a32 1 index(FILE *file, int active) a55 1 int i=0; d59 1 a59 1 index (file, -2); a76 2 FILE *srcfile; int size; d121 1 a121 1 index (file, snippet_no); a131 2 FILE *srcfile; int size; d179 1 a179 1 while (read=fread (&c, 1,1, input_file)){ @ 1.5 log @css2'ified the snippets webpage,. not quite content with the results yet @ text @d61 1 d73 1 a74 1 @ 1.4 log @*** empty log message *** @ text @d35 1 a35 1 fprintf (file, "

\n"); d37 1 a37 1 if (active==-1) d41 1 a41 1 d44 1 a44 1 fprintf (file, "%s <---
\n", snippet_name[i]); d46 1 a46 1 fprintf (file, "%s
\n", d50 1 a50 1 fprintf (file, "

\n"); a71 1 index (file, -1); d74 1 d81 4 a84 7 fprintf (file, "
\n"); fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); d106 1 a106 1 fprintf (file, "
\n"); fprintf (file, "

%s

\n", name,name,name); fprintf (file, "
\n");
d103 2
a104 6
            fprintf (file, "       
\n"); fprintf (file, " \n", name); fprintf (file, "
 
"); d123 10 a132 5 fprintf (file, ""); fprintf (file, "

"); fprintf (file, "\n"); d138 4 a141 8 fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); } fprintf (file, "
\n"); fprintf (file, "

%s

\n", name,name); fprintf (file, "
\n");

d158 1
d160 1
a160 11
            fprintf (file, "       
\n"); fprintf (file, " \n", name); fprintf (file, "
 

\n"); index (file, snippet_no); fprintf (file, "
"); d162 1 @ 1.3 log @further changes for single page/snippet for web @ text @d131 1 a131 4 fprintf (file, "
\n"); index (file, snippet_no); fprintf (file, "

"); d172 6 a177 1 fprintf (file, "

"); @ 1.2 log @various helping lines single html file for each snippet, preliminary browsing support @ text @d31 22 d60 1 a60 9 fprintf (file, "
    \n"); fprintf (file, "
  • all
  • \n"); for (i=0;i%s\n", snippet_name[i], snippet_name[i]); fprintf (file, "
\n"); a64 2 d72 1 a72 7 fprintf (file, "
    \n"); for (i=0;i%s\n", snippet_name[i], snippet_name[i]); fprintf (file, "
\n"); a129 1 fprintf (file, "

index"); d131 2 a132 4 if (snippet_no>0) fprintf (file, " prev(%s)", snippet_name[snippet_no-1], snippet_name[snippet_no-1]); else fprintf (file, ""); d134 1 a134 5 if (snippet_nonext(%s)", snippet_name[snippet_no+1], snippet_name[snippet_no+1]); else fprintf (file, ""); fprintf (file, "

\n"); d175 1 a175 1 fprintf (file, ""); @ 1.1 log @seperated the html generation from cairo_snippets_png @ text @d7 8 a14 3 /* write an snippets.html file, containing inline images, and source code */ int write_html (void); d23 5 a27 1 write_html (); d31 24 a54 2 int write_html(void) d59 1 a59 1 embed_file (file, "header.html"); a70 1 char imgname[40]; a73 1 sprintf (imgname, "%s.png", name); d77 70 a146 1 fprintf (file, "

%s

\n", name,name,name); d171 1 a171 1 fprintf (file, " \n", imgname); d177 1 a177 1 embed_file (file, "footer.html"); @