Skip to content
Extraits de code Groupes Projets
Valider 27fc49d7 rédigé par Eugen Rochko's avatar Eugen Rochko
Parcourir les fichiers

Add simple admin overview of PuSH subscriptions

parent 7e5e33df
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -234,3 +234,4 @@ body { ...@@ -234,3 +234,4 @@ body {
@import 'stream_entries'; @import 'stream_entries';
@import 'components'; @import 'components';
@import 'about'; @import 'about';
@import 'tables';
.table {
width: 100%;
max-width: 100%;
border-spacing: 0;
border-collapse: collapse;
th, td {
padding: 8px;
line-height: 1.42857143;
vertical-align: top;
border-top: 1px solid #ddd;
text-align: left;
}
& > thead > tr > th {
vertical-align: bottom;
border-bottom: 2px solid #ddd;
border-top: 0;
font-weight: 500;
}
}
samp {
font-family: 'Roboto Mono', monospace;
}
# frozen_string_literal: true
class Admin::PubsubhubbubController < ApplicationController
before_action :require_admin!
layout 'public'
def index
@subscriptions = Subscription.includes(:account).paginate(page: params[:page], per_page: 40)
end
end
...@@ -31,6 +31,10 @@ class ApplicationController < ActionController::Base ...@@ -31,6 +31,10 @@ class ApplicationController < ActionController::Base
I18n.locale = I18n.default_locale I18n.locale = I18n.default_locale
end end
def require_admin!
redirect_to root_path unless current_user&.admin?
end
protected protected
def not_found def not_found
......
module Admin::PubsubhubbubHelper
end
%table.table
%thead
%tr
%th Topic
%th Callback URL
%th Confirmed
%th Expires in
%tbody
- @subscriptions.each do |subscription|
%tr
%td
%samp= subscription.account.acct
%td
%samp= subscription.callback_url
%td
- if subscription.confirmed?
%i.fa.fa-check
%td= distance_of_time_in_words(Time.now, subscription.expires_at)
= will_paginate @subscriptions, pagination_options
...@@ -44,6 +44,10 @@ Rails.application.routes.draw do ...@@ -44,6 +44,10 @@ Rails.application.routes.draw do
resources :media, only: [:show] resources :media, only: [:show]
resources :tags, only: [:show] resources :tags, only: [:show]
namespace :admin do
resources :pubsubhubbub, only: [:index]
end
namespace :api do namespace :api do
# PubSubHubbub outgoing subscriptions # PubSubHubbub outgoing subscriptions
resources :subscriptions, only: [:show] resources :subscriptions, only: [:show]
......
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Admin::PubsubhubbubController, type: :controller do
describe 'GET #index' do
before do
sign_in :user, Fabricate(:user, admin: true)
end
it 'returns http success' do
get :index
expect(response).to have_http_status(:success)
end
end
end
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the Admin::PubsubhubbubHelper. For example:
#
# describe Admin::PubsubhubbubHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe Admin::PubsubhubbubHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter