Skip to content

Commit

Permalink
Reformat changelog to be better. Refactor upload to work with new get…
Browse files Browse the repository at this point in the history
…_allowed_file_extensions method. Slightly expanded desc in gemspec. Update gemspec version.
  • Loading branch information
elifoster committed Oct 9, 2015
1 parent 3a17569 commit 165d075
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 46 deletions.
72 changes: 37 additions & 35 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
# Changelog
## Version 0
### Version 0.6.0
* New get_variables method.
* New get_function_hooks method.
* New get_extension_tags method.
* New get_skins method.
* New get_restriction_levels method.
* New get_restriction_types method.
* New get_restrictions_data method for the above methods.
* New get_allowed_file_extensions method.
* New get_all_usergroups method.
* New get_magic_words method.
* New get_special_page_aliases method.
* New get_namespace_aliases method.
* New get_namespaces method.
* New get_filerepo_favicons method.
* New get_filerepo_thumburls method.
* New get_nonlocal_filerepos method.
* New get_local_filerepos method.
* New get_filerepo_urls method.
* New get_filerepo_rooturls method.
* Refactor get_filerepo_names to use new get_filerepoinfo method.
* New get_filerepoinfo method, in a similar style to get_userlists.
* New get_current_user_options for getting a hash containing all of the currently logged in user's preferences.
* New get_email_address method for getting the currently logged in user's email address.
* New get_realname method for getting the currently logged in user's real name.
* New get_changeable_groups method for getting the currently logged in user's groups that they can change (add/remove people from)
* New current_user_hasmsg? method for checking if the user has any unread messages.
* check_login no longer returns false, ever, because any code after a fail is unreachable.
* Slightly expanded Gem description.
* Finished all Meta modules and their methods, except for the allmessages meta query. [#6](https://github.com/ftb-gamepedia/mediawiki-butt-ruby/issues/6)
* New get_variables method.
* New get_function_hooks method.
* New get_extension_tags method.
* New get_skins method.
* New get_restriction_levels method.
* New get_restriction_types method.
* New get_restrictions_data method for the above methods.
* New get_allowed_file_extensions method, and refactored #upload to only allow files with those extensions.
* New get_all_usergroups method.
* New get_magic_words method.
* New get_special_page_aliases method.
* New get_namespace_aliases method.
* New get_namespaces method.
* New get_filerepo_favicons method.
* New get_filerepo_thumburls method.
* New get_nonlocal_filerepos method.
* New get_local_filerepos method.
* New get_filerepo_urls method.
* New get_filerepo_rooturls method.
* Refactor get_filerepo_names to use new get_filerepoinfo method.
* New get_filerepoinfo method, in a similar style to get_userlists.
* New get_current_user_options for getting a hash containing all of the currently logged in user's preferences.
* New get_email_address method for getting the currently logged in user's email address.
* New get_realname method for getting the currently logged in user's real name.
* New get_changeable_groups method for getting the currently logged in user's groups that they can change (add/remove people from)
* New current_user_hasmsg? method for checking if the user has any unread messages.
* check_login no longer returns false, ever, because any code after a fail is unreachable.
* prop parameter in get_current_user_meta is now optional, for get_current_user_name.
* New get_current_user_name method, for something fairly obvious.
* New get_siteinfo method, in a similar style to get_userlists.
* New get_statistics method, for getting a hash of the wiki's statistics.
* New get_general method, for getting hash of the 'general' wiki information.
* New get_extensions method, for getting an array of all extension names installed.
* New get_languages method, for getting a hash of all the languages, formatted as code => name.
* User-Agent header is now set for each post. It defaults to 'NotLoggedIn/MediaWiki::Butt', or "#{name}/MediaWiki::Butt" if logged in. This might cause some slight performance issues ([#5](https://github.com/FTB-Gamepedia/MediaWiki-Butt-Ruby/issues/5))
* prop parameter in get_current_user_meta is now optional, for get_current_user_name.
* New get_current_user_name method, for something fairly obvious.
* New get_siteinfo method, in a similar style to get_userlists.
* New get_statistics method, for getting a hash of the wiki's statistics.
* New get_general method, for getting hash of the 'general' wiki information.
* New get_extensions method, for getting an array of all extension names installed.
* New get_languages method, for getting a hash of all the languages, formatted as code => name.
* Split up the Meta module by meta type.


### Version 0.5.0
* New Administration module for administrative methods.
Expand Down
25 changes: 16 additions & 9 deletions lib/mediawiki/edit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def create_page(title, text, summary = 'New page', bot = true)
# through regex. Optional. If ommitted, it will be everything after
# the last slash in the URL.
# @return [Boolean/String] true if the upload was successful, else the
# warning's key.
# warning's key. Returns false if the file extension is not valid.
def upload(url, *filename)
params = {
action: 'upload',
Expand All @@ -87,15 +87,22 @@ def upload(url, *filename)
filename = url.split('/')[-1]
end

token = get_token('edit', filename)
params[:filename] = filename
params[:token] = token
ext = filename.split('.')[-1]
allowed_extensions = get_allowed_file_extensions
if allowed_extensions.include? ext

response = post(params)
if response['upload']['result'] == 'Success'
return true
elsif response['upload']['result'] == 'Warning'
return response['upload']['warnings'].keys[0]
token = get_token('edit', filename)
params[:filename] = filename
params[:token] = token

response = post(params)
if response['upload']['result'] == 'Success'
return true
elsif response['upload']['result'] == 'Warning'
return response['upload']['warnings'].keys[0]
end
else
return false
end
end

Expand Down
6 changes: 4 additions & 2 deletions mediawiki-butt.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ Gem::Specification.new do |s|
s.authors = ['Eli Foster', 'Eric Schneider (xbony2)']
s.name = 'mediawiki-butt'
s.summary = 'Interacting with the MediaWiki API'
s.version = '0.5.0'
s.version = '0.6.0'
s.license = 'CC-BY-NC-ND-4.0'
# Expand on this description eventually.
s.description = <<-EOF
MediaWiki::Butt is a Ruby Gem that provides a fully-featured MediaWiki API \
interface.
interface. It includes methods for changing wiki content, authentication, \
and queries.
EOF
s.email = '[email protected]'
s.homepage = 'https://github.com/ftb-gamepedia/mediawiki-butt-ruby'
Expand Down

0 comments on commit 165d075

Please sign in to comment.