Coder Social home page Coder Social logo

0xasahi / neogroup Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 5.0 1.64 MB

Donation: https://ko-fi.com/neogroup

Home Page: https://neogrp.club/

License: MIT License

Python 27.88% CSS 13.93% JavaScript 25.45% Sass 9.52% HTML 18.89% SCSS 4.32%
community groups mastodon

neogroup's Introduction

开篇

NeoGroup,灵感来源于 NeoDB,NeoDB 里几乎涵盖了豆瓣全部的书影音功能,但是唯独缺少了小组和同城功能,作为这两个功能的重度使用者,决定做点什么,所以也模仿 NeoDB,开发了一个基于 Mastodon 登录的去中心化小组产品

TODO

  • i18n
  • 首页增加关注的用户的发布的帖子

前端 Dev

使用了 django-react-templatetags 提供的 django 插件进行前后端(伪)分离渲染,源文件在 /static_source 目录,编译至 /common/static/react/ 文件夹。开发前首先确保安装了 node.js 和 yarn ,然后从根目录执行以下命令:

cd static_source
yarn
yarn dev

以上执行均无问题的话(执行过程可能 OOM 需要手动设置一下 ),就可以开始开发啦~


以新建一个 Nav 导航栏组件为例

首先在 static_source/src/components/ 下新建一个 Nav.jsx 文件( 样式可写在同目录下的 style.scss 里 import ):

https://github.com/anig1scur/neogroup/blob/style/static_source/src/components/Nav/index.jsx

然后在 App 这里对外导出。

确保 {% load react %} 以后可以在 django 模板中使用如下语句进行一个组件的渲染:

{% react_render component="Nav" %}

也可以传 props 到组件中,更多使用请看 django-react-templatetags

Server Side Rendering

cd static_source
node hypernova-bootstrap.js

neogroup's People

Contributors

0xasahi avatar anig1scur avatar ommyzhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

neogroup's Issues

对帖子页面的一点前端建议

建议移动端风格更原生一点,右上角的“三”可以改成“...”出下拉菜单,或者直接去掉(现在这几个链接基本不会从帖子页面点,还是去掉吧),左上角常驻返回按钮“<”,去掉文字“去看看”和图标。

“分享到联邦宇宙”按钮在移动端根本看不到title,建议直接改为输入框下方的checkbox,或者点击下拉切换(类似mastodon的可见性选择)。

是不是保持redirect_uri来源一致比较好?

OAuth2认证登录流程中用到的redirect_uri需要和创建app时的保持一致(准确说是包含),但是目前neogroup中两者是不同的来源。

前者来自请求的host

url = request.scheme + "://" + request.get_host() + reverse("users:OAuth2_login")

neogroup/mastodon/api.py

Lines 377 to 379 in b9a63b4

redirect_uri = (
request.scheme + "://" + request.get_host() + reverse("users:OAuth2_login")
)

后者来自settings中的固定值

"redirect_uris": settings.REDIRECT_URIS,

这种不一致增加了不必要的复杂性。我遇到的具体情况是,第一次跑时不知道要带环境变量APP_URL,于是登录过程中,创建app时redirect_uris设置成了默认的 https://neogrp.club ,而登录时redirect_uri是基于浏览器中的访问地址( http://neogrp.localhost:8000 ),导致“无效的回调地址”。由于可见的网址中redirect_uri是“正确”的,很难定位问题,最后只有上mastodon的服务器查表才发现原因(mastodon和pleroma的ctl工具都没有提供查看app的功能)。

此外,请求中的host头本身也不算很稳定的来源。

我建议统一用settings中配置的地址。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.