Permalink
Browse files

Add hook for Weblate

  • Loading branch information...
1 parent 8bc4de8 commit f5f67bae95d5880510ac8ea9dadbc7a933feb1d2 @nijel nijel committed Nov 13, 2012
Showing with 40 additions and 0 deletions.
  1. +12 −0 docs/weblate
  2. +28 −0 services/weblate.rb
View
@@ -0,0 +1,12 @@
+This service will notify Weblate about pushes to your repository.
+Weblate will then refresh updated translations and merge them with your
+changes.
+
+More info: http://weblate.org/
+
+Install Notes
+-------------
+
+You need to have enabled hooks in your Weblate installation (this is default)
+see documentation for more information:
+https://weblate.readthedocs.org/en/latest/api.html#notification-hooks
View
@@ -0,0 +1,28 @@
+class Service::Weblate < Service
+ string :url
+ white_list :url
+
+ def receive_push
+ url = data['url']
+ url.gsub! /\s/, ''
+
+ if url.empty?
+ raise_config_error "Invalid URL: #{url.inspect}"
+ end
+
+ if url !~ /^https?\:\/\//
+ url = "http://#{url}"
+ end
+
+ res = http_post "#{url}/hooks/github/",
+ :payload => payload.to_json
+
+ if res.status < 200 || res.status > 299
+ raise_config_error
+ end
+ rescue URI::InvalidURIError
+ raise_config_error "Invalid URL: #{data['url']}"
+ end
+end
+
+

0 comments on commit f5f67ba

Please sign in to comment.