Detailed explanation of blog content management system
1. Update content
The database was redesigned and changed to a subDocs database structure grouped by users
In response to database changes , all interfaces have been redesigned, and the interface style consistent with Lima Finance
is deleted, the original guest mode is added, the login registration function is added, and pop-up window login is supported.
Add a homepage to display the latest published articles and registered users
Add functions such as password modification, logout, and logout.
Optimize the pop-up window component, which is more intelligent, has more configuration items, and is close to the NetEase $.dialog component. And a set of codes only modified the css to realize the PC-side pop-up window and WAP-side toast functions under the same interface.
Add mobile terminal adaptation
Optimize the original code and fix some bugs.
For more updated content, please move to projects CMS-of-Blog_Production and CMS-of-Blog.
2. Core code analysis
1. Database
Redesign the original database and change it to user grouping The subDocs database structure. In this way, the database structure with users as a whole is clearer, and it is also easier to operate and read. The code is as follows:
At the beginning of the code, three new Schemas are defined: articleSchema, linkSchema and userSchema. ArticleSchema and linkSchema are nested in userSchema, forming a subDocs database structure grouped by users. Schema is a database model skeleton stored in file form and does not have the ability to operate the database. The Schema will then be published as a Model. Model is a model generated by Schema publishing, which is a pair of database operations with abstract properties and behaviors. Entities that can be created by Model. For example, an entity will be created when a new user is registered.
After the database is created, it needs to be read and operated. You can have a look at the code that sends the email verification code when registering to get a feel for it.
After receiving the request to send the email verification code, the background will initialize a tmp user. By new db.User()
, a User instance will be created, and then the save()
operation will be performed to write this data to the database. If the registration is not successful within half an hour, delete this data by matching the email address and db.User.remove()
. For more specific usage, please go to Official Documents.
2. Background
Divides all requests into three types:
ajax asynchronous request, unified path:
/web/
Public page parts, such as blog homepage, login, registration, etc., unified path:
/
The blog part related to the blog user ID, unified path:
/:id/
So that each user can have his own blog page, The specific code is as follows:
For the specific ajax interface code, you can see the index.js file in the server folder.
3. pop/toast component
3.1 pop/toast component configuration parameter description
pop
: Whether the pop-up window is displayed or not, according to the content parameter, if there is content, it is truecss
: Customize the class of the pop-up window , the default is emptyshowClose
: If it is false, the close button will not be displayed, the default iscloseFn
: The callback after clicking the close button of the pop-up windowtitle
: The title of the pop-up window, the default is 'warm reminder', if you don't want to display the title, pass it directly Emptycontent
(required): The content of the pop-up window supports passing htmlbtn1
: 'Button 1 copy | Button 1 style class', formatted to btn1Text and btn1Csscb1
: Callback after button 1 is clicked, if cb1 does not have If true is returned explicitly, the pop-up window will be closed by default after clicking the buttonbtn2
: 'Button 2 copy|Button 2 style class', formatted to btn2Text and btn2Csscb2
: Callback after button 2 is clicked. If cb2 does not explicitly return true, the pop-up window will be closed by default after the button is clicked. The button parameters are not passed, and the copy text defaults to 'I understand'. Click to close the pop-up windowinit
: The initialization function after the pop-up window is created, which can be used to handle complex Interaction (note that the pop-up window must change from false to true before the pop-up window is executed)destroy
: Callback function after the pop-up window disappearswapGoDialog
: On the mobile terminal, whether to use the pop-up window, the default is false, use toast
3.2 pop/toast component code
3.3 pop/toast component parameter format code
For the convenience of use, we have abbreviated it when using it. In order for the component to be recognized, the incoming parameters need to be formatted in the vuex action.
In order to make the mobile terminal compatible with the pop-up window component, we use mediaQuery to change the mobile terminal style. Add parameter wapGoDialog
to indicate whether we want to use the pop-up window when we are on the mobile terminal. The default is false and use toast. In this way, one set of code can be compatible with PC and WAP.
Postscript
Here we mainly analyze the background and database, and it is relatively simple. You can check the source code. In short, this is a good example of front-end starting with back-end and database. It has rich functions, and you can learn vue.js.
Related recommendations:
The most complete PHP open source content management system CMS
The above is the detailed content of Detailed explanation of blog content management system. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Windows operating system is one of the most popular operating systems in the world, and its new version Win11 has attracted much attention. In the Win11 system, obtaining administrator rights is an important operation. Administrator rights allow users to perform more operations and settings on the system. This article will introduce in detail how to obtain administrator permissions in Win11 system and how to effectively manage permissions. In the Win11 system, administrator rights are divided into two types: local administrator and domain administrator. A local administrator has full administrative rights to the local computer

How to change the page that opens the Microsoft Edge browser to 360 navigation? It is actually very simple, so now I will share with you the method of changing the page that opens the Microsoft Edge browser to 360 navigation. Friends in need can take a look. I hope Can help everyone. Open the Microsoft Edge browser. We see a page like the one below. Click the three-dot icon in the upper right corner. Click "Settings." Click "On startup" in the left column of the settings page. Click on the three points shown in the picture in the right column (do not click "Open New Tab"), then click Edit and change the URL to "0" (or other meaningless numbers). Then click "Save". Next, select "

Detailed explanation of division operation in OracleSQL In OracleSQL, division operation is a common and important mathematical operation, used to calculate the result of dividing two numbers. Division is often used in database queries, so understanding the division operation and its usage in OracleSQL is one of the essential skills for database developers. This article will discuss the relevant knowledge of division operations in OracleSQL in detail and provide specific code examples for readers' reference. 1. Division operation in OracleSQL

The modulo operator (%) in PHP is used to obtain the remainder of the division of two numbers. In this article, we will discuss the role and usage of the modulo operator in detail, and provide specific code examples to help readers better understand. 1. The role of the modulo operator In mathematics, when we divide an integer by another integer, we get a quotient and a remainder. For example, when we divide 10 by 3, the quotient is 3 and the remainder is 1. The modulo operator is used to obtain this remainder. 2. Usage of the modulo operator In PHP, use the % symbol to represent the modulus

CheatEngine is a game editor that can edit and modify the game's memory. However, its default language is non-Chinese, which is inconvenient for many friends. So how to set Chinese in CheatEngine? Today, the editor will give you a detailed introduction to how to set up Chinese in CheatEngine. I hope it can help you. Setting method one: 1. Double-click to open the software and click "edit" in the upper left corner. 2. Then click “settings” in the option list below. 3. In the opened window interface, click "languages" in the left column

Detailed explanation of Linux system call system() function System call is a very important part of the Linux operating system. It provides a way to interact with the system kernel. Among them, the system() function is one of the commonly used system call functions. This article will introduce the use of the system() function in detail and provide corresponding code examples. Basic Concepts of System Calls System calls are a way for user programs to interact with the operating system kernel. User programs request the operating system by calling system call functions

Detailed explanation of Linux's curl command Summary: curl is a powerful command line tool used for data communication with the server. This article will introduce the basic usage of the curl command and provide actual code examples to help readers better understand and apply the command. 1. What is curl? curl is a command line tool used to send and receive various network requests. It supports multiple protocols, such as HTTP, FTP, TELNET, etc., and provides rich functions, such as file upload, file download, data transmission, proxy

Do you know where to set the download button to display in Microsoft Edge? Below, the editor will bring you the method to set the download button to display in Microsoft Edge. I hope it will be helpful to you. Let’s follow the editor to learn it! Step 1: First open Microsoft Edge Browser, click the [...] logo in the upper right corner, as shown in the figure below. Step 2: Then click [Settings] in the pop-up menu, as shown in the figure below. Step 3: Then click [Appearance] on the left side of the interface, as shown in the figure below. Step 4: Finally, click the button on the right side of [Show Download Button] and it will change from gray to blue, as shown in the figure below. The above is where the editor brings you how to set up the download button in Microsoft Edge.
