gambas-source-code/app/other/MakeWebSite/.src/MMain.module
Benoît Minisini b9b46f3873 [CONFIGURATION]
* NEW: Add "-march=native" to the compilation flags. Maybe it could speed up then interpretrer a bit?

[DEVELOPMENT ENVIRONMENT]
* NEW: Connection editor: Update layout.
* NEW: Form editor: Clicking on the master selection selects the parent control.

[WEB SITE MAKER]
* NEW: Update for 3.8.4 version.

[GB.DB]
* BUG: Default values are now correctly taken into account by database templates.

[GB.DB.SQLITE3]
* BUG: Fix a possible uninitialized allocation of columns names.

[GB.UTIL]
* NEW: Class.Stat() class name argument now allows "../" in the name to search for classes in parent components.

[GB.WEB]
* NEW: Request.Language returns the main language requested by the HTTP client. This value can be directly assigned to System.Language.
* NEW: Session.Size returns the size of the session file in bytes.

[GB.WEB.FORM]
* NEW: Automatic management of favicon. The application favicon must be a file named "favicon.png" in the ".public" directory.
* NEW: The Align class for alignment constants.
* NEW: WebControl: Any control can raise a Message event now.
* NEW: The Message boxes now raise the "Message" event of the WebControl that opened the message box. If the event is not handled, then the event is raised by the WebForm of the control.
* NEW: The Select class for selection mode constants.
* BUG: WebComboBox: Define the default event.
* NEW: WebContainer: Indent is a new property that allows to add a left padding to the container.
* NEW: WebContainer: Extra children (those created after initialization) are now recreated with their event observer and event name, provided that the event observer is another WebControl.
* NEW: WebContainer: DeleteChildren() is a new method that deletes all container children.
* NEW: WebExpander: New container that implements an expander.
* NEW: WebForm: Teh application language now automatically switches to the language requested by the HTTP client.
* BUG: WebForm: Show() and ShowModal() method now raise the Open event.
* NEW: WebLabel: Add the Border property to the property list.
* NEW: WebLabel: Newlines in label text are automatically replaced by "<br>".
* NEW: WebTable: New control that implements an HTML table with automatic scrollbars. It gets its data through a Data event, and only displays the first hundred elements by default. A button allows to increase the number of displayed elements.
  The 'Mode' property allows to define the selection mode. When rows are selectable, an extra columns is added, with radion buttons on single selection mode, and checkboxes on multiple selection mode. The indexes of selected rows is returned by
  the 'Selection' property.
* BUG: Many fixes in the default stylesheet.


git-svn-id: svn://localhost/gambas/trunk@7536 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2015-12-27 18:16:32 +00:00

397 lines
9.4 KiB
Text

' Gambas module file
Private $cVar As New Collection
Private $cTrans As New Collection
Private $sLang As String
Private $aLanguages As String[] = ["en:C", "fr:fr_FR.UTF-8", "es:es_ES.UTF-8", "ca:ca_ES.UTF-8", "cs:cs_CZ.UTF-8", "ar:ar_EG.UTF-8", "tr:tr_TR.UTF-8", "zh:zh_CN.UTF-8", "ko:ko_KR.UTF-8", "de:de_DE.UTF-8", "nl:nl_NL.UTF-8"]
Private Const NBR_NEWS As Integer = 3
Sub InitVar()
'Dim aStable As String[] = ["2.23.1", "2.22.0", "2.21.0", "2.20.2"]
'DIM aDev AS String[] = ["92", "91", "90", "51"]
$cVar["OLD_VERSION"] = "2.24.0"
$cVar["DEV_VERSION"] = "3.8.4"
InitAuthor
End
Private Sub InitAuthor()
Dim hFile As File
Dim hAuthor As CAuthor
Dim sDev As String
Dim sTrans As String
Dim bDark As Boolean
Dim aCountry As New String[]
Dim cCountry As New Collection
Dim sCountry As String
Dim aAuthor As Object[]
Dim iInd As Integer
hFile = Open "authors.txt" For Read
While Not Eof(hFile)
hAuthor = New CAuthor(hFile)
Wend
Close #hFile
CAuthor.All.Sort
For Each hAuthor In CAuthor.All
If hAuthor.Translator Then
For Each sCountry In hAuthor.Translation
If Not cCountry.Exist(sCountry) Then
cCountry[sCountry] = New Object[]
aCountry.Add(sCountry)
Endif
cCountry[sCountry].Add(hAuthor)
Next
Endif
If hAuthor.Developer Then
If bDark Then
sDev &= "<tr valign=\"top\" class=\"dark\">"
Else
sDev &= "<tr valign=\"top\">"
Endif
bDark = Not bDark
sDev &= " <td>" & hAuthor.GetLink() & "</td>\n" &
" <td>" & hAuthor.Country & "</td>" &
" <td>"
If hAuthor.Works.Count > 1 Then
sDev &= "\n <li>" & hAuthor.Works.Join(".\n <li>") & ".\n"
Else
sDev &= hAuthor.Works[0] & "."
Endif
sDev &= " </td>\n</tr>"
Endif
Next
$cVar["DEVELOPERS"] = sDev
bDark = False
aCountry.Sort
For Each sCountry In aCountry
If bDark Then
sTrans &= "<tr valign=\"top\" class=\"dark\">"
Else
sTrans &= "<tr valign=\"top\">"
Endif
bDark = Not bDark
sTrans &= " <td>" & sCountry & "</td>\n"
sTrans &= " <td>\n"
aAuthor = cCountry[sCountry]
sTrans &= " " & aAuthor[0].GetLink() & "\n"
For iInd = 1 To aAuthor.Max
sTrans &= " <br>" & aAuthor[iInd].GetLink() & "\n"
Next
sTrans &= " </td>\n</tr>\n"
Next
$cVar["TRANSLATORS"] = sTrans
End
Sub GetNews(sPath As String) As String
Dim sNews As String
Dim sData As String
Dim iPos As Integer
Dim aDate As String[]
Dim dDate As Date
sNews = File.Load("news.html")
sData = File.Load(sPath)
aDate = Split(File.BaseName(sPath), "-")
dDate = Date(aDate[0], aDate[1], Left(aDate[2], 2))
If File.BaseName(sPath) = "2010-01-04" Then
sNews = Replace(sNews, "$(CLASS)", "news snow")
Else
sNews = Replace(sNews, "$(CLASS)", "news")
Endif
sNews = Replace(sNews, "$(DATE)", Format(dDate, "dd mmm yyyy"))
iPos = InStr(sData, "\n")
sNews = Replace(sNews, "$(TITLE)", Left(sData, iPos - 1))
sNews = Replace(sNews, "$(NEWS)", Trim(Mid$(sData, iPos + 1)))
Return sNews
End
Sub Expand(sPath As String)
Dim sData As String
Dim sVar As String
Dim iNews As Integer
Dim sKey As String
Dim sFile As String
Dim sSubst As String
Dim sDest As String
sDest = File.SetExt(sPath, "")
sData = File.Load(sPath)
For Each sVar In $cVar
sData = Replace(sData, "$(" & $cVar.Key & ")", sVar)
Next
If InStr(sData, "$(HEAD_NEWS)") Then
iNews = NBR_NEWS
sKey = "$(HEAD_NEWS)"
Else If InStr(sData, "$(NEWS)") Then
iNews = 1024
sKey = "$(NEWS)"
Endif
If iNews Then
For Each sFile In Dir("news", "*.html").Sort(gb.Descent)
If $sLang And If Exist("news" &/ $sLang &/ sFile)
sSubst &= GetNews("news" &/ $sLang &/ sFile)
Else
sSubst &= GetNews("news" &/ sFile)
Endif
Dec iNews
If iNews <= 0 Then Break
Next
sData = Replace(sData, sKey, sSubst)
Endif
Try Kill sDest & "~"
Try Move sDest To sDest & "~"
File.Save(sDest, sData)
CAuthor.All.Clear
End
Sub ReplaceMail(sPath As String)
Dim sData As String = File.Load(sPath)
Dim iPos, iPos2 As Integer
Dim sMail As String
Dim sOrig As String
Dim bMail As Boolean
Do
iPos = InStr(sData, "href=\"mailto:", iPos + 1)
If iPos = 0 Then Break
iPos2 = InStr(sData, Chr$(34), iPos + 7)
If iPos2 = 0 Then Break
sMail = Mid$(sData, iPos, iPos2 - iPos + 1)
sOrig = sMail
sMail = Replace(sMail, "@", "_AT_")
sMail = Replace(sMail, ".", "_DOT_")
sData = Left(sData, iPos - 1) & sMail & Mid$(sData, iPos2 + 1)
iPos += Len(sMail)
If sOrig <> sMail Then
If Not bMail Then
bMail = True
Print sPath
Endif
Endif
Loop
Try Kill sPath & "~"
Try Move sPath To sPath & "~"
File.Save(sPath, sData)
End
Private Sub ReplaceLink(sData As String, sAttr As String) As String
Dim iPos, iPos2 As Integer
Dim sLink As String
Do
iPos = InStr(sData, sAttr & "=\"", iPos + 1)
If iPos = 0 Then Break
iPos2 = InStr(sData, "\"", iPos + Len(sAttr) + 2)
If iPos2 = 0 Then Break
sLink = Mid$(sData, iPos + Len(sAttr) + 2, iPos2 - iPos - Len(sAttr) - 2)
If Not sLink Then Continue
If sLink Like "http://*" Then Continue
If sLink Like "https://*" Then Continue
If sLink Like "mailto:*" Then Continue
If sLink Like "/" Then Continue
If sLink Like "*.html" Then Continue
If sLink Like "*.html#*" Then Continue
If Left(sLink) = "#" Then Continue
sData = Left$(sData, iPos + Len(sAttr) + 1) & ".." &/ sLink & Mid$(sData, iPos2)
iPos = iPos2
Loop
Return sData
End
Private Sub Translate(sSrc As String, sDest As String, Optional bNoTrans As Boolean)
Dim sData As String = File.Load(sSrc)
Dim iPos, iPos2 As Integer
Dim sStr As String
If InStr(sDest, "changelog3") Then Stop
Print sDest
If Not bNoTrans Then
Do
iPos = InStr(sData, "{", iPos + 1)
If iPos = 0 Then Break
iPos2 = InStr(sData, "}", iPos + 1)
If iPos2 = 0 Then Break
sStr = Mid$(sData, iPos + 1, iPos2 - iPos - 1)
If InStr(sStr, "\n") Or Left(sStr) = " " Or Right(sStr) = " " Then Continue
$cTrans[sStr] = sStr
Print "{"; sStr; "}";
sStr = MTranslation[sStr]
Print " -> "; sStr
sData = Left$(sData, iPos - 1) & sStr & Mid$(sData, iPos2 + 1)
Loop
Endif
iPos = 0
Do
iPos = InStr(sData, "$(WIKI:", iPos + 1)
If iPos = 0 Then Break
iPos2 = InStr(sData, ")", iPos)
If iPos2 = 0 Then Break
sStr = "http://gambaswiki.org/wiki/" &/ Mid$(sData, iPos + 7, iPos2 - iPos - 7) & "?nh&amp;l=" & $sLang
sData = Left$(sData, iPos - 1) & sStr & Mid$(sData, iPos2 + 1)
Loop
sData = ReplaceLink(sData, "href")
sData = ReplaceLink(sData, "src")
sData = Replace(sData, "$(LANG)", $sLang)
If $sLang = "ar" Then
sData = Replace(sData, "$(LANGDIR)", "rtl")
sData = Replace(sData, "$(DIR)", "-rtl")
sData = Replace(sData, "$(STYLE)", "style-rtl.css")
sData = Replace(sData, "$(RIGHT)", "left")
Else
sData = Replace(sData, "$(LANGDIR)", "ltr")
sData = Replace(sData, "$(DIR)", "")
sData = Replace(sData, "$(STYLE)", "style.css")
sData = Replace(sData, "$(RIGHT)", "right")
Endif
File.Save(sDest, sData)
End
Public Sub Main()
Dim sFile As String
Dim sDir As String
Dim sLang As String
Dim aLang As String[]
Dim sTrans As String
Dim sData As String
Dim iPos, iPos2 As Integer
InitVar
' Trick for directly modifying the project html files
sDir = Application.Path &/ "gambas.sourceforge.net"
' For Each sFile In Dir(sDir, "*.template")
' Print sFile
' Expand(sDir &/ sFile)
' Next
'MChangeLog.MakeChangeLog(sDir, 2)
'MChangeLog.MakeChangeLog(sDir, 3)
If Exist("~/gambas/2.0/trunk") Then
Try Kill "~/gambas/2.0/trunk/app/src/gambas2/authors.txt"
Copy "authors.txt" To "~/gambas/2.0/trunk/app/src/gambas2/authors.txt"
Endif
If Exist("~/gambas/3.0/trunk") Then
Try Kill "~/gambas/3.0/trunk/app/src/gambas3/authors.txt"
Copy "authors.txt" To "~/gambas/3.0/trunk/app/src/gambas3/authors.txt"
Endif
For Each sLang In $aLanguages
aLang = Split(sLang, ":")
$sLang = aLang[0]
System.Language = aLang[1]
sLang = $sLang
For Each sFile In Dir(sDir, "*.template")
Print sFile
Expand(sDir &/ sFile)
Next
For Each sFile In Dir(sDir, "*.html")
ReplaceMail(sDir &/ sFile)
Next
Try Mkdir sDir &/ sLang
MTranslation.Load
For Each sFile In Dir(sDir, "*.html")
If sFile = "index.html" Then Continue
Translate(sDir &/ sFile, sDir &/ sLang &/ sFile, sFile Like "changelog*.html")
Next
Next
Print
Print "Creating the translation module..."
For Each sTrans In $cTrans
sTrans = Replace(sTrans, "\"", "\\\"")
sData &= " $cTr[\"" & sTrans & "\"] = (\"" & sTrans & "\")\n"
Next
sFile = File.Load(Application.Path &/ ".src/MTranslation.module")
iPos = InStr(sFile, "'{")
iPos2 = InStr(sFile, "'}", iPos)
sFile = Left$(sFile, iPos - 1) & "'{\n" & sData & " '}" & Mid$(sFile, iPos2 + 2)
File.Save(Application.Path &/ ".src/MTranslation.module", sFile)
Print
Print "**** DONE! ****"
End