통계 배너

:discourse2: 요약 Stat Banner은 홈페이지에 사이트 통계 목록을 표시합니다
:eyeglasses: 미리보기 Discourse Theme Creator에서 미리보기
:hammer_and_wrench: 저장소 https://github.com/discourse/discourse-stat-banner
:open_book: Discourse 테마가 처음이신가요? Discourse 테마 사용 입문가 가이드

이 테마 컴포넌트 설치

기능

표시할 통계를 원하는 만큼 생성할 수 있으며, 통계 값은 /about 페이지에서 채워지고 다음 중 선택할 수 있습니다:

  • 주제(topics)
  • 게시글(posts)
  • 활성 사용자
  • 사용자
  • 좋아요
  • 채팅 메시지
  • 채팅 채널
  • 채팅 사용자

이들은 각각 3가지 기간 중 하나에서 개별적으로 설정할 수 있습니다:

  • 1일
  • 7일
  • 30일

소스와 기간 외에도 다음을 구성할 수 있습니다:

  • 제목(title)
  • 링크(link) (선택 사항)
  • manual_value (선택 사항, 자동 값을 덮어씀)

설정

이름 설명
통계 표시
배너 제목
표시 위치
배경색 Discourse 색상 변수 또는 16진수 값
텍스트 색상 Discourse 색상 변수 또는 16진수 값
최소 열 너비
모바일에서 숨김
플러그인 아웃렛 이 컴포넌트가 표시되는 플러그인 아웃렛입니다. above-main-container 또는 below-site-header를 사용해 보세요. 플러그인 아웃렛 위치 테마 컴포넌트에서 더 많은 아웃렛을 찾을 수 있습니다.
캐시 비활성화 배너 통계는 배너가 표시될 때마다 새로고침됩니다. 이는 서버 부하를 약간 증가시킬 수 있다는 점에 유의하세요.

:discourse2: 우리의 호스팅을 사용 중이신가요? 테마 컴포넌트는 Standard, Business, Enterprise 플랜에서 사용할 수 있습니다.

29개의 좋아요

iPhone SE doesn’t obey hide on mobile.

Edit: looks like any mobile don’t follow that setting and the banner is always visible.

3개의 좋아요

And one small UX/UI request — links should look like a link.

3개의 좋아요

Thanks for the quick feedback @Jagster! I just updated it to fix these issues

3개의 좋아요

Hi, @awesomerobot,

Thank you very much for this Theme Component; I definitely snapped this up.

I have a question for you if you don’t mind, as I’m slightly confused. I understand the ‘Active Users’ as it’s self-explanatory, however, what do ‘Users’ cover?

Good question!

Active users is users seen within that 1/7/30 day time period (they visited the site logged in)

Users is the number of new accounts created within the 1/7/30 day time period

2개의 좋아요

Good morning, @awesomerobot,

I’ve spent some time reflecting on this theme component and, based on your answer regarding ‘Users’ and ‘Active Users’, it doesn’t seem as though the information has been refreshed recently. I also seem to have two different values for these metrics.

Here are my stats on desktop:

And on mobile:

Even though the difference isn’t substantial, I can’t seem to figure out where these stats are being pulled from.

I’ve tried implementing a Refresh HTML Code for the Statistics like so:

<script>
  setInterval(function() {
    location.reload();
  }, 60000); // Refresh every 1 minute (60000 milliseconds)
</script>

Note: The code will reload the page every 1 minute (60000 milliseconds). You can adjust the interval as per your requirements.

However, I’m unsure if this can be added into the settings editor.

Any help would be greatly appreciated.

1개의 좋아요

Update:

I’ve come to the conclusion it should look like this?

[
	{
		"setting": "display_stats",
		"value": "[{\"source\":\"posts\",\"period\":\"30_days\",\"title\":\"Posts\",\"link\":\"\",\"manual_value\":\"\"},{\"source\":\"likes\",\"period\":\"30_days\",\"title\":\"Likes\",\"link\":\"\",\"manual_value\":\"\"},{\"source\":\"active_users\",\"period\":\"30_days\",\"title\":\"Active Users\",\"link\":\"\",\"manual_value\":\"\"},{\"source\":\"users\",\"period\":\"30_days\",\"title\":\"Sign-Ups\",\"link\":\"\",\"manual_value\":\"\"}]"
	},
	{
		"setting": "banner_title",
		"value": "Statistics for the past 30 days"
	},
	{
		"setting": "show_on",
		"value": "homepage"
	},
	{
		"setting": "background_color",
		"value": "var(--tertiary-low)"
	},
	{
		"setting": "text_color",
		"value": "var(--primary)"
	},
	{
		"setting": "min_column_width",
		"value": "10em"
	},
	{
		"setting": "hide_on_mobile",
		"value": false
	},
	{
		"setting": "plugin_outlet",
		"value": "above-main-container"
	},
	{
		"setting": "javascript",
		"value": "setInterval(function() { Discourse.__container__.lookup('controller:widget').send('refresh'); }, 3600000);"
	}
]

However, I get an error message:

javascript: These settings were added. Please remove them and try again.

The stats are pulled from the about page, they use the same data from the table at the bottom of that page:

The data in the banner is refreshed based on the lowest stat period, from the time that the user first saw the banner.

So for example, if you have the banner configured with stats from the last day, after you initially see the banner it will refresh its data in 24 hours. If the banner is configured to show only stats from the last month, the data will refresh a month after you first viewed it (or if you clear your browser localStorage).

It was implemented this way to reduce the number of requests made, so rather than show updated stats every time the banner is viewed, they’re cached in the browser’s localStorage.

This editor is only for editing existing settings, you can not add new ones (or javascript) here at all.

If you’re looking for this banner to update more often, I could add a new setting that will disable caching.

2개의 좋아요

Hi, @awesomerobot

Thank you for the detailed response and for providing the source of the stats. However, I’m still facing the same issue with the stats displayed on my mobile phone, which has been the case since I initially installed it.

According to my understanding, my stats should have been updated to the following by now:

I have also tried clearing my browser cache, but it hasn’t made any difference.

I would greatly appreciate it if this option is possible, as it would provide a more comprehensive insight into the forum for consumers.

2개의 좋아요

those look like the stats from /admin, which are probably a little different from those on /about, but regardless… if you update the component I’ve added a setting to disable caching:

Screenshot 2023-10-30 at 2.03.15 PM

5개의 좋아요

Wonderful, it functions flawlessly! Once I activated the setting, it immediately refreshed. This approach is far simpler than clearing the cache since I always keep the forum open, along with many others!

Thank you for your dedication!

2개의 좋아요

Is there a way to set the period so that it is showing ‘all time’ stats?

Additionally it would awesome if I could display total ‘votes’ as calculated by this component: Topic Voting | Discourse - Civilized Discussion

The component is looking up stats from /about.json. So I guess “all time” could be added rather easily as it’s an available value as well.

However, if you’d want to display other stats I guess you’d need to fork and adjust the component so it looks up those values from where they are available.

2개의 좋아요

So I can update this manually in the settings JSON since it’s not in the dropdown?

No, if you add an entry to manual_value, it will just replace the looked up value with a static one. Maybe naming this field static_value would convey this better?

You can get the all-time count by adding the all-time period selector to the dropdown:

It’s just a simple change in the settings file of the component. I pushed a branch with this here: https://github.com/nolosb/discourse-stat-banner/tree/count. However, for a PR it would probably still need some logic to rename that variable on the dropdown?

1개의 좋아요

Incredible, thank you for adding this!

2개의 좋아요

Is there any way to limit it to a specific category? I tried to above-category-heading outlet and wanted to at least use CSS to limit it to a specific category, but then it’s not displayed anywhere

1개의 좋아요

if you change the theme setting show_on to everywhere you should be able to use this CSS to display it in a single category (replace examplecategory with your relevant category slug)

.stat-banner__wrapper {
  display: none;
}

body.category-examplecategory {
  .stat-banner__wrapper {
    display: block;
  }
}
1개의 좋아요