Re: [Echo ]Recreating the Status Pages once again

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2007-09-29 at 18:08 +0200, Martin Sourada wrote:
> Hi,
> 
> I was going through the Trac help in search of table styling
> capabilities of its wiki to improve the Icon Theme Status page [1]. In
> the process I came to a conclusion it would be better to include the
> tables as raw HTML and that it would be better to split the status page
> to more pages. And because the icon naming specifications [2] are
> subject to change (in the meaning that new icons can be added) as well
> as the icons that are created in addition to the specs and because I am
> a little bit lazy, I decided to create a c app that reads list of icons
> (provided in a file) and outputs a nicely formatted table in HTML code
> to standard output. My C skills are nothing fancy and I didn't take much
> thoughts to the algorithm so it is rather just-works type of code...
> 
> I put together an example page including the table generated by the code
> [3].
> 
> The advantages of the new page are better styling capabilities, easier
> adding/removing of new icons (in the original, addition of new icon into
> the middle of the table would be a lot of work) and automatic picking of
> icons from git (if icon is not present, '-' is displayed). It also
> displays 16x16, 22x22, 32x32 and 48x48 icons. One disadvantage is that
> it contains broken links to SVGs that are not in git yet...
> 
> And I attach the c code (in case someone would like to improve it). It
> uses nothing outside the standard libraries, so that you can build it
> just with gcc generate-status-table.c
> 
> Any thoughts, comments, etc.? I can push the source to git if there is a
> want (might be good to push icon lists to it as well) for it and create
> the rest of the pages.
> 
> Thanks,
> Martin
> 
> References:
> [1]
> https://hosted.fedoraproject.org/projects/echo-icon-theme/wiki/IconThemeStatus
> [2]
> http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
> [3]
> https://hosted.fedoraproject.org/projects/echo-icon-theme/wiki/IconThemeStatus/Actions
> 
oooh, I've just discovered I made a mistake... I hardcoded the category
into it... I attach fixed source file. I discovered it during recreating
the rest of the pages. Will let you know when I am finished with
recreating the things that are in specs.

Martin

#include <stdio.h>

#define COLS 5

int process_table (char *input, char *category)
{
//	printf ("%s\n\n", input);

	FILE *fi;
	int i, j;
	char icon_name [COLS][256];
	int aux;
	
	fi = fopen (input, "r");
	if (!fi) 
	{
		fprintf(stderr, "Unable to open input file: %s.\n", input);
		return -1;
	}

	i = 0;

	printf ("<table style=\"border:  none 0;width: 100%; text-align: center;\">\n");	

	do 
	{
		if (i == COLS)
		{
			printf ("\t<tr>\n");
			i = 0;
			for (j = 0; j < COLS; j++)
			{
				printf ("\t\t<td>\n");
				
				printf ("\t\t\t<img src=\"http://git.fedoraproject.org/?p=hosted/echo-icon-theme;a=blob_plain;f=trunk/Echo/16x16/%s/%s.png;hb=HEAD\"; width=\"16px\" height=\"16px\" alt=\"-\"/>\n", category, icon_name[j]);					
				printf ("\t\t\t<img src=\"http://git.fedoraproject.org/?p=hosted/echo-icon-theme;a=blob_plain;f=trunk/Echo/22x22/%s/%s.png;hb=HEAD\"; width=\"22px\" height=\"22px\" alt=\"-\"/>\n", category, icon_name[j]);					
				printf ("\t\t\t<img src=\"http://git.fedoraproject.org/?p=hosted/echo-icon-theme;a=blob_plain;f=trunk/Echo/32x32/%s/%s.png;hb=HEAD\"; width=\"32px\" height=\"32px\" alt=\"-\"/>\n", category, icon_name[j]);					
				printf ("\t\t\t<img src=\"http://git.fedoraproject.org/?p=hosted/echo-icon-theme;a=blob_plain;f=trunk/Echo/48x48/%s/%s.png;hb=HEAD\"; width=\"48px\" height=\"48px\" alt=\"-\"/>\n", category, icon_name[j]);					
				
				printf ("\t\t</td>\n");
			}
			printf ("\t</tr>\n");

			printf ("\t<tr>\n");
			for (j = 0; j < COLS; j++)
			{
				printf ("\t\t<td>\n");
				
				printf ("\t\t\t<a href=\"http://git.fedoraproject.org/?p=hosted/echo-icon-theme;a=blob_plain;f=trunk/Echo/scalable/%s/%s.svg;hb=HEAD\";>%s</a>", category, icon_name[j], icon_name[j]);
			
				printf ("\t\t</td>\n");
			}
			printf ("\t</tr>\n");
			printf ("\t<tr style=\"height: 2em;\"></tr>\n\n");
		}
//		aux = fgetc (fi);
//		printf ("%d", aux);
		fscanf (fi, "%s", icon_name[i]);
		aux = fgetc (fi);
//		printf ("%s\n", icon_name);
		i++;
		
	} while (!(aux == -1));

	i--;
	printf ("\t<tr>\n");
	for (j = 0; j < i; j++)
	{
		printf ("\t\t<td>\n");
		
		printf ("\t\t\t<img src=\"http://git.fedoraproject.org/?p=hosted/echo-icon-theme;a=blob_plain;f=trunk/Echo/16x16/%s/%s.png;hb=HEAD\"; width=\"16px\" height=\"16px\" alt=\"-\"/>\n", category, icon_name[j]);					
		printf ("\t\t\t<img src=\"http://git.fedoraproject.org/?p=hosted/echo-icon-theme;a=blob_plain;f=trunk/Echo/22x22/%s/%s.png;hb=HEAD\"; width=\"22px\" height=\"22px\" alt=\"-\"/>\n", category, icon_name[j]);					
		printf ("\t\t\t<img src=\"http://git.fedoraproject.org/?p=hosted/echo-icon-theme;a=blob_plain;f=trunk/Echo/32x32/%s/%s.png;hb=HEAD\"; width=\"32px\" height=\"32px\" alt=\"-\"/>\n", category, icon_name[j]);					
		printf ("\t\t\t<img src=\"http://git.fedoraproject.org/?p=hosted/echo-icon-theme;a=blob_plain;f=trunk/Echo/48x48/%s/%s.png;hb=HEAD\"; width=\"48px\" height=\"48px\" alt=\"-\"/>\n", category, icon_name[j]);					
		
		printf ("\t\t</td>\n");
	}
	printf ("\t</tr>\n");

	printf ("\t<tr>\n");
	for (j = 0; j < i; j++)
	{
		printf ("\t\t<td>\n");
		
		printf ("\t\t\t<a href=\"http://git.fedoraproject.org/?p=hosted/echo-icon-theme;a=blob_plain;f=trunk/Echo/scalable/%s/%s.svg;hb=HEAD\";>%s</a>", category, icon_name[j], icon_name[j]);
	
		printf ("\t\t</td>\n");
	}
	printf ("\t</tr>\n");
	printf ("\t<tr style=\"height: 2em;\"></tr>\n\n");


	printf ("</table>\n");
	fclose (fi);

	return 0;
}

int main(int argc, char *argv[])
{
	char *input;
	char *category;
	if (argc < 3)
	{
		fprintf(stderr, "Missing argument!\nUsage: generate-status-table <input-file> <category>\n");
		return (1);
	}
	input = argv[1];
	category = argv[2];
	int i = process_table (input,category);

	return i;
}

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Fedora-art-list mailing list
Fedora-art-list@xxxxxxxxxx
http://www.redhat.com/mailman/listinfo/fedora-art-list

[Index of Archives]     [Fedora Music]     [Fedora Development]     [Linux Kernel]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Directory]     [PAM]     [Big List of Linux Books]     [Gimp]     [Yosemite News]

  Powered by Linux