Skip to content

Commit

Permalink
Rename 'abbreviated as' to 'short'
Browse files Browse the repository at this point in the history
  • Loading branch information
grammarware committed Feb 17, 2013
1 parent 5319862 commit 00c2fca
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 36 deletions.
46 changes: 26 additions & 20 deletions WikiPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import os
import sys

languages = ('Abbreviated as', 'English', 'German', 'French', 'Dutch', 'Russian')
flags = ('' , 'EN' , 'DE' , 'FR' , 'NL' , 'RU')
languages = ('Short', 'English', 'German', 'French', 'Dutch', 'Russian')
flags = ('' , 'EN' , 'DE' , 'FR' , 'NL' , 'RU')
code = ('**','[[','`')

class WikiPage:
Expand Down Expand Up @@ -46,11 +46,17 @@ def validate(self):
print(' * The original is expected to have line "%s"' % line)
for line in lines:
print(' * The original has unmatched line "%s"' % line)
def getNames(self):
names = []
for k in self.items.keys():
names.extend(self.items[k].getTitles())
return names
def getLanguages(self):
return sorted(self.items.keys())
def getNames(self,lang):
return self.items[lang]
def getKeywords(self):
kws = []
for lang in self.items.keys():
kws.append(lang)
# print(self.items[lang].getTitles())
kws.extend(self.items[lang].getTitles())
return kws
def getHtml(self, main):
s = '''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Expand All @@ -72,16 +78,16 @@ def getHtml(self, main):
<div>[<a href="mailto:vadim@grammarware.net">Complain!</a>]</div>
</div>
<div class="main">
''' % (', '.join(self.getNames()), main, self.main.split('.md')[0].replace(' ','-'))
''' % (', '.join(self.getKeywords()), main, self.main.split('.md')[0].replace(' ','-'))
if self.fig:
s += '<div class="fig"><a href="http://github.com/grammarware/sleg/blob/master/figures/%s"><img src="http://github.com/grammarware/slef/raw/master/figures/%s" alt="%s" title="%s"/></a><br/>(<a href="http://github.com/grammarware/sleg/blob/master/figures/%s.info.txt">info</a>)</div>' % (self.fig, self.fig, main, main, self.fig)
if self.defin:
s += '<div class="def">%s</div>\n' % self.defin.getHtml()
z = ''
for k in languages:
if k in self.items.keys():
# print('"%s" vs "%s"' % (str(self.items[k]) , main))
if self.items[k].title == main:
# print('"%s" vs "%s"' % (self.items[k].getTitle() , main))
if self.items[k].getTitle() == main:
z += '<li>%s<strong>%s</strong>: %s</li>\n' % (self.getFlag(k), k, self.items[k].getHtml())
else:
z += '<li>%s<strong>%s</strong>: %s</li>\n' % (self.getFlag(k), k, self.items[k].getHtmlLinked())
Expand Down Expand Up @@ -138,7 +144,9 @@ def __str__(self):
# English: _algebraic data type_ ([Wikipedia](http://en.wikipedia.org/wiki/Algebraic data type))
class Entry:
def __init__(self, s):
self.title = s.split('_')[1]
self.titles = []
for t in s.split(' or '):
self.titles.append(t.split('_')[1])
self.links = []
# Lng: _title_ ([W1](http://link)) ([W2](http://link))
for link in s.split(' ([')[1:]:
Expand All @@ -149,22 +157,20 @@ def __init__(self, s):
def who(self):
return self.__class__.__name__
def getTitle(self):
return self.title
# ???
return '/'.join(self.titles)
def getTitles(self):
if self.title.find('/') < 0:
return [self.title]
else:
return self.title.split('/')
return self.titles
def getHtml(self):
return self.getHtmlLinks('<em>%s</em>' % self.title)
return self.getHtmlLinks(' or '.join(['<em>%s</em>' % t for t in self.titles]))
def getHtmlLinked(self):
return self.getHtmlLinks(' or '.join(['<em><a href="%s.html">%s</a></em>' % (t,t) for t in self.titles])) # .capitalize()?
def getHtmlLinks(self, s):
for link in self.links:
s += ' (<a href="%s">%s</a>)' % (link[1], link[0])
return s
def getHtmlLinked(self):
return self.getHtmlLinks('<em><a href="%s.html">%s</a></em>' % (self.title, self.title)) # .capitalize()?
def __str__(self):
s = '_%s_' % self.title
s = ' or '.join(['_%s_' % t for t in self.titles])
for link in self.links:
s += ' ([%s](%s))' % link
return s
Expand Down
43 changes: 28 additions & 15 deletions md2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import WikiPage

names = []
names = {}

for root, dirs, filenames in os.walk('wiki/'):
for f in filter(lambda x:x.endswith('.md'),filenames):
Expand All @@ -13,16 +13,18 @@
print(f)
p = WikiPage.WikiPage('wiki/%s' % f)
p.validate()
for name in p.getNames():
try:
f = open('up/%s.html' % name,'w')
f.write(p.getHtml(name))
for name in p.getNames():
if name not in names:
names.append(name)
f.close()
except IOError:
print('"%s" cannot be accessed' % name)
for lang in p.getLanguages():
if lang not in names.keys():
names[lang] = []
for name in p.getNames(lang).getTitles():
if name not in names[lang]:
names[lang].append(name)
try:
f = open('up/%s.html' % name,'w')
f.write(p.getHtml(name))
f.close()
except IOError:
print(' !!! "%s" cannot be accessed' % name)

#
f = open('up/index.html','w')
Expand All @@ -46,10 +48,21 @@
</div>
<div class="main">
<h1>SLEG is under construction!</h1>
<h2>Unordered list of all possible pages</h2><div class="mult">''')
for name in sorted(names):
f.write('<a href="%s.html">%s</a><br/>\n' % (name,name))
f.write('''</div></div><div style="clear:both"/><hr />
<h2>Unordered list of all possible pages</h2>• ''')
for l in WikiPage.languages:
if l in names:
f.write('<a href="#%s">%s<a> • ' % (l,l))
for i in range(0,len(WikiPage.languages)):
if WikiPage.languages[i] not in names:
continue
s = '<hr/><h3>'
if WikiPage.flags[i]:
s += '<img src="www/%s.png" alt="%s"/>' % (WikiPage.flags[i], WikiPage.languages[i])
s += '<a name="%s"/>%s</h3>\n<div class="mult">\n' % (WikiPage.languages[i], WikiPage.languages[i])
for name in sorted(names[WikiPage.languages[i]]):
s += '<a href="%s.html">%s</a><br/>\n' % (name,name)
f.write(s+'</div>')
f.write('''</div><div style="clear:both"/><hr />
<div class="last">
<em>
<a href="http://github.com/grammarware/sleg">Software Language Engineering Glossary</a> (SLEG) is
Expand Down
2 changes: 1 addition & 1 deletion wiki
Submodule wiki updated from afad6b to 29dc18

0 comments on commit 00c2fca

Please sign in to comment.