search
HomeWeb Front-endJS TutorialDetailed explanation of blog content management system

Detailed explanation of blog content management system

Feb 22, 2018 pm 01:36 PM
contentmanagement systemDetailed explanation

1. Update content

  1. The database was redesigned and changed to a subDocs database structure grouped by users

  2. In response to database changes , all interfaces have been redesigned, and the interface style consistent with Lima Finance

  3. is deleted, the original guest mode is added, the login registration function is added, and pop-up window login is supported.

  4. Add a homepage to display the latest published articles and registered users

  5. Add functions such as password modification, logout, and logout.

  6. 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.

  7. Add mobile terminal adaptation

  8. 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 true

  • css: Customize the class of the pop-up window , the default is empty

  • showClose: If it is false, the close button will not be displayed, the default is

  • closeFn : The callback after clicking the close button of the pop-up window

  • title: The title of the pop-up window, the default is 'warm reminder', if you don't want to display the title, pass it directly Empty

  • content(required): The content of the pop-up window supports passing html

  • btn1: 'Button 1 copy | Button 1 style class', formatted to btn1Text and btn1Css

  • cb1: 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 button

  • btn2: 'Button 2 copy|Button 2 style class', formatted to btn2Text and btn2Css

  • cb2: 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 window

  • init: 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 disappears

  • wapGoDialog: 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

20 PHP CMS open source content management systems

Based on laravel framework content management system

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
From Websites to Apps: The Diverse Applications of JavaScriptFrom Websites to Apps: The Diverse Applications of JavaScriptApr 22, 2025 am 12:02 AM

JavaScript is widely used in websites, mobile applications, desktop applications and server-side programming. 1) In website development, JavaScript operates DOM together with HTML and CSS to achieve dynamic effects and supports frameworks such as jQuery and React. 2) Through ReactNative and Ionic, JavaScript is used to develop cross-platform mobile applications. 3) The Electron framework enables JavaScript to build desktop applications. 4) Node.js allows JavaScript to run on the server side and supports high concurrent requests.

Python vs. JavaScript: Use Cases and Applications ComparedPython vs. JavaScript: Use Cases and Applications ComparedApr 21, 2025 am 12:01 AM

Python is more suitable for data science and automation, while JavaScript is more suitable for front-end and full-stack development. 1. Python performs well in data science and machine learning, using libraries such as NumPy and Pandas for data processing and modeling. 2. Python is concise and efficient in automation and scripting. 3. JavaScript is indispensable in front-end development and is used to build dynamic web pages and single-page applications. 4. JavaScript plays a role in back-end development through Node.js and supports full-stack development.

The Role of C/C   in JavaScript Interpreters and CompilersThe Role of C/C in JavaScript Interpreters and CompilersApr 20, 2025 am 12:01 AM

C and C play a vital role in the JavaScript engine, mainly used to implement interpreters and JIT compilers. 1) C is used to parse JavaScript source code and generate an abstract syntax tree. 2) C is responsible for generating and executing bytecode. 3) C implements the JIT compiler, optimizes and compiles hot-spot code at runtime, and significantly improves the execution efficiency of JavaScript.

JavaScript in Action: Real-World Examples and ProjectsJavaScript in Action: Real-World Examples and ProjectsApr 19, 2025 am 12:13 AM

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

JavaScript and the Web: Core Functionality and Use CasesJavaScript and the Web: Core Functionality and Use CasesApr 18, 2025 am 12:19 AM

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding the JavaScript Engine: Implementation DetailsUnderstanding the JavaScript Engine: Implementation DetailsApr 17, 2025 am 12:05 AM

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python vs. JavaScript: The Learning Curve and Ease of UsePython vs. JavaScript: The Learning Curve and Ease of UseApr 16, 2025 am 12:12 AM

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python vs. JavaScript: Community, Libraries, and ResourcesPython vs. JavaScript: Community, Libraries, and ResourcesApr 15, 2025 am 12:16 AM

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools