Skip to content

Commit

Permalink
[ICU-4358] Change to use HTML templates
Browse files Browse the repository at this point in the history
X-SVN-Rev: 17668
  • Loading branch information
grhoten committed May 24, 2005
1 parent 309a2e3 commit bc81d79
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ XMLConverter/samples/x.xml -text svneol=unset#text/xml
apputil/data/common-footer.html svneol=native#text/html
apputil/data/common-leftnav.html svneol=native#text/html
apputil/data/common-masthead.html svneol=native#text/html
idnbrowser/idna-header.html svneol=native#text/html
locexp/resource/fr/displayproblems.gif -text
locexp/resource/fr/explore.gif -text
locexp/resource/fr/lx.jpg -text svneol=unset#image/jpeg
Expand Down Expand Up @@ -119,6 +120,7 @@ locexp/resource/zh_SG/displayproblems.gif -text
locexp/resource/zh_SG/dp.gif -text
locexp/resource/zh_SG/explore.gif -text
locexp/resource/zh_TW.txt -text
nbrowser/normalization-header.html svneol=native#text/html
scompare/scompare-content-templ.html svneol=native#text/html
scompare/scompare-page-templ.html svneol=native#text/html
scompare/scompare.html svneol=native#text/html
Expand Down
26 changes: 26 additions & 0 deletions idnbrowser/idna-header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<link rel="schema.DC" href="http://purl.org/DC/elements/1.0/"/>
<link rel="SHORTCUT ICON" href="http://www.ibm.com/favicon.ico"/>
<meta name="Description" content="Internationalized Domain Name Algorithm (IDNA) demonstration using the ICU Unicode support library"/>
<meta name="IBM.Country" content="ZZ"/>
<meta name="DC.Date" scheme="iso8601" content="2005-02-01"/>
<meta name="Source" content="v14 Template Generator, Template 14.7"/>
<meta name="DC.Type" scheme="IBM_ContentClassTaxonomy" content="ZZ999"/>
<meta name="Abstract" content="Unicode IDNA demonstration using the ICU Unicode support library"/>
<meta name="Keywords" content="unicode, ICU, IDN, nameprep, stringprep, punycode, RFC 3490, software, C, C++, Java, globalization, library, IBM"/>
<meta name="DC.Subject" scheme="IBM_SubjectTaxonomy" content="SW700"/>
<meta name="DC.Language" scheme="rfc1766" content="en"/>
<meta name="Security" content="Public"/>
<meta name="IBM.Industry" scheme="IBM_IndustryTaxonomy" content="ZZ"/>
<meta name="Robots" content="index,nofollow"/>
<meta name="DC.Publisher" content="IBM Corporation - Software Group - Globalization Center of Competency (GCoC) - ICU Department"/>
<meta name="IBM.Effective" scheme="W3CDTF" content="2005-01-38"/>
<meta name="Owner" content="Icu Intl/Cupertino/IBM@IBMUS"/>
<meta name="DC.Rights" content="Copyright (c) 2005 by IBM Corporation"/>
<title>IBM ICU IDNA Demo</title>
<link rel="stylesheet" type="text/css" href="//www.ibm.com/common/v14/main.css" />
<link rel="stylesheet" type="text/css" media="all" href="//www.ibm.com/common/v14/screen.css" />
<link rel="stylesheet" type="text/css" media="print" href="//www.ibm.com/common/v14/print.css" />
<script src="//www.ibm.com/common/v14/detection.js" language="JavaScript" type="text/javascript">
</script>
2 changes: 2 additions & 0 deletions nbrowser/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ TARGET = nbrowser
#LDFLAGS += -L../locexp/util -liculxutil $(LDFLAGS_USTDIO)
#LDFLAGS += $(LDFLAGS_TOOLUTIL)
CPPFLAGS += -I$(ICU_SOURCE)/common
CPPFLAGS += -I$(top_srcdir)/apputil

# ICULIBS includes all standard ICU libraries.
# if we wanted only part of the ICU, we could use (for example) just '$(LIBS) -licuuc -lusort' ...
Expand Down Expand Up @@ -52,6 +53,7 @@ install-local: all-local install-target
install-target: all-local
$(MKINSTALLDIRS) $(BINDIR)
$(INSTALL) $(TARGET) $(BINDIR)/$(TARGET)
$(INSTALL) normalization-header.html $(BINDIR)/data

dist-local:

Expand Down
68 changes: 57 additions & 11 deletions nbrowser/nbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
* This code works only if compiled and run with an ASCII-based charset!
*/

#ifndef ICU_URL
# define ICU_URL "http://ibm.com/software/globalization/icu"
#endif

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Expand All @@ -33,22 +29,28 @@
#include "unicode/unistr.h"
#include "unicode/unorm.h"
#include "unormimp.h" // ### TODO internal file, for normalization prototype
#include "demo_settings.h"

#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))

static const char *htmlHeader=
"Content-Type: text/html; charset=utf-8\n"
"\n"
"<html lang=\"en-US\">\n"
"<head>\n"
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"
"<title>Normalization Browser</title>\n"
"<head>\n";

static const char endHeaderBeginBody[] =
"</head>\n"
"<body>\n"
"<a href=\"" ICU_URL "\">ICU</a> &gt;\n"
"<a href=\"" ICU_URL "/chartsdemostools.jsp\">Demo</a> &gt;<br>\n"
"<body>\n";

static const char breadCrumbMainHeader[]=
DEMO_BREAD_CRUMB_BAR
"<h1>Normalization Browser</h1>\n";

static const char defaultHeader[]=
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"
"<title>Normalization Browser</title>\n";

static const char *htmlFooter=
"</body>";

Expand Down Expand Up @@ -282,6 +284,37 @@ parseString(const char *s,
}
}

/**
* @returns 1 if open failed
*/
static int printTemplateFile(char *templateFileName) {
size_t size = 0;
size_t savedPos;
char *buffer;
FILE *templateFile = fopen(templateFileName, "r");

if (templateFileName == NULL) {
printf("<!-- ERROR: %s cannot be opened -->", templateFileName);
return 1;
}

/* Go to the end, find the size, and go back to the beginning. */
savedPos = ftell(templateFile);
fseek(templateFile, 0, SEEK_END);
size = ftell(templateFile);
fseek(templateFile, savedPos, SEEK_SET);

/* Read in the whole file and print it out */
buffer = (char *)malloc(size+1);
fread(buffer, size, 1, templateFile);
buffer[size] = 0; // NULL terminate for printing.
printf("%s", buffer);

free(buffer);
fclose(templateFile);
return 0;
}

extern int
main(int argc, const char *argv[]) {
UChar input[100], buffer16[600]; // buffer16 should be 6 times longer than input for \\uhhhh
Expand All @@ -295,12 +328,22 @@ main(int argc, const char *argv[]) {

script=getenv("SCRIPT_NAME"); //"/cgi-bin/nbrowser"
puts(htmlHeader);
if (printTemplateFile(DEMO_COMMON_DIR "normalization-header.html")) {
puts(defaultHeader);
}
puts(endHeaderBeginBody);
printTemplateFile(DEMO_COMMON_MASTHEAD);
puts(DEMO_BEGIN_LEFT_NAV);
printTemplateFile(DEMO_COMMON_LEFTNAV);
puts(DEMO_END_LEFT_NAV);
puts(DEMO_BEGIN_CONTENT);
puts(breadCrumbMainHeader);

inputLength=options=0;
inputIsUTF8=FALSE;
errorCode=U_ZERO_ERROR;

if((cgi=getenv("QUERY_STRING"))!=NULL) {
if((cgi=getenv("QUERY_STRING"))!=NULL && cgi[0]!=0) {
// get input from cgi variable, e.g. t=a\\u0308%EA%B0%81&s=0061+0308&op1=on
const char *in;

Expand Down Expand Up @@ -381,6 +424,9 @@ main(int argc, const char *argv[]) {
u_versionToString(iv, ivString);
printf(versions, uvString, ivString);

puts(DEMO_END_CONTENT);
printTemplateFile(DEMO_COMMON_FOOTER);
puts(htmlFooter);

return 0;
}
27 changes: 27 additions & 0 deletions nbrowser/normalization-header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<link rel="schema.DC" href="http://purl.org/DC/elements/1.0/"/>
<link rel="SHORTCUT ICON" href="http://www.ibm.com/favicon.ico"/>
<meta name="Description" content="Unicode Normalization demonstration using the ICU Unicode support library"/>
<meta name="IBM.Country" content="ZZ"/>
<meta name="DC.Date" scheme="iso8601" content="2005-02-01"/>
<meta name="Source" content="v14 Template Generator, Template 14.7"/>
<meta name="DC.Type" scheme="IBM_ContentClassTaxonomy" content="ZZ999"/>
<meta name="Abstract" content="Unicode Normalization demonstration using the ICU Unicode support library"/>
<meta name="Keywords" content="unicode, normalization, NFC, NFD, NFKD, NFKC,
FCD, software, C, C++, Java, globalization, ICU, library, IBM"/>
<meta name="DC.Subject" scheme="IBM_SubjectTaxonomy" content="SW700"/>
<meta name="DC.Language" scheme="rfc1766" content="en"/>
<meta name="Security" content="Public"/>
<meta name="IBM.Industry" scheme="IBM_IndustryTaxonomy" content="ZZ"/>
<meta name="Robots" content="index,nofollow"/>
<meta name="DC.Publisher" content="IBM Corporation - Software Group - Globalization Center of Competency (GCoC) - ICU Department"/>
<meta name="IBM.Effective" scheme="W3CDTF" content="2005-01-38"/>
<meta name="Owner" content="Icu Intl/Cupertino/IBM@IBMUS"/>
<meta name="DC.Rights" content="Copyright (c) 2005 by IBM Corporation"/>
<title>IBM: ICU Demonstration - Normalization Browser</title>
<link rel="stylesheet" type="text/css" href="//www.ibm.com/common/v14/main.css" />
<link rel="stylesheet" type="text/css" media="all" href="//www.ibm.com/common/v14/screen.css" />
<link rel="stylesheet" type="text/css" media="print" href="//www.ibm.com/common/v14/print.css" />
<script src="//www.ibm.com/common/v14/detection.js" language="JavaScript" type="text/javascript">
</script>

0 comments on commit bc81d79

Please sign in to comment.