serlo / serlo-export

Export Serlo.org and Mathe für Nicht-Freaks articles into various output formats
https://de.serlo.org/
Apache License 2.0
5 stars 1 forks source link

Add possibility to download certain version ids of an article. #58

Closed kulla closed 6 years ago

kulla commented 7 years ago

In our article there shall be a function get_content_by_id(revisionid) whereby revisionid is the unique id of an article version. For example https://de.wikibooks.org/w/index.php?title=Mathe_f%C3%BCr_Nicht-Freaks:_Supremum_und_Infimum&oldid=823239 has the version id 823239. The function get_content_by_id(revisionid) can be cached.

The implementation of get_content_by_title(...) can be

def __init__(self, db)
    self.db = db

    # create self.revisions as a hash with title -> revisionid

def get_current_revision(title):
    assert isprefix("Mathe für Nicht-Freaks", "title")

    return self.revisions[title]

def get_content_by_title(self, title)
    self.get_content_by_id(self, self.get_current_revision(title))