Git Product home page Git Product logo

share_and_talk's Introduction

Share And Talk Blog Website

English | 中文(简体)

Website Homepage

1. Introduction😁

  1. Multi-user (currently only supports qq avatars and gravatar avatars)
  2. Blog publishing, liking, editing, deleting
  3. Support for primary and secondary classification tags
  4. Support for article markdown syntax, code highlighting, Katex scientific formulas, and flowchart diagrams

Environments

  • win10x64 and above
  • Python 3.11.2
  • Mysql 8.0.32
  • Apache 2.4.46

2. Installation🍔

2.0 Docker Installation(recommended)

Please install docker first

2.0.1 Clone project

git clone https://github.com/StarrySky-skyler/Share_And_Talk.git

2.0.2 Run

docker compose up -d

2.0.3 Stop

docker compose stop

2.0.4 Delete services

docker compose down

2.1 Method 2: Manual Installation

2.1.1 Clone the project to local

pip install wheel
git clone https://github.com/StarrySky-skyler/Share_And_Talk.git

2.1.2 Install dependencies

It is recommended to create venv or other virtual environment first

pip install -r requirements.txt

2.1.3 Configure the database

First, create a new database, using utf8mb4

Open ShareAndTalk/config.py

# Database settings
dbName = 'share_and_talk'
dbUser = 'root'
dbPassword = 'skyler'
# Email settings
EMAIL_USER = 'Your email'
EMAIL_PASSWORD = 'Your password'
DEFAULT_FROM = 'Your email'

Detailes:

  • dbName : Database name
  • dbUser : Database username
  • dbPassword : Password for the corresponding user

Enter commands below

py manage.py makemigrations
py manage.py migrate

Import example database

py manage.py loaddata backup/example.json

Notice:

the example database contains

  1. a superuser. Its username is root, password is skyler

  2. a help page

  3. some default categories

2.1.4 Configure language and timezone

Default language: Simplified Chinese

Default timezone: GMT+8

See ShareAndTalk/settings.py

LANGUAGE_CODE = 'zh-hans'

TIME_ZONE = 'Asia/Shanghai'

Detailed configuration reference:

Language Identifier List🚅

Time Zone List 1 Wikipedia🧪

Time Zone List 2🎈

If you need to change to another language, you also need to delete the following code from ShareAndTalk/settings.py

# Default language
LANGUAGES = [
    ('zh-hans', '中文(简体)'),
]

2.1.5 Configure email (optional)

Used for "user feedback" at the bottom of the homepage

Open ShareAndTalk/config.py

# Database settings
dbName = 'share_and_talk'
dbUser = 'root'
dbPassword = 'skyler'
# Email settings
EMAIL_USER = 'Your email'
EMAIL_PASSWORD = 'Your password'
DEFAULT_FROM = 'Your email'

Details:

  • EMAIL_USER : Recipient email
  • EMAIL_PASSWORD : Email key
  • DEFAULT_FROM : Sending email address

See detailed reference django email configuration

2.1.6 Create a superuser

In the root directory of this project, open cmd or powershell or other terminals and enter the following command

py manage.py createsuperuser

Follow the prompts to create

2.1.7 Deployment🌭

  1. Open ShareAndTalk/settings.py and change
DEBUG = True

to

DEBUG = False
  1. Open powershell, go to the repository root directory, and run the following command to copy the static files to the static folder
py manage.py collectstatic

The static folder will be automatically created after running the command. If you need to change the folder location, please modify the following code in ShareAndTalk/settings.py

STATIC_URL = "static/"
if not DEBUG:
    STATICFILES_DIRS = (
    os.path.join(BASE_DIR, '/static/'), # Change your static folder here
    )
    STATIC_ROOT = os.path.join(BASE_DIR,'static') # Change your static folder here
  1. Configure apache2, see Notion Note

3. Supplementary Information💻

The location where website users upload files is saved in the uploads folder. If you need to change it, locate the following code at the end of ShareAndTalk/settings.py

# mdeditor
X_FRAME_OPTIONS = 'SAMEORIGIN'
MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
MEDIA_URL = '/media/'

Just modify MEDIA_ROOT to a string containing the absolute path

Common Commands

  1. Restore table structure (enter mysql first)
source backup/db_structure.sql;
  1. Restore database data
py manage.py loaddata backup/xxx.json
  1. Django Shell
py manage.py shell
  1. Backup json data
py -Xutf8 manage.py dumpdata > db.json

share_and_talk's People

Contributors

starrysky-skyler avatar

Stargazers

 avatar

Watchers

 avatar

share_and_talk's Issues

[Feature] 增加网易云音乐外联播放器

前端示例

参考插入下面一段代码在 html 里

{% csrf_token %}
<iframe id="fixed-iframe" frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="https://music.163.com/outchain/player?type=2&id=2102108609&auto=1&height=66"></iframe>

可以用 css 固定一下

#fixed-iframe {
    position: fixed;
    right: 0;
    bottom: 0;
    width: 300px; /* 设置iframe宽度 */
    height: 200px; /* 设置iframe高度 */
    z-index: 999; /* 确保iframe在其他元素之上 */
}

后端调整

需要给每个文章加一个url网易云音乐链接字段

[Fix] 项目调整

TODO

  1. 重构代码
  2. cdn或者前端使用模糊加载图片
  3. 用户编辑文章和登录时弹出的toast窗口,改为cookie方式判断
  4. 压缩js和css文件
  5. 用户登录界面调整
  6. 后台管理不应出现密码加密值的调整
  7. 其他性能优化
  8. 编写尽可能全覆盖的自动化测试,可以用from django.test import TestCase
  9. 用户图片为qq头像时,应对qq号加密
  10. 新建测试管理员xjq
  11. CI在每次提交/pull request时运行测试
  12. CD自动发布,无需更改README.md自动修改最新版本

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.