Create RAW-XHTML-Site

Ask questions about how to create a script or swap scripts with other users.
Post Reply
User avatar
Walti
Posts: 51
Joined: 06 Jul 2009 11:26
Location: Schweiz / Swiss / Swizerland
Contact:

Create RAW-XHTML-Site

Post by Walti »

A script which generates a raw-html/xhtml-Site.

Updatet 9.3.2010
if no Document is open, then the script create e new one before execute

Updatet 9.2.2010
- add new translations is more simply then before
- new radio-buttons to select Doctype
- new Polish translation (thx pjj)

Updatet 18.6.2010
- some more Dublin-Core-Tags

If you wonder what the javascript ie(x).js in the generatet code is:
This script makes most of css-tags for ms-browsers compatible to the w3c-standart and is verry usefull.
More Information about this can you find here


Feel free to use and change it at your pourpose:

Code: Select all

/*=======================================================*/
/*==           C++ - Script for RJTextEd               ==*/
/*==---------------------------------------------------==*/
/*==            Generate xhtml raw-code                ==*/
/*==---------------------------------------------------==*/
/*== Author   : Walti Zubler, www.zubleredv.ch         ==*/
/*== Version : 2010-06-18  Version  2.2                ==*/
/*=======================================================*/

TForm   f;                   // Input-form
TButton DoIt;                // Execute Input-Form Send-Button

TGroupbox g;
TRadioButton html_trans, html_strict, xhtml_trans, xhtml_strict;

TLabel title_label;      TMemo title_text;
TLabel author_label;     TMemo author_text;
TLabel copy_label;       TMemo copy_text;
TLabel abstract_label;   TMemo abstract_text;
TLabel descript_label;   TMemo descript_text;
TLabel audience_label;   TMemo audience_text;
TLabel pagetype_label;   TMemo pagetype_text;
TLabel pagetopic_label;  TMemo pagetopic_text;
TLabel keywords_label;   TMemo keywords_text;

TRJDocument d;

string template_string;
int actual_top, left_margin1, left_margin2, input_width, tmp;

string xhtml = " /";
string doctype;

string lang_name;                 // Aktuelle Sprachdatei
int    lang_ix;

int    msg_button   = 0, msg_titel    = 1, msg_author   = 2, msg_copyright = 3, msg_abstract = 4,
       msg_descript = 5, msg_audience = 6, msg_pagetype = 7, msg_pagetopic = 8, msg_keywords = 9;

string msg[10][10];

void gen_msg()
{
  lang_name = MainApp.GetCurrentLanguageFileName();
  if      (lang_name == "Deutsch.ini") lang_ix = 1;      // German
  else if (lang_name == "Polish.ini")  lang_ix = 2;      // Polish
  else                                 lang_ix = 0;      // All undefined handle as English

  //  msg[x][0]  = English     1 = German     2 = Polish

  msg[msg_button][0]     = "Generate";
  msg[msg_button][1]     = "Generieren";
  msg[msg_button][2]     = "Generate";

  msg[msg_titel][0]      = "<title>....</title>  The title of the website";
  msg[msg_titel][1]      = "<title>....</title>  Der Titel der Webseite";
  msg[msg_titel][2]      = "<title>....</title>  tytul tej strony";

  msg[msg_author][0]     = "author:  company/name of programmer";
  msg[msg_author][1]     = "author:  Firma/Name des Programmierers der Webseite";
  msg[msg_author][2]     = "author:  nazwisko autora albo nazwa agencji webowej";

  msg[msg_copyright][0]  = "copyright+publisher:  the owner/editor of the website (customer)";
  msg[msg_copyright][1]  = "copyright+publisher:  der Inhaber/Herausgeber der Webseite (Kunde)";
  msg[msg_copyright][2]  = "copyright+publisher:  copyright+nazwa instytucji, bedacej wlascicielem lub edytorem serwisu";

  msg[msg_abstract][0]   = "abstract:  short description of the website's content, which is similar to the title-tags of the content";
  msg[msg_abstract][1]   = "abstract:  Kurze Beschreibung des Inhaltes der Webseite, ist dem Inhalt des title-Tags ähnlich";
  msg[msg_abstract][2]   = "abstract:  krótki opis zawartosci strony, podobny do tagu <title> tej konkretnej strony";

  msg[msg_descript][0]   = "description:  short description of the content(150 characters/25 words max.) do not use the words from the title-tag if possible!";
  msg[msg_descript][1]   = "description:  Kurze Beschreibung des Inhaltes (150 Zeichen/25 Wörter max.) möglichst keine Wörter aus dem title-Tag verwenden!";
  msg[msg_descript][2]   = "description:  krótki opis zawartosci (maks. 150 znaków lub 25 slów); jesli to mozliwe, nie uzywaj slów z tagu <title>";

  msg[msg_audience][0]   = "audience:  targetgroup, seperate multiple entries with commas. for example: All,beginner,advanced,students, and etc.";
  msg[msg_audience][1]   = "audience:  Zielgruppe, Mehrfacheinträge durch Komma trennen. z.B. Alle,Anfänger,Fortgeschrittene,Studenten,etc.";
  msg[msg_audience][2]   = "audience:  grupa docelowa, do której kierowany jest serwis; wpisy oddzielaj przecinkami, np. wszyscy, poczatkujacy, zaawansowani, studenci itp.";

  msg[msg_pagetype][0]   = "pagetype:  type of website, seperate multiple entries with commas. for example, Instructions,Webshop,Linklists, and etc.";
  msg[msg_pagetype][1]   = "pagetype:  Typ der Webseite, Mehrfacheinträge durch Komma trennen. z.B. Anleitung,Webshop,Linkliste,etc.";
  msg[msg_pagetype][2]   = "pagetype:  typ zawartosci strony, wpisy oddzielaj przecinkami, np. instrukcje, sklep internetowy, katalog stron, itp.";

  msg[msg_pagetopic][0]  = "pagetopic:  Theme of page, seperate multiple entries with commas. for example, General consumer,architecture,car, and etc.";
  msg[msg_pagetopic][1]  = "pagetopic:  Thema der Seite, Mehrfacheinträge durch Komma trennen. z.B. Allgemeine Konsumgüter,Architektur,Audio, etc.";
  msg[msg_pagetopic][2]  = "pagetopic:  tematyka strony, wpisy oddzielaj przecinkami, np. fotografia, architektura, samochody itp.";

  msg[msg_keywords][0]   = "keywords:  precise, exclusive, not too less not too much !";
  msg[msg_keywords][1]   = "keywords:  Schlüsselwörter, präzise, exklusive, nicht zu wenig nicht zu viel !";
  msg[msg_keywords][2]   = "keywords:  slowa kluczowe, frazy kluczowe, precyzyjne, nie za duzo, nie za malo";

}

void gen_doctype()
{
  if (html_trans.Checked)
    {
      xhtml = "";
      doctype =  "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/TR/html4/loose.dtd\">\r\n";
    }
  else if (html_strict.Checked)
    {
      xhtml = "";
      doctype =  "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\r\n";
    }
  else if (xhtml_trans.Checked)
    {
      xhtml = " /";
      doctype =  "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n";
      doctype += "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"de\" lang=\"de\">\r\n";
    }
  else
    {
      xhtml = " /";
      doctype =  "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n";
      doctype += "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"de\" lang=\"de\">\r\n";
    }
}

void gen_template_string()
{
  template_string = doctype;
  template_string += "<head>\r\n";
  template_string += "    <title>" + title_text.Lines[0] + "</title>\r\n";
  template_string += "    <meta http-equiv=\"content-type\" content=\"application/xhtml+xml; charset=iso-8859-1\""+xhtml+">\r\n";
  template_string += "    <meta http-equiv=\"content-language\" content=\"de\""+xhtml+">\r\n";
  template_string += "    <meta http-equiv=\"content-script-type\" content=\"text/javascript\""+xhtml+">\r\n";
  template_string += "    <meta http-equiv=\"content-style-type\" content=\"text/css\""+xhtml+">\r\n";
  template_string += "\r\n";
  template_string += "    <meta name=\"language\" content=\"de\""+xhtml+">\r\n";
  template_string += "    <meta name=\"abstract\" content=\"" + abstract_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "    <meta name=\"keywords\" content=\"" + keywords_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "    <meta name=\"description\" content=\"" + descript_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "    <meta name=\"author\" content=\"" + author_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "    <meta name=\"copyright\" content=\"" + copy_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "    <meta name=\"publisher\" content=\"" + copy_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "    <meta name=\"audience\" content=\""+ audience_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "    <meta name=\"page-type\" content=\"" + pagetype_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "    <meta name=\"page-topic\" content=\"" + pagetopic_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "\r\n";
  template_string += "    <meta name=\"DC.title\" content=\"" + title_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "    <meta name=\"DC.creator\" content=\"" + author_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "    <meta name=\"DC.publisher\" content=\"" + copy_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "    <meta name=\"DC.language\" content=\"de\" scheme=\"RFC3066\""+xhtml+">\r\n";
  template_string += "    <meta name=\"DC.coverage\" content=\"International\""+xhtml+">\r\n";
  template_string += "    <meta name=\"DC.rights\" content=\"" + copy_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "    <meta name=\"DC.description\" content=\"" + descript_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "    <meta name=\"DC.subject\" content=\"" + pagetopic_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "    <meta name=\"DC.type\" content=\"" + pagetype_text.Lines[0] + "\""+xhtml+">\r\n";
  template_string += "\r\n";
  template_string += "    <meta name=\"robots\" content=\"follow, index\""+xhtml+">\r\n";
  template_string += "    <meta name=\"revisit-after\" content=\"14 days\""+xhtml+">\r\n";
  template_string += "\r\n";
  template_string += "    <link href=\"css/bildschirm.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen, projection\""+xhtml+">\r\n";
  template_string += "\r\n";
  template_string += "    <link rel=\"shortcut icon\" href=\"favicon.ico\" type=\"image/x-icon\""+xhtml+">\r\n";
  template_string += "\r\n";
  template_string += "    <!--[if lt IE 9]>\r\n";
  template_string += "      <script src=\"http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js\" type=\"text/javascript\">IE7_PNG_SUFFIX='*.png';</script>\r\n";
  template_string += "    <![endif]-->\r\n";
  template_string += "\r\n";
  template_string += "</head>\r\n";
  template_string += "<body>\r\n";
  template_string += "\r\n";
  template_string += "  <div id=\"arbeitsflaeche\">\r\n";
  template_string += "\r\n";
  template_string += "  </div>  <!-- Ende arbeitsflaeche -->\r\n";
  template_string += "\r\n";
  template_string += "</body>\r\n";
  template_string += "</html>\r\n";
}

void gen_form()
{
   actual_top = 20;  left_margin1 = 20;  left_margin2 = 20;  input_width = 750;

   f = new TForm(nil);
   f.Caption = "HTML/XHTML - RAW-Code-Generator";
   f.BorderStyle = bsSizeable;
   f.Position = poScreenCenter;
   f.Width = 800;
   f.Height = 560;
}

void gen_form_title_input()
{
  title_label = new TLabel(f);       title_label.Parent = f;
  title_label.Left = left_margin1;   title_label.Top = actual_top;
  title_label.Caption = msg[msg_titel][lang_ix];

  title_text = new TMemo(f);       title_text.Parent = f;
  title_text.Left = left_margin2;  title_text.Top  = actual_top+15;
  title_text.Width = input_width;  title_text.Height = 20;
  title_text.MaxLength = 200;
}

void gen_form_author_input()
{
  author_label = new TLabel(f);       author_label.Parent = f;
  author_label.Left = left_margin1;   author_label.Top = actual_top;
  author_label.Caption = msg[msg_author][lang_ix];

  author_text = new TMemo(f);       author_text.Parent = f;
  author_text.Left = left_margin2;  author_text.Top  = actual_top+15;
  author_text.Width = input_width;  author_text.Height = 20;
  author_text.MaxLength = 200;
}

void gen_form_copy_input()
{
  copy_label = new TLabel(f);       copy_label.Parent = f;
  copy_label.Left = left_margin1;   copy_label.Top = actual_top;
  copy_label.Caption = msg[msg_copyright][lang_ix];

  copy_text = new TMemo(f);       copy_text.Parent = f;
  copy_text.Left = left_margin2;  copy_text.Top  = actual_top+15;
  copy_text.Width = input_width;  copy_text.Height = 20;
  copy_text.MaxLength = 200;
}

void gen_form_abstract_input()
{
  abstract_label = new TLabel(f);       abstract_label.Parent = f;
  abstract_label.Left = left_margin1;   abstract_label.Top = actual_top;
  abstract_label.Caption = msg[msg_abstract][lang_ix];

  abstract_text = new TMemo(f);       abstract_text.Parent = f;
  abstract_text.Left = left_margin2;  abstract_text.Top  = actual_top+15;
  abstract_text.Width = input_width;  abstract_text.Height = 20;
  abstract_text.MaxLength = 200;
}

void gen_form_descript_input()
{
  descript_label = new TLabel(f);       descript_label.Parent = f;
  descript_label.Left = left_margin1;   descript_label.Top = actual_top;
  descript_label.Caption = msg[msg_descript][lang_ix];

  descript_text = new TMemo(f);       descript_text.Parent = f;
  descript_text.Left = left_margin2;  descript_text.Top  = actual_top+15;
  descript_text.Width = input_width;  descript_text.Height = 20;
  descript_text.MaxLength = 200;
}

void gen_form_audience_input()
{
  audience_label = new TLabel(f);       audience_label.Parent = f;
  audience_label.Left = left_margin1;   audience_label.Top = actual_top;
  audience_label.Caption = msg[msg_audience][lang_ix];

  audience_text = new TMemo(f);       audience_text.Parent = f;
  audience_text.Left = left_margin2;  audience_text.Top  = actual_top+15;
  audience_text.Width = input_width;  audience_text.Height = 20;
  audience_text.MaxLength = 200;
}

void gen_form_pagetype_input()
{
  pagetype_label = new TLabel(f);       pagetype_label.Parent = f;
  pagetype_label.Left = left_margin1;   pagetype_label.Top = actual_top;
  pagetype_label.Caption = msg[msg_pagetype][lang_ix];

  pagetype_text = new TMemo(f);       pagetype_text.Parent = f;
  pagetype_text.Left = left_margin2;  pagetype_text.Top  = actual_top+15;
  pagetype_text.Width = input_width;  pagetype_text.Height = 20;
  pagetype_text.MaxLength = 200;
}

void gen_form_pagetopic_input()
{
  pagetopic_label = new TLabel(f);       pagetopic_label.Parent = f;
  pagetopic_label.Left = left_margin1;   pagetopic_label.Top = actual_top;
  pagetopic_label.Caption = msg[msg_pagetopic][lang_ix];

  pagetopic_text = new TMemo(f);       pagetopic_text.Parent = f;
  pagetopic_text.Left = left_margin2;  pagetopic_text.Top  = actual_top+15;
  pagetopic_text.Width = input_width;  pagetopic_text.Height = 20;
  pagetopic_text.MaxLength = 200;
}

void gen_form_keywords_input()
{
  keywords_label = new TLabel(f);       keywords_label.Parent = f;
  keywords_label.Left = left_margin1;   keywords_label.Top = actual_top;
  keywords_label.Caption = msg[msg_keywords][lang_ix];

  keywords_text = new TMemo(f);       keywords_text.Parent = f;
  keywords_text.Left = left_margin2;  keywords_text.Top  = actual_top+15;
  keywords_text.Width = input_width;  keywords_text.Height = 20;
  keywords_text.MaxLength = 1000;
}

void gen_form_codetype()
{
  g = new TGroupBox(f);    g.Name = "gOptions";
  g.Parent = f;            g.SetBounds(10, actual_top, 770, 50);
  g.Anchors = akLeft+akTop;
  g.Caption = " Doctype: ";

  html_trans = new TRadioButton(g);
  html_trans.Name = "html_trans";  html_trans.Parent = g;
  html_trans.Left = 80;  html_trans.Top = 20;  html_trans.Width = 150;
  html_trans.Anchors = akLeft+akTop;
  html_trans.Caption = "HTML Transitional";

  html_strict = new TRadioButton(g);
  html_strict.Name = "html_strict";  html_strict.Parent = g;
  html_strict.Left = 230;  html_strict.Top = 20;  html_strict.Width = 150;
  html_strict.Anchors = akLeft+akTop;
  html_strict.Caption = "HTML Strict";

  xhtml_trans = new TRadioButton(g);
  xhtml_trans.Name = "xhtml_trans";  xhtml_trans.Parent = g;
  xhtml_trans.Left = 380;  xhtml_trans.Top = 20;  xhtml_trans.Width = 150;
  xhtml_trans.Anchors = akLeft+akTop;
  xhtml_trans.Caption = "XHTML Transitional";

  xhtml_strict = new TRadioButton(g);
  xhtml_strict.Name = "xhtml_strict";  xhtml_strict.Parent = g;
  xhtml_strict.Left = 520;  xhtml_strict.Top = 20;  xhtml_strict.Width = 150;
  xhtml_strict.Anchors = akLeft+akTop;
  xhtml_strict.Caption = "XHTML Strict";

  xhtml_trans.Checked = True;
}

void ButtonClick(TButton Sender)        // Start Code-Generation
{
       int fehler = 0;

  gen_doctype();
  gen_template_string();
  d.InsertText(template_string);
  f.ModalResult = mrOk;
}

{
  if (MainApp.DocumentCount == 0)   {   MainApp.NewDocument("html");   }
  gen_msg();
  gen_form();
  gen_form_title_input();     actual_top += 45;
  gen_form_author_input();    actual_top += 45;
  gen_form_copy_input();      actual_top += 45;
  gen_form_abstract_input();  actual_top += 45;
  gen_form_descript_input();  actual_top += 45;
  gen_form_audience_input();  actual_top += 45;
  gen_form_pagetype_input();  actual_top += 45;
  gen_form_pagetopic_input(); actual_top += 45;
  gen_form_keywords_input();  actual_top += 45;
  gen_form_codetype();        actual_top += 65;

  //-------------------------------------
  // Execute input-Button
  DoIt = new TButton(f);
  DoIt.Name = "btnGo";
  DoIt.Parent = f;
  DoIt.Left = 300;
  DoIt.Top = actual_top;
  DoIt.Width = 100;
  DoIt.Caption = msg[msg_button][lang_ix];
  DoIt.OnClick = &ButtonClick;

  // Show and handle the Input-Form
  f.ShowModal;
  f.Free;
}
Open a blank html- or php-file and run the script.
Hope it is useful for usage and as script-demo.

pm or mail me translations if you have made one, and i will publish it here.

Happy programming, Walti
Last edited by Walti on 18 Jun 2010 01:05, edited 11 times in total.
User avatar
Walti
Posts: 51
Joined: 06 Jul 2009 11:26
Location: Schweiz / Swiss / Swizerland
Contact:

Other Languages

Post by Walti »

It would be nice if other programmers/webdesigners would add other languages to this script and serve it here for the community
User avatar
pjj
Posts: 2109
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Post by pjj »

Wow! You use Dublin Core! I'm impressed, really! :D (I checked your website BTW. Almost every page validates. Chapeau bas! [I'm a standardista myself as well, you see :) ])
User avatar
Walti
Posts: 51
Joined: 06 Jul 2009 11:26
Location: Schweiz / Swiss / Swizerland
Contact:

Post by Walti »

@pjj

THX for the Flowers :)

I had completely rewritten my page during the last 3 weeks, and now all is even more validate then before :)

Ok, i made use of PopBox on Images and some Entrys for the use of this are not Valide and in CSS i use box-shadow and font-shadow, CSS3 tags which are also not valid for the current Css-Validator, and some online-games-objects are also not valide, but the rest is all valide :)

And of course i made the whole work with RJ TextED :)

I see you are from Polen, can you made the needed translation-additions for Polen for this script ?

Sorry at all for my bad english writing :)
User avatar
pjj
Posts: 2109
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Post by pjj »

Walti wrote:THX for the Flowers :)
Pleasure!
Walti wrote:I see you are from Polen, can you made the needed translation-additions for Polen for this script ?
I would have made it long ago, but somehow I missed the point completely. I just have done it and sent you in e-mail.
User avatar
pjj
Posts: 2109
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Post by pjj »

Help for other contributors:

title_label.Caption = The title of the website
author_label.Caption = author, company/name of programmer
copy_label.Caption = copyright+publisher, the owner/editor of the website (customer)
abstract_label.Caption = abstract, short description of the website's content, which is similar to the title-tags of the content
descript_label.Caption = description, short description of the content(150 characters/25 words max.) do not use the words from the title-tag if possible!
audience_label.Caption = audience, targetgroup, seperate multiple entries with commas. for example, All,beginner,advanced,students, and etc.
pagetype_label.Caption = pagetype, type of website, seperate multiple entries with commas. for example, Instructions,Webshop,Linklists, and etc.
pagetopic_label.Caption = pagetopic, Theme of page, seperate multiple entries with commas. for example, General consumer,architecture,car, and etc.
keywords_label.Caption = keywords, passwords, precise, exclusive, not too less not too much!
User avatar
Walti
Posts: 51
Joined: 06 Jul 2009 11:26
Location: Schweiz / Swiss / Swizerland
Contact:

Post by Walti »

I have updatet the script today

- add new translations is more simply then before
- new radio-buttons to select Doctype
- new Polish translation (thx pjj)

you can find the actual code in the first post in this treath.
User avatar
Walti
Posts: 51
Joined: 06 Jul 2009 11:26
Location: Schweiz / Swiss / Swizerland
Contact:

Post by Walti »

I have updatet the script today

- Some more Dublin-Core-Metas added.

you can find the actual code in the first post in this treath.

It would be great if some of you can send me translations for aditional languages for this script.
:)

Happy Programming
Walti
Post Reply