# 홈 라우터의 주제 목록을 최신에서 팔로우로 변경

**URL:** https://meta.discourse.org/t/change-topic-list-home-router-from-latest-to-following/169828
**Category:** Development
**Created:** [11월 11, 2020, 2:06오후 UTC](https://meta.discourse.org/t/change-topic-list-home-router-from-latest-to-following/169828 "2020-11-11T14:06:32Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![feabila](https://avatars.discourse-cdn.com/v4/letter/f/e9bcb4/32.png) [@feabila](https://meta.discourse.org/u/feabila)
#### Post date: [11월 11, 2020, 2:06오후 UTC](https://meta.discourse.org/t/change-topic-list-home-router-from-latest-to-following/169828/1 "2020-11-11T14:06:32Z")

</div>

여러분 안녕하세요!

기본 홈 토픽 목록 라우터를 변경하려고 시도하고 있지만, 아직 방법을 찾지 못했습니다! 여러분이 도와주셨으면 좋겠습니다.

"최신(Latest)"에서 “팔로우(Following)”(제가 팔로우하는 사용자가 생성한 토픽)로 변경하려고 합니다.

## **시도해 본 방법** :

- 가장 효율적인 방법은 상단 메뉴에 "팔로우"를 추가하는 것이었는데, 작동하지 않았습니다. ![Screen Shot 2020-11-11 at 10.57.41](https://global.discourse-cdn.com/meta/original/3X/c/2/c2a92656ee6ed0353d1622425d4564411d194ec6.png)
- 다른 방법으로는 [Custom Top Navigation Links](https://meta.discourse.org/t/custom-top-navigation-links/87225) 를 설치하는 것이었습니다. 이를 통해 제어 내비게이션 링크를 추가할 수 있었지만, 라우트 경로 “/” (루트)는 여전히 "최신"으로 표시됩니다.
- 또 다른 방법은 "filters"가 정의된 “discourse/app/routes/app-route-map.js” 파일을 조작하는 것이었습니다. 이것도 작동하지 않았습니다.
  - `this.route("discovery", { path: "/", resetNamespace: true }, function () {`

## 제 목표:

- "[http://localhost:3000/](http://localhost:3000/)"에서 표시되는 토픽 목록을 "최신"에서 "팔로우"로 변경하는 것입니다. [Discourse Follow](https://meta.discourse.org/t/follow-plugin/110579) 덕분에 가능한 일입니다. 이 라우트는 이미 존재하므로 "/following"을 얻으면 작동하지만, 이 라우트가 “/” 경로에서 수행되기를 원했습니다.

이것이 가능한가요!?

여러분의 도움이 부탁드립니다!  
감사합니다,  
Felipe

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [11월 11, 2020, 6:06오후 UTC](https://meta.discourse.org/t/change-topic-list-home-router-from-latest-to-following/169828/2 "2020-11-11T18:06:00Z")

</div>

최근에 제출한 PR이 도움이 될 수 있습니다.

여기서 Bookmarks를 기본 보기 후보에 추가했습니다:

> [@기본 홈 페이지로 "북마크" 보기 설정](https://meta.discourse.org/t/bookmarks-view-as-default-home-page/153560/14?u=merefield):
>
> Currently trundling through CI checks …

가장 어려웠던 부분은 테스트 케이스를 추가하는 것이었습니다! 🙂

이것은 플러그인에 대한 PR으로 고려할 수 있습니다. 까다로운 부분은 현재 표시할 내용이 있을 때만 표시되므로, 이 점을 고려해야 한다는 것입니다 …

> <https://github.com/discourse/discourse-follow/blob/3a92727ca6dde826be7bfda8a134835809cc2891/assets/javascripts/discourse/initializers/follow-initializer.js.es6#L19>

---

<div class="post-metadata">

### Author: ![feabila](https://avatars.discourse-cdn.com/v4/letter/f/e9bcb4/32.png) [@feabila](https://meta.discourse.org/u/feabila)
#### Post date: [11월 11, 2020, 9:14오후 UTC](https://meta.discourse.org/t/change-topic-list-home-router-from-latest-to-following/169828/3 "2020-11-11T21:14:53Z")

</div>

로버트, 안녕하세요! 말씀해 주신 PR의 두 파일을 수정했습니다.

- discourse/app/models/user\_option.rb
  - when 7 then “following”

- discourse/app/controllers/preferences/interface.js
  - USER\_HOMES 상수에 “following” 추가  
 ![Screen Shot 2020-11-11 at 18.08.20](https://global.discourse-cdn.com/meta/original/3X/d/a/da054837a2b7955c8fd4f6cda39c2c586c76ad4d.png)

결과가 나오지 않았습니다. 이 변경 사항으로 “상단 메뉴” 사이트 설정을 선택할 수 있을 것이라 생각했습니다. 따라서 "latest"가 필수적이라면 “following” - “latest” 순서로 배치하여 홈이 "following"으로 리다이렉트되도록 하려 했습니다.

개발 중에 다음 코드를 통해 방법을 찾았습니다.

```
import { setDefaultHomepage } from 'discourse/lib/utilities';

```

그래서 제 컴포넌트 시작 부분에 다음 코드를 넣었습니다.

```
setDefaultHomepage("following");

```

Rails 콘솔에서 **SiteSetting.homepage** 변수가 "latest"로 설정되어 있는 것을 발견했기 때문입니다.  
그리고 성공했습니다 😃!

문제가 될 만한 부분이 보이나요?

백엔드에서 latest를 로드하고 이니셜라이저가 클라이언트 사이드에서 로드되는 것에 대해 우려됩니다.

감사합니다,  
Felipe

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [11월 11, 2020, 9:18오후 UTC](https://meta.discourse.org/t/change-topic-list-home-router-from-latest-to-following/169828/4 "2020-11-11T21:18:34Z")

</div>

아니, Ruby 파일을 직접 수정할 수는 없습니다. 그건 그냥 힌트였을 뿐이에요. 결국 그 사례에서 제가 그랬던 것처럼 코어에 PR을 제출하는 게 아니니까요. plugin.rb의 플러그인 초기화 부분에서 해당 내용을 수정하는 방법을 찾아야 할 것 같아요… 이건 코어가 아니라 플러그인 쪽의 변경 사항이 됩니다.

---

<div class="post-metadata">

### Author: ![feabila](https://avatars.discourse-cdn.com/v4/letter/f/e9bcb4/32.png) [@feabila](https://meta.discourse.org/u/feabila)
#### Post date: [11월 11, 2020, 10:04오후 UTC](https://meta.discourse.org/t/change-topic-list-home-router-from-latest-to-following/169828/5 "2020-11-11T22:04:59Z")

</div>

요오!

말씀하신 대로 **plugin.rb** 에서 "following"를 유일한 옵션으로 지정하면 됩니다:

```
UserOption.class_eval do
	def homepage 
		"following"
	end 
end

```

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [11월 11, 2020, 10:11오후 UTC](https://meta.discourse.org/t/change-topic-list-home-router-from-latest-to-following/169828/6 "2020-11-11T22:11:57Z")

</div>

> [@feabila](#):
>
> **plugin.rb** 에서 말씀하신 대로 "following"을 유일한 옵션으로 설정하는 것이 가능했습니다:

하하, 그렇게 하는 방법 중 하나는 맞지만, 실제로는 옵션을 추가하는 방식으로 처리하고, 사용자에게 항상 변경할 수 있는 선택지를 주는 것이 좋습니다 … 이 플러그인이 플러그인에 병합되기를 원한다면요 😉

그래도 좋습니다, 계속 발전시켜 보세요.

참고로, 이것도 확인해 보세요:

> [@Override existing Discourse methods in plugins](https://meta.discourse.org/t/tips-for-overriding-existing-discourse-methods-in-plugins/83389):
>
> I’ve been running into a bunch of instances recently of needing to override existing ruby methods from plugins, and thought I’d share my best practices here. Overriding an instance method class ::TopicQuery module BabbleDefaultResults def default\_results(options={}) super(options).where('archetype \<\> ?', Archetype.chat) end end prepend BabbleDefaultResults end Here I’m removing chat topics from an instance method which is returning a list of topics. The module name BabbleD…
