CoCalc Shared Fileswww / cgi-bin / mfd / glossary.pyOpen in CoCalc with one click!
Author: William A. Stein
1
############################################################################
2
# Glossary interface #
3
############################################################################
4
#
5
# new_entry: Making a new glossary entry:
6
# - phrase to define
7
# - a directory which contains:
8
# index.html -- should be something can be inserted into the middle of an HTML page.
9
# various latex files (whenever filename.tex appears in index.html, this program
10
# will run latex on filename.tex and produce dvi, ps, and pdf files, plus change
11
# index.html to have links to those files).
12
#
13
# - author
14
#
15
# table called "definition" that contains
16
# - term string
17
# - author (integer)
18
# - article (large object, which is "tar -jcvf" file).
19
20
class Definition:
21
def __init__(self, term):
22
23
def __repr__(self):
24
25
def generate_static_web_page(self, glossary):
26
# Return at string that is defines an HTML web page, constructed as follows
27
# 1. Load the definition.
28
# 2. Searches for words in the definition that are defined elsewhere in the
29
# glossary (by looping through words in the glossary and finding them in the definition).
30
# For each one found, make an appropriate hyperlink. (Be careful not to be
31
# self referential.)
32
# (We run this command for tex files: convert -crop 0x0 q_expansion.dvi q_expansion.jpg)
33
34
35
class Glossary:
36
def __init__(self):
37
38
def __repr__(self):
39
return "The elliptic curve %s"%(self.code())
40
41
def generate_static_web_pages(self, directory_name):
42
# 1. load all Definitions
43
# 2. call "generate_static_web_page" on each Definition.
44
# -- save the generated web page to a file named term_to_filename(...)
45
46
47
48
49
# given a term, e.g., "q-Expansion", returns a string which
50
# is the name of the file, e.g., "q_expansion", that the
51
# definition of "q-Expansion".
52
# Possible algorithm: change to all lower case; replace all non-alphabetic by underscores.
53
def term_to_filename(term):
54
55
def term_to_url(term):
56
# return something like
57
# url="/mfd/glossary/%s"%term_to_filename(term)
58
# actually return
59
# <a href=url>term</a>
60
# (or if need hostname, use value from constants.py)
61
# if term's definition isn't in glossary, then just return term.
62
63
64