Commit b7064677 authored by Jonne Haß's avatar Jonne Haß Committed by Dennis Schubert

Collapse StatisticsController into NodeInfoController

parent 487b0d90
......@@ -95,4 +95,4 @@
@import 'highlightjs/github';
/* statistics */
@import 'new_styles/statistics';
@import 'statistics';
.page-statistics {
.page-node_info.action-statistics {
h1{ text-align: center; }
h3{
......
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
# 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
-# 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"
-# 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
# 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
# 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment