1
0
Fork 0
mirror of https://github.com/veekun/pokedex.git synced 2024-08-20 18:16:34 +00:00

Move Markdown handling to the translation classes

- the Session has a `pokedex_link_maker` property, whose `object_url`
  method is used to make URLs in Markdown
- pokemon.names_table.name is now an ordinary Unicode column
- pokemon.name is a MarkdownString that is aware of the session and the
  language the string is in
- pokemon.name_map is a dict-like association_proxy of the above
- move.effect works similarly, with transparent $effect_chance substitution
  as before
This commit is contained in:
Petr Viktorin 2011-04-20 21:47:37 +02:00
parent 5a6ff3d27b
commit 85d779ba83
5 changed files with 165 additions and 119 deletions
pokedex/db

View file

@ -18,6 +18,10 @@ Columns have a info dictionary with these keys:
- ripped: True for text that has been ripped from the games, and can be ripped
again for new versions or languages
- string_getter: for translation columns, a function taking (text, session,
language) that is used for properties on the main table. Used for Markdown
text.
See `pokedex.db.multilang` for how localizable text columns work. The session
classes in that module can be used to change the default language.
"""
@ -124,10 +128,10 @@ create_translation_table('ability_names', Ability, 'names',
info=dict(description="The name", format='plaintext', official=True, ripped=True)),
)
create_translation_table('ability_prose', Ability, 'prose',
effect = Column(markdown.MarkdownColumn(5120), nullable=True,
info=dict(description="A detailed description of this ability's effect", format='markdown')),
short_effect = Column(markdown.MarkdownColumn(512), nullable=True,
info=dict(description="A short summary of this ability's effect", format='markdown')),
effect = Column(Unicode(5120), nullable=True,
info=dict(description="A detailed description of this ability's effect", format='markdown', string_getter=markdown.MarkdownString)),
short_effect = Column(Unicode(512), nullable=True,
info=dict(description="A short summary of this ability's effect", format='markdown', string_getter=markdown.MarkdownString)),
)
class AbilityChangelog(TableBase):
@ -142,8 +146,8 @@ class AbilityChangelog(TableBase):
info=dict(description="The ID of the version group in which the ability changed"))
create_translation_table('ability_changelog_prose', AbilityChangelog, 'prose',
effect = Column(markdown.MarkdownColumn(255), nullable=False,
info=dict(description="A description of the old behavior", format='markdown'))
effect = Column(Unicode(255), nullable=False,
info=dict(description="A description of the old behavior", format='markdown', string_getter=markdown.MarkdownString))
)
class AbilityFlavorText(TableBase):
@ -503,10 +507,10 @@ create_translation_table('item_names', Item, 'names',
info=dict(description="The name", format='plaintext', official=True, ripped=True)),
)
create_translation_table('item_prose', Item, 'prose',
short_effect = Column(markdown.MarkdownColumn(256), nullable=True,
info=dict(description="A short summary of the effect", format='markdown')),
effect = Column(markdown.MarkdownColumn(5120), nullable=True,
info=dict(description=u"Detailed description of the item's effect.", format='markdown')),
short_effect = Column(Unicode(256), nullable=True,
info=dict(description="A short summary of the effect", format='markdown', string_getter=markdown.MarkdownString)),
effect = Column(Unicode(5120), nullable=True,
info=dict(description=u"Detailed description of the item's effect.", format='markdown', string_getter=markdown.MarkdownString)),
)
create_translation_table('item_flavor_summaries', Item, 'flavor_summaries',
flavor_summary = Column(Unicode(512), nullable=True,
@ -803,7 +807,7 @@ class MoveEffect(TableBase):
create_translation_table('move_effect_prose', MoveEffect, 'prose',
short_effect = Column(Unicode(256), nullable=True,
info=dict(description="A short summary of the effect", format='plaintext')),
info=dict(description="A short summary of the effect", format='markdown')),
effect = Column(Unicode(5120), nullable=True,
info=dict(description="A detailed description of the effect", format='markdown')),
)
@ -825,8 +829,8 @@ class MoveEffectChangelog(TableBase):
)
create_translation_table('move_effect_changelog_prose', MoveEffectChangelog, 'prose',
effect = Column(markdown.MarkdownColumn(512), nullable=False,
info=dict(description="A description of the old behavior", format='markdown')),
effect = Column(Unicode(512), nullable=False,
info=dict(description="A description of the old behavior", format='markdown', string_getter=markdown.MarkdownString)),
)
class MoveFlag(TableBase):
@ -854,8 +858,8 @@ create_translation_table('move_flag_type_prose', MoveFlagType, 'prose',
relation_lazy='joined',
name = Column(Unicode(32), nullable=True, index=True,
info=dict(description="The name", format='plaintext', official=False)),
description = Column(markdown.MarkdownColumn(256), nullable=True,
info=dict(description="A short description of the flag", format='markdown')),
description = Column(Unicode(256), nullable=True,
info=dict(description="A short description of the flag", format='markdown', string_getter=markdown.MarkdownString)),
)
class MoveFlavorText(TableBase):
@ -1355,8 +1359,8 @@ PokemonFormGroup.id = PokemonFormGroup.pokemon_id
create_translation_table('pokemon_form_group_prose', PokemonFormGroup, 'prose',
term = Column(Unicode(16), nullable=True,
info=dict(description=u"The term for this Pokémon's forms, e.g. \"Cloak\" for Burmy or \"Forme\" for Deoxys.", official=True, format='plaintext')),
description = Column(markdown.MarkdownColumn(1024), nullable=True,
info=dict(description=u"Description of how the forms work", format='markdown')),
description = Column(Unicode(1024), nullable=True,
info=dict(description=u"Description of how the forms work", format='markdown', string_getter=markdown.MarkdownString)),
)
class PokemonFormPokeathlonStat(TableBase):