Skip to content
Extraits de code Groupes Projets
Valider b7064677 rédigé par Jonne Haß's avatar Jonne Haß Validation de Dennis Schubert
Parcourir les fichiers

Collapse StatisticsController into NodeInfoController

parent 487b0d90
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 59 ajouts et 76 suppressions
...@@ -95,4 +95,4 @@ ...@@ -95,4 +95,4 @@
@import 'highlightjs/github'; @import 'highlightjs/github';
/* statistics */ /* statistics */
@import 'new_styles/statistics'; @import 'statistics';
.page-statistics { .page-node_info.action-statistics {
h1{ text-align: center; } h1{ text-align: center; }
h3{ h3{
......
class NodeInfoController < ApplicationController class NodeInfoController < ApplicationController
respond_to :json respond_to :json
respond_to :html, only: :statistics
def jrd def jrd
render json: NodeInfo.jrd(CGI.unescape(node_info_url("123.123").sub("123.123", "%{version}"))) render json: NodeInfo.jrd(CGI.unescape(node_info_url("123.123").sub("123.123", "%{version}")))
...@@ -13,4 +14,11 @@ class NodeInfoController < ApplicationController ...@@ -13,4 +14,11 @@ class NodeInfoController < ApplicationController
head :not_found head :not_found
end end
end end
def statistics
respond_to do |format|
format.json { render json: StatisticsPresenter.new }
format.all { @statistics = NodeInfoPresenter.new("1.0") }
end
end
end end
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class StatisticsController < ApplicationController
respond_to :html, :json
def statistics
@statistics = StatisticsPresenter.new
respond_to do |format|
format.json { render json: @statistics }
format.all
end
end
end
Fichier déplacé
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
.row
%h1= t("_statistics")
= render "statistic", name: t("statistics.name"), value: @statistics.name, activated: "serv-enabled"
= render "statistic", name: t("statistics.version"), value: @statistics.version, activated: "serv-enabled"
= render "statistic", name: t("statistics.registrations"), value: registrations_status(@statistics), activated: registrations_status_class(@statistics)
- if @statistics.expose_user_counts?
= render "statistic", name: t("statistics.total_users"), value: @statistics.total_users, activated: "serv-enabled"
= render "statistic", name: t("statistics.active_users_halfyear"), value: @statistics.halfyear_users, activated: "serv-enabled"
= render "statistic", name: t("statistics.active_users_monthly"), value: @statistics.monthly_users, activated: "serv-enabled"
- if @statistics.expose_posts_counts?
= render "statistic", name: t("statistics.local_posts"), value: @statistics.local_posts, activated: "serv-enabled"
- if @statistics.expose_comment_counts?
= render "statistic", name: t("statistics.local_comments"), value: @statistics.local_comments, activated: "serv-enabled"
.row
%h1= t("statistics.services")
- Configuration::KNOWN_SERVICES.each do |service|
= render "statistic", name: "#{service.capitalize}", value: service_status(service, @statistics.available_services), activated: service_class(service, @statistics.available_services)
.container-fluid
= render "statistics"
= render "statistics"
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
.row-fluid
%h1
= t('_statistics')
= render 'statistics/statistic', name: t('statistics.name'), value: @statistics.name, activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.version'), value: @statistics.version, activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.registrations'), value: registrations_status(@statistics), activated: registrations_status_class(@statistics)
- if @statistics.expose_user_counts?
= render 'statistics/statistic', name: t('statistics.total_users'), value: @statistics.total_users, activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.active_users_halfyear'), value: @statistics.halfyear_users, activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.active_users_monthly'), value: @statistics.monthly_users, activated: "serv-enabled"
- if @statistics.expose_posts_counts?
= render 'statistics/statistic', name: t('statistics.local_posts'), value: @statistics.local_posts, activated: "serv-enabled"
- if @statistics.expose_comment_counts?
= render 'statistics/statistic', name: t('statistics.local_comments'), value: @statistics.local_comments, activated: "serv-enabled"
.row-fluid
%h1
= t('statistics.services')
- Configuration::KNOWN_SERVICES.each do |service|
= render 'statistics/statistic', name: "#{service.capitalize}", value: service_status(service, @statistics.available_services), activated: service_class(service, @statistics.available_services)
\ No newline at end of file
= render('statistics/statistics')
\ No newline at end of file
= render('statistics/statistics')
\ No newline at end of file
...@@ -238,9 +238,7 @@ Diaspora::Application.routes.draw do ...@@ -238,9 +238,7 @@ Diaspora::Application.routes.draw do
# NodeInfo # NodeInfo
get ".well-known/nodeinfo", to: "node_info#jrd" get ".well-known/nodeinfo", to: "node_info#jrd"
get "nodeinfo/:version", to: "node_info#document", as: "node_info", constraints: {version: /\d+\.\d+/} get "nodeinfo/:version", to: "node_info#document", as: "node_info", constraints: {version: /\d+\.\d+/}
get "statistics", to: "node_info#statistics"
#Statistics
get :statistics, controller: :statistics
# Terms # Terms
if AppConfig.settings.terms.enable? if AppConfig.settings.terms.enable?
......
...@@ -51,4 +51,27 @@ describe NodeInfoController do ...@@ -51,4 +51,27 @@ describe NodeInfoController do
end end
end end
end end
describe "#statistics" do
it "responds to format json" do
get :statistics, format: "json"
expect(response.code).to eq("200")
end
it "contains json" do
get :statistics, format: "json"
json = JSON.parse(response.body)
expect(json["name"]).to be_present
end
it "responds to html" do
get :statistics, format: "html"
expect(response.code).to eq("200")
end
it "responds to mobile" do
get :statistics, format: "mobile"
expect(response.code).to eq("200")
end
end
end end
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require "spec_helper"
describe StatisticsController, type: :controller do
describe "#statistics" do
it "responds to format json" do
get :statistics, format: "json"
expect(response.code).to eq("200")
end
it "contains json" do
get :statistics, format: "json"
json = JSON.parse(response.body)
expect(json["name"]).to be_present
end
it "responds to html" do
get :statistics, format: "html"
expect(response.code).to eq("200")
end
it "responds to mobile" do
get :statistics, format: "mobile"
expect(response.code).to eq("200")
end
end
end
...@@ -112,7 +112,7 @@ describe NodeInfoPresenter do ...@@ -112,7 +112,7 @@ describe NodeInfoPresenter do
AppConfig.settings.enable_registrations = false AppConfig.settings.enable_registrations = false
end end
it "should mark openRegistrations to be false" do it "should mark open_registrations to be false" do
expect(presenter.open_registrations?).to be false expect(presenter.open_registrations?).to be false
end end
end 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