-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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 1 commit
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,53 @@ | ||
| --- | ||
| 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 Text Template](https://pkg.go.dev/text/template) | ||
wxiaoguang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## 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
|
||
|
|
||
| Guidelines specialized for Gitea: | ||
6543 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 1. Every feature (Fomantic-UI/jQuery module) should be put in separated files/directories. | ||
wxiaoguang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 2. HTML id/css-class-name should use kebab-case. | ||
| 3. HTML id/css-class-name used by JavaScript top-level selector should be unique in whole project, | ||
| and should contain 2-3 feature related keywords. Recommend to use `js-` prefix for CSS names for JavaScript usage only. | ||
wxiaoguang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 4. jQuery events across different features should use their own namespaces. | ||
| 5. CSS styles provided by frameworks should not be overwritten by framework's selectors globally. | ||
| Always use new defined CSS names to overwrite framework styles. Recommend to use `us-` prefix for user defined styles. | ||
wxiaoguang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 6. Backend can pass data to frontend (JavaScript) by `ctx.PageData["myModuleData"] = map{}` | ||
wxiaoguang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 7. Simple pages and SEO-related pages use Go Text Template render to generate static Fomantic-UI HTML output. Complex pages can use Vue2 (or Vue3 in future). | ||
wxiaoguang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Legacy Problems and Solutions | ||
|
|
||
| ### Too many codes in `web_src/index.js` | ||
wxiaoguang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| In history, many JavaScript codes are written into `web_src/index.js` directly, which becomes too big to maintain. | ||
| We should split this file into small modules, the separated files can be put in `web_src/js/features` for the first step. | ||
wxiaoguang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Vue2/Vue3 and JSX | ||
|
|
||
| Gitea is using Vue2 now, we have plan to upgrade to Vue3. We decide not to introduce JSX now to make sure the HTML and JavaScript codes are not mixed together. | ||
wxiaoguang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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.