Collapse StatisticsController into NodeInfoController
This commit is contained in:
parent
487b0d90ca
commit
b7064677ff
15 changed files with 59 additions and 76 deletions
|
|
@ -95,4 +95,4 @@
|
|||
@import 'highlightjs/github';
|
||||
|
||||
/* statistics */
|
||||
@import 'new_styles/statistics';
|
||||
@import 'statistics';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
.page-statistics {
|
||||
.page-node_info.action-statistics {
|
||||
h1{ text-align: center; }
|
||||
|
||||
h3{
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
class NodeInfoController < ApplicationController
|
||||
respond_to :json
|
||||
respond_to :html, only: :statistics
|
||||
|
||||
def jrd
|
||||
render json: NodeInfo.jrd(CGI.unescape(node_info_url("123.123").sub("123.123", "%{version}")))
|
||||
|
|
@ -13,4 +14,11 @@ class NodeInfoController < ApplicationController
|
|||
head :not_found
|
||||
end
|
||||
end
|
||||
|
||||
def statistics
|
||||
respond_to do |format|
|
||||
format.json { render json: StatisticsPresenter.new }
|
||||
format.all { @statistics = NodeInfoPresenter.new("1.0") }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
# 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
|
||||
21
app/views/node_info/_statistics.haml
Normal file
21
app/views/node_info/_statistics.haml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
-# 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)
|
||||
2
app/views/node_info/statistics.html.haml
Normal file
2
app/views/node_info/statistics.html.haml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
.container-fluid
|
||||
= render "statistics"
|
||||
1
app/views/node_info/statistics.mobile.haml
Normal file
1
app/views/node_info/statistics.mobile.haml
Normal file
|
|
@ -0,0 +1 @@
|
|||
= render "statistics"
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
-# 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)
|
||||
|
|
@ -1 +0,0 @@
|
|||
= render('statistics/statistics')
|
||||
|
|
@ -1 +0,0 @@
|
|||
= render('statistics/statistics')
|
||||
|
|
@ -238,9 +238,7 @@ Diaspora::Application.routes.draw do
|
|||
# NodeInfo
|
||||
get ".well-known/nodeinfo", to: "node_info#jrd"
|
||||
get "nodeinfo/:version", to: "node_info#document", as: "node_info", constraints: {version: /\d+\.\d+/}
|
||||
|
||||
#Statistics
|
||||
get :statistics, controller: :statistics
|
||||
get "statistics", to: "node_info#statistics"
|
||||
|
||||
# Terms
|
||||
if AppConfig.settings.terms.enable?
|
||||
|
|
|
|||
|
|
@ -51,4 +51,27 @@ describe NodeInfoController do
|
|||
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
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
# 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
|
|||
AppConfig.settings.enable_registrations = false
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue