dokuwiki 1.1 → 1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/lib/dokuwiki.rb +18 -13
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4effc5859bdfa6574a0903d3eafd653d0a61809ad303d71464ccfb9c702271a4
4
- data.tar.gz: fcb2d6da0763a49c229e817f47fea8b9ba8af348a7699a3cfc6815b2b808aed5
3
+ metadata.gz: fbbc62f3ad854a8ce431488a5d2a41c9693c7fa1d072e4413e4be4d79596b45f
4
+ data.tar.gz: 2e18e0bbbb54312f2c3c0d19ccce3426199994f7395dcbc486d96dbe1670ac0d
5
5
  SHA512:
6
- metadata.gz: 3380449ad3ebfbdb85ad0ce132694d200197ae77252be700f60e414a83576b9f2e3f70cf8626331ba1d4b6e713110bd854b687ba70ef495fe0f633df9e3647f4
7
- data.tar.gz: bb1d7815938efb1218716831708fef824853ffc9abbcbffdf2626bd10ace455425138d715fd42d579f0788f56fc44a5a8fcd94888607a98999902d7b4ec05ff3
6
+ metadata.gz: 319c5f9d2526537add900357a46a3257a75c2d70065caf050569c9d29b04ecef8d87bf10d06524b1f1dc61d4a704cb1a6bd1846a6b5e8531810e0d216845287e
7
+ data.tar.gz: 8c7f5f37defffe8931d79b66c7e40a046060193c1668271124e175b5775bf849b1477a93655677057c27866eee684781669af34c26bb1918ea577a06f1a0f984
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 1.3 (2024-03-11)
2
+
3
+ - downloads pages via raw instead of edit
4
+
5
+ ## 1.2 (2022-04-13)
6
+
7
+ - add support for csv, svg and txt media files
8
+
1
9
  ## 1.1 (2021-01-09)
2
10
 
3
11
  - fix media dir
data/lib/dokuwiki.rb CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/local/bin/ruby -w
1
+ # frozen_string_literal: true
2
2
 
3
3
  # = dokuwiki.rb
4
4
  #
@@ -14,7 +14,6 @@
14
14
  require 'rubygems'
15
15
  require 'http-cookie'
16
16
  require 'mechanize'
17
- require 'pp'
18
17
 
19
18
  # Module for accessing DokuWiki
20
19
  module DokuWiki
@@ -27,6 +26,7 @@ module DokuWiki
27
26
  # DokuWiki.upload_dir
28
27
  # DokuWiki.wait_second
29
28
  # DokuWiki.namespace( wikipath )
29
+ # DokuWiki.export_url( wikipath )
30
30
  # DokuWiki.edit_url( wikipath )
31
31
  # DokuWiki.get( url )
32
32
  # DokuWiki.login( wikipath, user, pass )
@@ -44,9 +44,9 @@ module DokuWiki
44
44
  #
45
45
  class DokuWikiAccess
46
46
  # extension for files in dokuwiki syntax
47
- EXTENSION = 'wiki'.freeze
47
+ EXTENSION = 'wiki'
48
48
  # filename for cookie cache
49
- COOKIES = 'cookies.txt'.freeze
49
+ COOKIES = 'cookies.txt'
50
50
 
51
51
  # directory for media download cache
52
52
  attr_accessor :media_dir
@@ -89,6 +89,11 @@ module DokuWiki
89
89
  wikipath.gsub( ':', '%3A' ).freeze
90
90
  end
91
91
 
92
+ # make export url
93
+ def export_url( wikipath )
94
+ "#{@dokuwiki_page_url}#{wikipath}&do=export_raw"
95
+ end
96
+
92
97
  # make edit url
93
98
  def edit_url( wikipath )
94
99
  "#{@dokuwiki_page_url}#{wikipath}&do=edit"
@@ -158,11 +163,10 @@ module DokuWiki
158
163
 
159
164
  # save wiki source to file
160
165
  def save_wiki_source( page, filename )
161
- f = page.form_with( id: 'dw__editform' )
162
- wikitext = f.field_with( name: 'wikitext' ).value.delete( "\r" )
166
+ wikitext = ''
167
+ wikitext = page.body \
168
+ if page.header[ 'content-type' ].include?( 'text/plain' )
163
169
  file_put_contents( filename, wikitext )
164
- button = f.button_with( name: 'do[draftdel]' )
165
- @agent.submit( f, button )
166
170
  end
167
171
 
168
172
  # save wiki body to file
@@ -185,18 +189,19 @@ module DokuWiki
185
189
  # save wiki path to file
186
190
  def save_wiki_path( wikipath )
187
191
  filename = wikipath.split( ':' ).last
188
- case wikipath
189
- when /[.]jpe?g$/, /[.]png$/, /[.]pdf$/
192
+ extension = filename.split( '.' ).last
193
+ case extension
194
+ when 'jpg', 'jpeg', 'png', 'svg', 'pdf', 'csv', 'txt', '.text'
190
195
  url = @dokuwiki_media_url + wikipath
191
196
  save_wiki_media( filename, url )
192
- when /[.]css$/
197
+ when 'css'
193
198
  url = @dokuwiki_css_url + wikipath.sub( /[.]css$/, '' )
194
199
  save_wiki_media( filename, url )
195
- when /[.]html$/
200
+ when 'html'
196
201
  url = @dokuwiki_page_url + wikipath.sub( /[.]html$/, '' )
197
202
  save_wiki_body( filename, url )
198
203
  else
199
- url = edit_url( wikipath )
204
+ url = export_url( wikipath )
200
205
  filename << ".#{EXTENSION}"
201
206
  page = get( url )
202
207
  save_wiki_source( page, filename )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dokuwiki
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: '1.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dirk Meyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-09 00:00:00.000000000 Z
11
+ date: 2024-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-cookie
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  requirements: []
85
- rubygems_version: 3.0.8
85
+ rubygems_version: 3.4.19
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: access DokuWiki server