fixes #619 'add possibility to edit an url'
This commit is contained in:
parent
5fe9273b2f
commit
e9368bc8ea
1 changed files with 12 additions and 1 deletions
|
|
@ -17,9 +17,10 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from urlparse import urlsplit
|
from urlparse import urlsplit, urljoin
|
||||||
import urllib
|
import urllib
|
||||||
import datetime
|
import datetime
|
||||||
|
import re
|
||||||
|
|
||||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||||
from weboob.tools.json import json as simplejson
|
from weboob.tools.json import json as simplejson
|
||||||
|
|
@ -47,9 +48,19 @@ class MediawikiBrowser(BaseBrowser):
|
||||||
self.apiurl = apiurl
|
self.apiurl = apiurl
|
||||||
BaseBrowser.__init__(self, *args, **kwargs)
|
BaseBrowser.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
|
def url2page(self, page):
|
||||||
|
baseurl = self.PROTOCOL + '://' + self.DOMAIN + self.BASEPATH
|
||||||
|
m = re.match('^' + urljoin(baseurl, 'wiki/(.+)$'), page)
|
||||||
|
if m:
|
||||||
|
return m.group(1)
|
||||||
|
else:
|
||||||
|
return page
|
||||||
|
|
||||||
def get_wiki_source(self, page):
|
def get_wiki_source(self, page):
|
||||||
assert isinstance(self.apiurl, basestring)
|
assert isinstance(self.apiurl, basestring)
|
||||||
|
|
||||||
|
page = self.url2page(page)
|
||||||
|
|
||||||
data = {'action': 'query',
|
data = {'action': 'query',
|
||||||
'prop': 'revisions|info',
|
'prop': 'revisions|info',
|
||||||
'titles': page,
|
'titles': page,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue