From cd9babdeeb5af55f922f8916c41f999445725888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Mon, 3 Feb 2014 18:32:43 +0000 Subject: [PATCH] [EXAMPLES] * NEW: Embed the gb.markdown code so that the example can be tested on the stable version of Gambas. This is temporary! git-svn-id: svn://localhost/gambas/trunk@6128 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- examples/examples/Web/SmallWiki/.project | 4 +- .../examples/Web/SmallWiki/.public/style.css | 31 +- .../Web/SmallWiki/.src/Markdown.class | 21 + .../Web/SmallWiki/.src/MarkdownLink.class | 8 + .../examples/Web/SmallWiki/.src/Markup.module | 762 ++++++++++++++++++ .../examples/Web/SmallWiki/.src/Wiki.class | 7 +- .../examples/Web/SmallWiki/.src/Wiki.webpage | 7 +- .../Web/SmallWiki/.src/WikiMarkdown.class | 2 +- examples/examples/Web/SmallWiki/.startup | 3 +- 9 files changed, 830 insertions(+), 15 deletions(-) create mode 100644 examples/examples/Web/SmallWiki/.src/Markdown.class create mode 100644 examples/examples/Web/SmallWiki/.src/MarkdownLink.class create mode 100644 examples/examples/Web/SmallWiki/.src/Markup.module diff --git a/examples/examples/Web/SmallWiki/.project b/examples/examples/Web/SmallWiki/.project index 391e99962..21d06f869 100644 --- a/examples/examples/Web/SmallWiki/.project +++ b/examples/examples/Web/SmallWiki/.project @@ -4,8 +4,8 @@ Title=SmallWiki Startup=Main UseHttpServer=1 Icon=.public/logo.png -Version=0.0.126 -Component=gb.markdown +Version=3.5.90 +VersionFile=1 Component=gb.web TabSize=2 ExecPath=/home/guygle/guygle/cgi-bin/wiki.gambas diff --git a/examples/examples/Web/SmallWiki/.public/style.css b/examples/examples/Web/SmallWiki/.public/style.css index d4f022401..497477f2f 100644 --- a/examples/examples/Web/SmallWiki/.public/style.css +++ b/examples/examples/Web/SmallWiki/.public/style.css @@ -1,3 +1,7 @@ +HTML, BODY { + height: 100%; + } + BODY{ padding: 0px; margin: 0px; @@ -21,13 +25,20 @@ CODE { } PRE { + background: #F0F0F0; + display: inline-table; + padding: 4px; + margin: 0px; +} + +/*PRE { border: solid 1px #E0E0E0; padding: 4px; } PRE CODE { background: none; -} +}*/ TABLE { border: solid #A0A0A0 1px; @@ -72,6 +83,7 @@ TABLE.example TH { border-bottom: black solid 1px; padding: 4px 8px; box-shadow: 0 0 8px black; + height: 24px; } .title { @@ -93,7 +105,9 @@ TABLE.example TH { .unknown { color: red; - font-style: italic; + font-style: italic; + margin-top: 8px; + font-size: 150%; } .command { @@ -107,9 +121,18 @@ TABLE.example TH { padding: 2px; } +.edit-frame { + position: absolute; + left: 0px; + right: 0px; + top: 36px; + bottom: 0px; + padding: 8px; +} + .edit { border: none; - width: 100%; - height: 600px; background: none; + width: 100%; + height: 100%; } diff --git a/examples/examples/Web/SmallWiki/.src/Markdown.class b/examples/examples/Web/SmallWiki/.src/Markdown.class new file mode 100644 index 000000000..789fb7cbe --- /dev/null +++ b/examples/examples/Web/SmallWiki/.src/Markdown.class @@ -0,0 +1,21 @@ +' Gambas class file + +'Export +Create + +Public Root As String +Public Line As Integer + +Public Sub ToHTML(Markdown As String) As String + + Return Markup.Convert(Markdown, Me) + +End + +Public Sub Link((sLink) As MarkdownLink) + +End + +Public Sub Command((sCommand) As String) As String[] + +End diff --git a/examples/examples/Web/SmallWiki/.src/MarkdownLink.class b/examples/examples/Web/SmallWiki/.src/MarkdownLink.class new file mode 100644 index 000000000..5d5dc0b6c --- /dev/null +++ b/examples/examples/Web/SmallWiki/.src/MarkdownLink.class @@ -0,0 +1,8 @@ +' Gambas class file + +'Export + +Public Link As String +Public Text As String +Public Title As String +Public Html As String diff --git a/examples/examples/Web/SmallWiki/.src/Markup.module b/examples/examples/Web/SmallWiki/.src/Markup.module new file mode 100644 index 000000000..fbafa6356 --- /dev/null +++ b/examples/examples/Web/SmallWiki/.src/Markup.module @@ -0,0 +1,762 @@ +' Gambas module file + +Public Struct MarkupList + sType As String + iIndent As Integer +End Struct + +Private $aMarkup As String[] +Private $cLink As Collection +Private $aIndex As String[] +Private $aTable As String[] +Private $aTablePos As Integer[] +Private $hMarkdown As Markdown +Private $hLink As New MarkdownLink + +Private Sub GetIndent(sLine As String) As Integer + + Return Len(sLine) - Len(LTrim(sLine)) + +End + +Public Sub Convert(sMarkup As String, hMarkdown As Markdown) As String + + $hMarkdown = hMarkdown + $cLink = New Collection + $aIndex = New String[] + + Return ConvertMarkup(Split(sMarkup, "\n")) + +End + +Private Sub ConvertMarkup(aLine As String[], Optional bDoNotSetLine As Boolean) As String + + Dim iLine As Integer + Dim aResult As String[] + Dim sLine As String + Dim sText As String + Dim I As Integer + Dim bCode As Boolean + Dim iBlockQuote As Integer + Dim sCar As String + Dim bInsidePar As Boolean + Dim bIgnorePar As Boolean + Dim bAddPar As Boolean + Dim iIndent, iCurrentIndent As Integer + Dim hMarkupList As MarkupList + Dim bJustList As Boolean + Dim sLink As String + Dim iPos As Integer + Dim aList As New MarkupList[] + Dim sTable As String + Dim iIndexPos As Integer = -1 + Dim aCommand As String[] + + aResult = New String[] + $aMarkup = New String[] + $aTable = New String[] + $aTablePos = New Integer[] + + ' iLine = 0 + ' Do + ' If iLine >= aLine.Count Then Break + ' sLine = LTrim(aLine[iLine]) + ' If Left(sLine) = "%" Then + ' If sLine Begins "%IF " Then + ' Else If sLine Begins "%ELSE " Then + ' + ' Endif + ' Endif + ' Inc iLine + ' Loop + + For iLine = 0 To aLine.Max + + sLine = LTrim(aLine[iLine]) + If Not sLine Then Continue + If Left(sLine) <> "[" Then Continue + I = InStr(sLine, "]:") + If I = 0 Then Continue + If I >= 3 Then + sLink = Trim(Mid$(sLine, I + 2)) + $cLink[Mid$(sLine, 2, I - 2)] = sLink + If Left(sLink) = "#" Then + iPos = InStr(sLink, " ") + If iPos Then sLink = Left(sLink, iPos - 1) + aLine[iLine] = "" + Continue + Endif + Endif + aLine[iLine] = "" + + Next + + For iLine = 0 To aLine.Max + + If Not bDoNotSetLine Then $hMarkdown.Line = iLine + sLine = aLine[iLine] + + If $aMarkup.Count Then + aResult.Add(ConvertLine(sLine)) + Continue + Endif + + sLine = RTrim(sLine) + If Not sLine Then sLine = aLine[iLine] + + ' Special command + + If Left(sLine, 2) = "@{" And If Right(sLine) = "}" Then + If sLine = "@{index}" Then + iIndexPos = aResult.Count + aResult.Add(sLine) + Else + aCommand = $hMarkdown.Command(Mid$(sLine, 3, -1)) + If aCommand And If aCommand.Count Then + aResult.Add(ConvertMarkup(aCommand)) + Endif + Endif + Continue + Endif + + ' Blockquote + + I = 0 + Do + If Left(sLine) <> ">" Then Break + sCar = Mid$(sLine, 2, 1) + If sCar <> " " And If sCar <> gb.Tab Then Break + Inc I + sLine = LTrim(Mid$(sLine, 3)) + Loop + + If I > iBlockQuote Then + While I > iBlockQuote + aResult.Add("
") + Inc iBlockQuote + Wend + Else If I < iBlockQuote Then + While I < iBlockQuote + aResult.Add("
") + Dec iBlockQuote + Wend + Endif + + ' Lists + + If Trim(sLine) Then + + iIndent = GetIndent(sLine) + GoSub CLOSE_LIST + + sLine = Mid$(sLine, iCurrentIndent + 1) + + ' Horizontal lines + + If Left(sLine) = "*" And If Right(sLine) = "*" Then + sText = Replace(sLine, " ", "") + If Len(sText) >= 3 And If sText = String$(Len(sText), "*") Then + GoSub CLOSE_PARA + aResult.Add("
") + Continue + Endif + Endif + + If Left(sLine) = "-" And If Right(sLine) = "-" Then + sText = Replace(sLine, " ", "") + If Len(sText) >= 3 And If sText = String$(Len(sText), "-") Then + GoSub CLOSE_PARA + aResult.Add("
") + Continue + Endif + Endif + + If sLine Begins "* " Or If sLine Begins "- " Then + hMarkupList = New MarkupList + hMarkupList.sType = "ul" + hMarkupList.iIndent = iIndent + 1 + GetIndent(Mid$(sLine, 2)) + aList.Add(hMarkupList) + bJustList = True + If aResult.Count And If Trim(aResult[aResult.Max]) = "" Then + If Not Trim(aLine[iLine - 1]) And If iLine < aLine.Max And If GetIndent(aLine[iLine + 1]) >= hMarkupList.iIndent Then + bJustList = False + Endif + aResult.Remove(aResult.Max) + Else + GoSub CLOSE_PARA + aResult.Add(Space$(iCurrentIndent) & "