From: Daryle C. L. <le...@fe...> - 2003-07-09 07:05:18
|
In my M$ world I used a program called GED2HTML which allowed generating a "mini ancestor tree" with each person. I added this to GRAMPS, however clumsily. Here is the patch for WebPage.py if anyone is interested. 66a67,68 > _hline = " " # Everything is underlined, so use blank > 95a98,159 > class MiniTree: > """ > This is one dirty piece of code, that is why I made it it's own > class. I'm sure that someone with more knowledge of GRAMPS can make > it much cleaner. > """ > def __init__(self,person,doc): > self.doc = doc > self.person = person > self.lines = [ "" for i in range(9) ] > name = self.person.getPrimaryName().getRegularName() > self.lines[4] = name > indent = (len(name) - 1) / 2 > self.lines[3] = self.lines[5] = self.lines[6] = ' ' * indent + '|' > self.draw_parents(person,2,6,indent,1) > > def draw_parents(self, person, father_line, mother_line, indent, recurse): > family = person.getMainParents() > if not family: return > > father_name = mother_name = "" > father = family.getFather() > mother = family.getMother() > if father: > father_name = father.getPrimaryName().getRegularName() > if mother: > mother_name = mother.getPrimaryName().getRegularName() > pad = len(father_name) > if pad < len(mother_name): > pad = len(mother_name) > father_name = _hline + father_name + _hline * (pad-len(father_name)+1) > mother_name = _hline + mother_name + _hline * (pad-len(mother_name)+1) > self.draw_father(father, father_name, father_line, indent) > self.draw_mother(mother, mother_name, mother_line, indent) > indent += pad+3 > if recurse: > if father: > self.draw_parents(father, father_line-1, father_line-1, > indent, 0) > if mother: > self.draw_parents(mother, mother_line+1, mother_line+1, > indent, 0) > > def draw_father(self, person, name, line, indent): > self.draw_string(line, indent, '|') > self.draw_string(line-1, indent+1, "") > self.draw_link(line-1, person, name) > > def draw_mother(self, person, name, line, indent): > self.draw_string(line+1, indent, '|') > self.draw_link(line+1, person, name) > > def draw_string(self, line, indent, text): > self.lines[line] += ' ' * (indent-len(self.lines[line])) + text > > def draw_link(self, line, person, name): > if person and person.getId(): > self.lines[line] += "<A HREF='%s%s'>%s</A>" % (person.getId(), > self.doc.ext, name) > else: > self.lines[line] += "<U>%s</U>" % name > 103c167 < def __init__(self,person,photos,restrict,private,uc,link,map, --- > def __init__(self,person,photos,restrict,private,uc,link,mini_tree,map, 116a181 > self.mini_tree = mini_tree 235a301,314 > def write_tree(self): > if not self.mini_tree or not self.person.getMainParents(): return > self.doc.start_paragraph("FamilyTitle") > self.doc.end_paragraph() > > self.doc.start_paragraph("Data") > self.doc.write_raw('<PRE>\n') > tree = MiniTree(self.person,self.doc) > for line in tree.lines: > if line: self.doc.write_raw(line + '\n') > self.doc.write_raw('</PRE>\n') > self.doc.end_paragraph() > > 318a398,400 > # draw mini-tree > self.write_tree() > 585,586c667,668 < private, srccomments, include_link, style, image_dir, < template_name,use_id,id_link,gendex,ext): --- > private, srccomments, include_link, include_mini_tree, > style, image_dir, template_name,use_id,id_link,gendex,ext): 599a682 > self.include_mini_tree = include_mini_tree 800,801c883,885 < self.include_link, my_map, dir_name, < self.image_dir, tdoc, self.use_id,self.id_link,self.ext) --- > self.include_link, self.include_mini_tree, > my_map, dir_name, self.image_dir, tdoc, > self.use_id,self.id_link,self.ext) 853a938,941 > tree_msg = _("Include short ancestor tree") > self.mini_tree = gtk.CheckButton(tree_msg) > self.mini_tree.set_active(1) > 873a962 > self.add_option('',self.mini_tree) 1103a1193 > self.include_mini_tree = self.mini_tree.get_active() 1153c1243,1244 < self.include_link, self.selected_style, --- > self.include_link, self.include_mini_tree, > self.selected_style, |