-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Frontend refactor: move Vue related code from index.js
to components
dir, and remove unused codes.
#17301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Frontend refactor: move Vue related code from index.js
to components
dir, and remove unused codes.
#17301
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
50f6aeb
frontend refactor
wxiaoguang ec69e6d
Apply suggestions from code review
wxiaoguang 01ae9d7
Update templates/base/head.tmpl
wxiaoguang 3d312ad
Update docs/content/doc/developers/guidelines-frontend.md
wxiaoguang f092f19
fix typo
wxiaoguang b0c0494
fix typo
wxiaoguang f27d1a8
Merge branch 'main' into frontend-refactor
6543 f1eb378
refactor PageData to pageData
wxiaoguang 3d51f1b
Merge branch 'frontend-refactor' of github.com:wxiaoguang/gitea into …
wxiaoguang 4d78ad9
Apply suggestions from code review
6543 2595a58
Simply for the visual difference.
6543 0a2b420
Merge branch 'main' into frontend-refactor
6543 ec2ec55
Revert "Apply suggestions from code review"
6543 3eee3f2
Merge branch 'main' into frontend-refactor
lunny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
date: "2021-10-13T16:00:00+02:00" | ||
title: "Guidelines for Frontend Development" | ||
slug: "guidelines-frontend" | ||
weight: 20 | ||
toc: false | ||
draft: false | ||
menu: | ||
sidebar: | ||
parent: "developers" | ||
name: "Guidelines for Frontend" | ||
weight: 20 | ||
identifier: "guidelines-frontend" | ||
--- | ||
|
||
# Guidelines for Frontend Development | ||
|
||
**Table of Contents** | ||
|
||
{{< toc >}} | ||
|
||
## Background | ||
|
||
Gitea uses [Less CSS](https://lesscss.org), [Fomantic-UI](https://fomantic-ui.com/introduction/getting-started.html) (based on [jQuery](https://api.jquery.com)) and [Vue2](https://vuejs.org/v2/guide/) for its frontend. | ||
|
||
The HTML pages are rendered by [Go HTML Template](https://pkg.go.dev/html/template) | ||
|
||
## General Guidelines | ||
|
||
We recommend [Google HTML/CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.html) and [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html) | ||
6543 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Gitea specific guidelines: | ||
|
||
1. Every feature (Fomantic-UI/jQuery module) should be put in separate files/directories. | ||
2. HTML ids and classes should use kebab-case. | ||
3. HTML ids and classes used in JavaScript should be unique for the whole project, and should contain 2-3 feature related keywords. We recommend to use the `js-` prefix for classes that are only used in JavaScript. | ||
4. jQuery events across different features should use their own namespaces. | ||
5. CSS styling for classes provided by frameworks should not be overwritten. Always use new class-names to overwrite framework styles. We recommend to use the `us-` prefix for user defined styles. | ||
6. The backend can pass complex data to the frontend by using `ctx.PageData["myModuleData"] = map[]{}` | ||
7. Simple pages and SEO-related pages use Go HTML Template render to generate static Fomantic-UI HTML output. Complex pages can use Vue2 (or Vue3 in future). | ||
|
||
## Legacy Problems and Solutions | ||
|
||
### Too much code in `web_src/index.js` | ||
|
||
Previously, most JavaScript code was written into `web_src/index.js` directly, making the file unmaintainable. | ||
Try to keep this file small by creating new modules instead. These modules can be put in the `web_src/js/features` directory for now. | ||
|
||
### Vue2/Vue3 and JSX | ||
|
||
Gitea is using Vue2 now, we plan to upgrade to Vue3. We decided not to introduce JSX to keep the HTML and the JavaScript code separated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.