EnglishРусский  

   ..

   bnf.g

   default.g

   standard.g

Данный проект закрыт! Создан новый скриптовый язык с тем же именем. Всё доступно на GitHub.
Также попробуйте нашу open source кроссплатформенную программу для создания и управления скриптами.

Реклама

Инсталлятор CreateInstall
Бесплатные и коммерческие инсталляторы

  1 /******************************************************************************
  2 *
  3 * Copyright (C) 2006, The Gentee Group. All rights reserved. 
  4 * This file is part of the Gentee open source project - http://www.gentee.com. 
  5 * 
  6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
  7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
  8 * ACCEPTANCE OF THE AGREEMENT.
  9 *
 10 * ID: standard 17.11.06 0.0.A.
 11 *
 12 * Author: Alexey Krivonogov ( gentee )
 13 *
 14 ******************************************************************************/
 15 
 16 include : $"..\..\..\..\example\src2html\src2html.g"
 17 
 18 global
 19 {
 20    uint _gtimenu // gtitem in menu for searchroot
 21    uint _childmenu  // The first owner in childs
 22 }
 23 
 24 /*-----------------------------------------------------------------------------
 25 *
 26 * ID:  15.03.2007 1.0
 27 * 
 28 * Summary: Получить ссылку на страницу.  
 29 *  
 30 -----------------------------------------------------------------------------*/
 31 
 32 text a( arrstr params )
 33 \{
 34    str atext link
 35    uint gti 
 36    
 37    if !*params : return
 38    
 39    link = params[0]
 40       
 41    gti as _gtp.find( link )
 42    if >i
 43    { 
 44       _gtp.geturl( gti, link )
 45       gti.getsubitem( "urlname", atext )
 46       if !*atext : gti.getsubitem( "title", atext )
 47    }
 48       
 49    if *params > 1 && *params[1] : atext = params[1]
 50 
 51    if !*atext
 52    {
 53       atext = link
 54       if "http:".eqlenign( atext ) : atext.del( 0, 7 )
 55    }
 56    @"<a href = \"\( link )\">\( atext )</a>"
 57 }\!
 58 
 59 text content( gtitem gti )
 60 \{
 61    str  content title
 62    arrstr  prg
 63 
 64    gti.getsubitem( "content", content )
 65    gti.getsubitem( "pagetitle", title )
 66    if !*title : gti.getsubitem( "title", title )
 67 
 68    @"#h1( '\(title )')\l"
 69    if gti.find( "nop" )
 70    {
 71       @content
 72    }
 73    else
 74    {
 75       @"<p>"
 76       prg.load( content, 0 )
 77       foreach curp, prg
 78       {
 79          if !*curp : @"</p><p>\l"
 80          else : @"\(curp)\l" 
 81       }
 82       @"</p>"
 83    }
 84 //   @content      
 85 }\!
 86 
 87 
 88 method uint gtpub.searchmenu( gtitem gmenu, str name )
 89 {
 90    if gmenu.name %== name : return &gmenu
 91    
 92    foreach curmenu, gmenu
 93    {
 94       uint ret
 95       if ret = this.searchmenu( curmenu->gtitem, name ) : return ret 
 96    }
 97    return 0
 98 }
 99 
100 text ulcont( gtitem root )
101 <ul><p>\{
102    foreach cur, root
103    {
104       cur as gtitem
105       arrstr  pars
106       str     link
107       
108       if cur.find("nourl")
109       {
110          uint gtdis
111          str  stemp
112          
113          gtdis as _gtp.find( cur.name )
114          if >dis : gtdis.getsubitem( "title", stemp )
115          else : stemp = cur.name
116          link = "<span class=\"text\">\(stemp)</span>"
117       }
118       else
119       {
120          pars += cur.name
121          link@a( pars )
122       } 
123       @"<li>\( link )"
124       if cur.haschild() : @ulcont( cur )
125       @"</li>\l"
126    }
127 }</p></ul>\!
128 
129 text contents( arrstr param )
130 \{
131    uint root
132    
133    root as _gtp.searchmenu( _gtp.find( "menu"), param[0] )->gtitem
134    
135    @"<p>#h2( '#lng/tcont#' )"   
136    @ulcont( root )
137    @"</p>"
138 }\!
139 
140 text adesc( arrstr params )
141 \{
142    uint gti 
143    
144    if !*params : return
145   
146    gti as _gtp.find( params[0] )
147    if >i
148    { 
149       str stemp
150       gti.getsubitem( "desc", stemp )
151       @stemp
152    }
153 }\!
154 
155 text desc( arrstr params )
156 \{
157    uint gti 
158    
159    if !*params : return
160   
161    gti as _gtp.find( params[0] )
162    if >i
163    { 
164       str stemp
165       gti.getsubitem( "desc", stemp )
166       @stemp
167    }
168 }\!
169 
170 text doclist( arrstr param )
171 #tblparam[\{
172    arrstr items
173    
174    items.loadtrim( param[0] )
175    foreach cur, items
176    {
177       str title desc link
178       uint gti
179       
180       gti as _gtp.find( cur )
181       if >i
182       { 
183 //         _gtp.geturl( gti, link )
184 //         gti.getsubitem( "urlname", title )
185 //         if !*title : gti.getsubitem( "title", title )
186          gti.getsubitem( "desc", desc )
187          @"#a( \( cur ))|\(desc)\l "
188       }
189       
190    }   
191 }]\!
192 
193 text dwnfile( arrstr param )
194 \{
195    finfo fi
196    datetime dt
197    str   date atext name filename = "#dwnpath#\\\(param[0])"
198    
199    _gtp.get( "lng/date", date )
200    _gtp.process( filename )
201    if !getfileinfo( filename, fi )
202    {
203       print("File \( filename ) has not been found!\n")
204    } 
205    name.fnameext( filename )
206    ftimetodatetime( fi.lastwrite, dt, 0)
207    getdateformat( dt, date, atext )
208     
209    @"<strong><a href = '/download/\(name)'>\(name)</></>|\(fi.sizelo)|\(atext)|\(param[1])"      
210 
211 }\!
212 
213 text form( arrstr params )
214 \{
215    str url
216    uint gti
217    
218    gti as _gtp.find( params[0] )
219    if >i : _gtp.geturl( gti, url )
220 }
221 <form class="form1" enctype="multipart/form-data" action="\( url )"  method="post">\!
222 
223 text formcombo( arrstr params )
224 \{  arrstr items
225  
226    if *params < 3 : return
227    @"<h6>\( params[0] )</h6><SELECT NAME=\"\( params[1] )\" SIZE=1 class=\"combobox\">"
228    items.loadtrim( params[2] )
229    foreach curi, items
230    {
231       arrstr subi
232       curi.split( subi, '|', $SPLIT_NOSYS | $SPLIT_FIRST )
233       @"<option value='\(subi[0])'>\( subi[1] )</option>"
234    }
235    @"</select>"
236 }\!
237 
238 text formend( arrstr params )
239 <br><input type="submit" value="\( params[0] )" class="button">
240 \{
241    if *params > 1
242    {
243       @"<input type=\"reset\" value=\"\( params[1])\" class=\"button\">"
244    }
245 }</form>\!
246 
247 text formradio( arrstr params )
248 \{  arrstr items
249  
250    if *params < 3 : return
251    @"<h6>\( params[0] )</h6>"
252    items.loadtrim( params[2] )
253    foreach curi, items
254    {
255       arrstr subi
256       curi.split( subi, '|', $SPLIT_NOSYS | $SPLIT_FIRST )
257       @"<input type=\"radio\" name=\"\(params[1])\" value=\"\(subi[0])\"> \( subi[1] )</input><br>"
258    }
259 }\!
260 
261 text curlang( arrstr params )
262 \{
263     @_gtp.lang
264 }\!
265 
266 text mainmenu( gtitem gti )
267 <div class="menu-box">
268 	<span class="mainmenu">
269 \{
270    uint imenu
271    
272    imenu as _gtp.find("menu")
273    foreach curmenu, imenu
274    {
275       str  name
276       uint mgti
277       arrstr  astr
278       
279       curmenu as gtitem
280       astr += curmenu.name
281       
282       _gtp.geturlname( curmenu.name, name )
283       
284       if _gtp.searchmenu( curmenu, gti.name )
285       {
286          @"<div class=\"menu-act\">\( name )</div>"
287       }
288       else : @a( astr )
289    }         
290 }      
291 	</span>
292 </div>\!
293 
294 method gtitem gtpub.searchroot( gtitem gti, str name attrib )
295 {
296    if gti.name %== name
297    { 
298       _gtimenu = >i
299       return 0xFFFFFFFF->gtitem
300    } 
301    foreach curmenu, gti
302    {
303       uint ret
304       
305       curmenu as gtitem
306       ret as this.searchroot( curmenu, name, attrib )
307       if ret
308       {
309          if &ret == 0xFFFFFFFF
310          {
311             if gti.find( attrib ) : return gti
312             else : return ret        
313          }
314          else : return ret 
315       }      
316    }
317    return 0->gtitem   
318 }
319 
320 text grainmenu( gtitem gti )
321 \{
322    uint rootmenu
323   
324    rootmenu as _gtp.searchroot( _gtp.find("menu"), gti.name, "grain" )
325    if !&rootmenu || &rootmenu == 0xFFFFFFFF : return
326 }<div class="box submenu">\{
327    uint   owner 
328    int    i
329    arrstr st
330    
331    owner as _gtimenu->gtitem
332    
333    do
334    {
335       owner as owner.parent()
336       if !owner.find("nourl")
337       {
338          st += owner.name
339       }
340    } while &owner != &rootmenu  
341    
342    for i = *st - 1, i >= 0, i--
343    {
344       str class
345       arrstr param
346       if i == *st - 1 && i : class = "class=\"first\""
347       elif !i : class = "class=\"last\""
348 //      url@a( param += st[i] )
349       @"<span \(class)>"
350       @a( param += st[i] )
351       @"</span>"          
352    }  
353 //   navgenerate( rootmenu, 0, gti.name, stemp )
354 //   @stemp
355 //				<span class="first"><a href="#">Документация</a></span><span><a href="#">Описание языка</a></span><span class="last"><a href="#">Макросы</a></span>
356 }</div>
357 \!
358 
359 text linklist( arrstr params )
360 #h2( \( params[0] ) )
361 <p><ul>
362 \{
363    arrstr items
364    
365    params[1].split( items, '|', $SPLIT_NOSYS )
366    foreach cur, items
367    {
368       @"<li>#a( \( cur ) )</li>\l"
369    }
370 }</ul></p>\!
371 
372 func str navgenerate( gtitem gti, uint level, str name ret )
373 {
374    str stemp
375    
376    if gti.haschild() && ( !level || name != "childs" ) && 
377       ( !_childmenu || _childmenu == >i || level != 1 )
378    {
379       arrstr astr
380 
381       if level
382       {            
383          if gti.name %== name
384          {
385             _gtp.geturlname( name, stemp )
386             ret@"<div class=\"lvl l\(level) act  show\">
387 							<p class=\"act\"><!--span onclick=\"hideShow(2)\" id=\"2\"> – </span-->   \( stemp )</p>
388 							<div class=\"lvl l\( level + 1 ) show\" ><!-- id=\"2_1\" -->
389 								<ul>"
390          }
391          else
392          {
393             astr += gti.name
394             if gti.find("nourl")
395             {
396                uint gtdis
397                gtdis as _gtp.find( gti.name )
398                if >dis : gtdis.getsubitem( "title", stemp )
399                else : stemp@gti.name
400             }
401             else : stemp@a( astr )
402             ret@"<div class=\"lvl l\(level)\">
403 					<p><!--span onclick=\"hideShow(3)\" id = \"3\" > – </span-->   \( stemp )</p>
404 						<div class=\"lvl l\(level + 1) show\"><!-- id=\"3_1\"-->
405                   <ul>"
406          }            
407       }
408 //      print("Childs \(gti.name) = \(level) \(name)\n")            
409       foreach curmenu, gti
410       {
411          navgenerate( curmenu->gtitem, level + 1, name, ret )
412       }
413       if level
414       {
415          ret@"</ul></div></div>"
416       }
417    }
418    else 
419    {
420 //      print( "\(gti.name) \(level) \n")
421       if gti.name %== name
422       {
423          _gtp.geturlname( name, stemp )
424          if level == 1
425          {      
426             ret @ "<div class=\"lvl l\(level) act\"><p class=\"act\">   \( stemp )</p></div>"
427          }
428          else : ret @ "<li class=\"act\">\( stemp )</li>"
429       }
430       else
431       {
432          arrstr astr
433             
434          if gti.find("nourl")
435          {
436             uint gtdis
437             gtdis as _gtp.find( gti.name )
438             if >dis : gtdis.getsubitem( "title", stemp )
439             else : stemp@gti.name
440          }
441          else
442          {
443             astr += gti.name 
444             stemp@a( astr )
445          }
446          if level == 1
447          {         
448             ret @ "<div class=\"lvl l\(level)\"><p>   \(stemp)</p></div>"
449          }
450          else : ret @ "<li>\(stemp)</li>" 
451       }
452    }
453    return ret
454 }
455 
456 text navmenu( gtitem gti )
457 \{
458    uint rootmenu parent
459    str  name
460 
461    _gtimenu = 0
462    _childmenu = 0
463    name = gti.name
464    rootmenu as _gtp.searchroot( _gtp.find("menu"), name, "nav" )
465       
466    if _gtimenu && _gtimenu->gtitem.find( "childs" ) 
467    {
468       name = "childs"
469       rootmenu as _gtimenu->gtitem
470 //      return
471    }
472    elif !&rootmenu || &rootmenu == 0xFFFFFFFF : return
473 }<div class="left-menu">\{
474    str stemp
475    if rootmenu.find( "childs" ) && &rootmenu != _gtimenu 
476    {
477       _childmenu = _gtimenu
478       while &_childmenu->gtitem.parent() != &rootmenu   
479       {
480          _childmenu = &_childmenu->gtitem.parent()
481       }
482 //      print(" \( &rootmenu ) Child = \( _childmenu ) \(name) \( _childmenu->gtitem.name )\n")    
483    }
484    navgenerate( rootmenu, 0, name, stemp )
485    @stemp 
486 /*   foreach curmenu, imenu
487    {
488       str  name
489       uint mgti
490       arrstr  astr
491       
492       curmenu as gtitem
493    }*/         
494 }
495 </div>\!
496 
497 text related( str param )
498 \{
499    uint gti gtis
500 
501    gti as _gtp.find("common/\( param )/require" )
502    if >i
503    {
504       @"<p>#h2(#lng/require#)#tblparam[ \( gti.value ) ]</p>"
505    }
506    
507    gti as _gtp.find("common/\( param )/related" )
508    if style[0] != 'H'
509    {
510       gtis as _gtp.find("common/\( param )/source" )
511    }
512    if >i && gtis
513    {
514       @"<table border=0 width=100%><tr><td>"
515    }
516    if >i
517    {
518       @"<p>#linklist( #lng/related#, \( gti.value ))</p>"
519    }
520    if >i && gtis : @"</td><td>"
521    if gtis
522    {
523       @"<p>#h2( '#lng/source#' )<p><ul>"
524    
525       arrstr items
526    
527       gtis->gtitem.value.split( items, '|', $SPLIT_NOSYS )
528       foreach cur, items
529       {
530          str val anchor
531          uint off
532          
533          off = cur.findch('#')
534          if off < *cur
535          {
536             anchor.substr( cur, off, *cur - off )
537             cur.setlen( off )
538          }
539          val.replacech( cur, '.', "_" ) += ".htm"
540          @"<li>#a( /source/\(val)\(anchor), \(cur) )</li>\l"
541       }
542       @"</ul></p></p>"
543    }
544    if >i && gtis
545    {
546       @"</td></tr></table>"
547    }
548 }\!
549 
550 text sp( arrstr param )
551 \{
552    uint i
553    fornum i, uint( param[0] ) + 1
554    {
555       @" "
556    }
557 }\!
558 
559 text srcg( arrstr params )
560 \{
561    str  out stemp
562    
563    _gtp.process( params[0] )   
564 //   stemp.replacech( params[0], '<', "<" )
565 //   out.replacech( stemp, '>', ">" )
566    out@src2html( params[0], $S2H_GENTEE )
567 }
568 <pre><code>\( out )</code></pre>
569 \!
570 
571 text ex( arrstr params )
572 \{
573    uint example
574    
575    example as _gtp.find( params[0] )
576    if &example
577    {
578       params[0] = example->gtitem.value
579       @srcg( params ) 
580    }
581 }\!
582 
583 text srchtml( arrstr params )
584 \{
585    str  out stemp
586    
587    _gtp.process( params[0] )   
588    stemp.replacech( params[0], '<', "<" )
589    out.replacech( stemp, '>', ">" )
590 }
591 <pre><code><strong>\( out )</strong></code></pre>
592 \!
593 
594 text srctxt( arrstr params )
595 \{
596    str  out stemp
597    
598    _gtp.process( params[0] )   
599    stemp.replacech( params[0], '<', "<" )
600    out.replacech( stemp, '>', ">" )
601 }
602 <pre><code><strong>\( out )</strong></code></pre>
603 \!
604 
605 text tblborder( arrstr param )
606 \{
607    uint i, cols, width = 100
608    arrstr lines items
609    
610    if *param > 1 : width = uint( param[1] )
611 
612    lines.loadtrim( param[0] )
613    
614    @"<table cellpadding=\"0\" rules=\"cols\" class=\"table1\" width=\( width )%>"
615    lines[0].split( items, '|', $SPLIT_NOSYS )
616    cols = *items      
617    @"<col span=\( cols ) width=\"20%\">"
618    fornum i, *lines
619    {
620       str class
621       
622       if !i : class = "class=\"tablehead\""
623       elif i == 1 : class = "class=\"after-tablehead\""
624       @"<tr \(class)>"
625       lines[i].split( items, '|', $SPLIT_NOSYS )
626       if *items == 1
627       {
628           @"<td colspan = \(cols)><span>\(items[0])</span></td>"  
629       }
630       else
631       {
632          foreach curi, items
633          {
634             @"<td><span>\(curi)</span></td>"
635          }
636       }
637       @"</tr>"
638    }
639    @"</table>"
640 }\!
641 
642 text tblparam( arrstr param )
643 \{
644    uint i, cols, width = 100
645    uint colw = 30
646    arrstr lines items
647    
648    if *param > 1 : width = uint( param[1] )
649    if *param > 2 : colw = uint( param[2] )
650 
651    lines.loadtrim( param[0] )
652    
653    @"<table cellpadding=\"0\" class=\"table3\" width=\( width )%>"
654    @"<col width=\"\(colw)%\">"
655    fornum i, *lines
656    {
657       str class
658       
659       if !i : class = "class=\"first-row\""
660       elif i == *lines - 1 : class = "class=\"last-row\""
661       @"<tr \(class)>"
662       lines[i].split( items, '|', $SPLIT_NOSYS )
663       if *items == 1 : items += " "
664        _gtp.process( items[0] )
665        _gtp.process( items[1] )
666       @"<td class=\"first-col\"><span>\(items[0])</span></td>"
667       @"<td class=\"last-col\"><span>\(items[1])</span></td>"
668       @"</tr>"
669    }
670    @"</table>"
671 }\!
672 
673 text tbllines( arrstr param )
674 \{
675    uint i
676    arrstr lines
677    
678    subfunc trout( uint num )
679    {
680       uint k
681       arrstr items
682       
683       _gtp.process( lines[ num ] )
684       lines[ num ].split( items, '|', $SPLIT_NOSYS )
685 		@"<td class=\"first-col\"><span>\( items[0] )</span></td>\l"
686       
687       fornum k = 1, *items - 1
688       {
689          @"<td><span>\( items[k] )</span></td>\l"   
690       }
691       @"<td class=\"last-col\"><span>\( items[ *items - 1 ] )</span></td>\l"
692    }
693    
694    lines.loadtrim( param[0] )
695    
696    @"<div class=\"box-no-bord\"><table cellpadding=\"0\" class=\"table2\">
697 <tr class=\"tablehead\">\l"
698    trout( 0 )
699    @"</tr>\l"
700    fornum i = 1, *lines
701    {
702       if !*lines[i] : continue
703       @"<tr class=\"\(?( i & 1, "ne-chet", "chet" ))\">\l"
704       trout( i )  
705       @"</tr>\l"
706    }
707    @"</table></div>"
708 }\!
709 
710 text apilist( arrstr param )
711 \{
712    arrstr items
713    uint   i
714 
715    subfunc trout( str sname )
716    {
717       str  desc
718       uint gti
719       
720       gti as _gtp.find( sname )
721       if !>i : return
722 
723       gti.getsubitem( "desc", desc )
724       @"<td class=\"first-col\"><span class=\"api\">#a(\( sname ))</span></td>\l"
725       @"<td class=\"last-col\"><span>\( desc )</span></td>\l"
726    }
727    
728    items.loadtrim( param[0] )
729 
730    @"<div class=\"box-no-bord\"><table cellpadding=\"0\" class=\"table2\">"
731    fornum i = 0, *items
732    {
733       @"<tr class=\"\(?( i & 1, "ne-chet", "chet" ))\">\l"
734       trout( items[i] )  
735       @"</tr>\l"
736    }
737    @"</table></div>"
738 }\!
739 
740 text urltext( arrstr params )
741 \{
742    arrstr links
743    
744    links.loadtrim( params[0] )
745    foreach curlink, links
746    {
747       arrstr items
748       
749       curlink.split( items, ',', $SPLIT_FIRST | $SPLIT_NOSYS )
750       if *items == 2
751       {
752          @"#h4( #a[\(items[0])])<p>\(items[1])</p>"
753       }
754    }
755 }\!
756 
757 text header( gtitem gti, str langlink )
758 	<div class="header">
759 		<span class="logo"> </span>
760    	<noindex><span class="search">
761 \{
762 if _gtp.find("langlist")
763 {
764    foreach curl, _gtp.find("langlist")
765    {  
766       str name
767       curl as gtitem
768           
769       curl.get( "name", name )
770 	   @"<span class=\"lang\">"
771       if curl.name %== _gtp.lang : @name
772       elif *langlink
773       {
774          @"<a href=\"\(curl.value)\(langlink)\">\( name )</a>"
775       }
776       else
777       {   
778          str link
779          _gtp.geturl( gti, link )
780          @"<a href=\"\(curl.value)\(link)\">\( name )</a>"
781       }
782       @"</span>"
783    }
784 }
785 }
786 			<!-- form action="" method=get>
787 				<input type="text" class="inp" name="search">
788 				<input type="submit" value="Search"  class="sub" name="submit">
789             </form -->
790 		</span></noindex>
791 		<span class="head-fon"> </span>
792 		<br style="clear:right">
793       \@mainmenu( gti )
794 	</div>
795 \!
796 
797 text ul( arrstr params )
798 <ul>
799 \{
800    arrstr links
801    
802    links.loadtrim( params[0] )
803    foreach curlink, links
804    {
805       @"<li><span class=\"text\">\(curlink)</span></li>\l"
806    }
807 }</ul>\!
808 
809 include : "bnf.g"
Редактировать