diff --git a/Gemfile b/Gemfile index effb2be6e..0347de453 100644 --- a/Gemfile +++ b/Gemfile @@ -134,3 +134,5 @@ gem 'jwt' gem 'doorkeeper' gem 'doorkeeper-jwt' + +gem 'gitea-client', '~> 0.5.1' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index e27c504aa..6e4f079fb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -106,6 +106,8 @@ GEM activerecord (>= 3.1.0, < 7) diff-lcs (1.3) diffy (3.3.0) + domain_name (0.5.20190701) + unf (>= 0.0.5, < 1.0.0) doorkeeper (5.5.1) railties (>= 5) doorkeeper-jwt (0.4.1) @@ -133,6 +135,8 @@ GEM fugit (1.4.1) et-orbi (~> 1.1, >= 1.1.8) raabro (~> 1.4) + gitea-client (0.5.1) + rest-client (~> 2.1.0) globalid (0.4.2) activesupport (>= 4.2.0) grape-entity (0.7.1) @@ -143,6 +147,9 @@ GEM harmonious_dictionary (0.0.1) hashie (3.6.0) htmlentities (4.3.4) + http-accept (1.7.0) + http-cookie (1.0.5) + domain_name (~> 0.5) i18n (1.8.2) concurrent-ruby (~> 1.0) io-like (0.3.1) @@ -180,6 +187,9 @@ GEM mimemagic (~> 0.3.2) maruku (0.7.3) method_source (0.9.2) + mime-types (3.4.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2022.0105) mimemagic (0.3.10) nokogiri (~> 1) rake @@ -193,6 +203,7 @@ GEM mustermann (1.1.1) ruby2_keywords (~> 0.0.1) mysql2 (0.5.3) + netrc (0.11.0) nio4r (2.5.2) nokogiri (1.10.8) mini_portile2 (~> 2.4.0) @@ -292,6 +303,11 @@ GEM regexp_parser (1.7.0) request_store (1.5.0) rack (>= 1.4) + rest-client (2.1.0) + http-accept (>= 1.7.0, < 2.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) reverse_markdown (1.4.0) nokogiri roo (2.8.3) @@ -418,6 +434,9 @@ GEM thread_safe (~> 0.1) uglifier (4.2.0) execjs (>= 0.3.0, < 3) + unf (0.1.4) + unf_ext + unf_ext (0.0.8.2) unicode-display_width (1.6.1) web-console (3.7.0) actionview (>= 5.0) @@ -459,6 +478,7 @@ DEPENDENCIES enumerize faraday (~> 0.15.4) font-awesome-sass (= 4.7.0) + gitea-client (~> 0.5.1) grape-entity (~> 0.7.1) groupdate (~> 4.1.0) harmonious_dictionary (~> 0.0.1) diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb new file mode 100644 index 000000000..76c527d85 --- /dev/null +++ b/app/controllers/api/v1/base_controller.rb @@ -0,0 +1,2 @@ +class Api::V1::BaseController < ApplicationController +end \ No newline at end of file diff --git a/app/controllers/api/v1/repos_controller.rb b/app/controllers/api/v1/repos_controller.rb new file mode 100644 index 000000000..667f47dbc --- /dev/null +++ b/app/controllers/api/v1/repos_controller.rb @@ -0,0 +1,6 @@ +class Api::V1::ReposController < Api::V1::BaseController + + def index + render_ok + end +end \ No newline at end of file diff --git a/config/initializers/gitea_client.rb b/config/initializers/gitea_client.rb new file mode 100644 index 000000000..92706ffd8 --- /dev/null +++ b/config/initializers/gitea_client.rb @@ -0,0 +1,11 @@ +require 'gitea-client' + +config = Rails.application.config_for(:configuration).symbolize_keys! +gitea_config = config[:gitea].symbolize_keys! + +$gitea_client = Gitea::Api::Client.new({ + domain: gitea_config[:domain], + base_url: gitea_config[:base_url], + username: gitea_config[:username], + password: gitea_config[:password] +}) \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d3b2e7f36..c0e845a85 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,11 @@ Rails.application.routes.draw do + def draw(routes_name) + instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb"))) + end + + draw :api + use_doorkeeper require 'sidekiq/web' require 'sidekiq/cron/web' diff --git a/config/routes/api.rb b/config/routes/api.rb new file mode 100644 index 000000000..718f705a6 --- /dev/null +++ b/config/routes/api.rb @@ -0,0 +1,7 @@ +defaults format: :json do + namespace :api do + namespace :v1 do + resources :repos + end + end +end \ No newline at end of file