-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b068dbd
commit 88490e3
Showing
52 changed files
with
252 additions
and
195 deletions.
There are no files selected for viewing
This file contains 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 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 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,33 @@ | ||
package templates | ||
|
||
import ( | ||
"code.gitea.io/gitea/modules/setting" | ||
"code.gitea.io/gitea/modules/translation" | ||
"html/template" | ||
"time" | ||
) | ||
|
||
func parseLegacy(datetime string) time.Time { | ||
t, err := time.Parse(time.RFC3339, datetime) | ||
if err != nil { | ||
t, _ = time.ParseInLocation(time.DateOnly, datetime, setting.DefaultUILocation) | ||
} | ||
return t | ||
} | ||
|
||
func dateTimeLegacy(format string, datetime any, _ ...string) template.HTML { | ||
if !setting.IsProd || setting.IsInTesting { | ||
panic("dateTimeLegacy is for backward compatibility only, do not use it in new code") | ||
} | ||
if s, ok := datetime.(string); ok { | ||
datetime = parseLegacy(s) | ||
} | ||
return dateTimeFormat(format, datetime) | ||
} | ||
|
||
func timeSinceLegacy(time any, _ translation.Locale) template.HTML { | ||
if !setting.IsProd || setting.IsInTesting { | ||
panic("timeSinceLegacy is for backward compatibility only, do not use it in new code") | ||
} | ||
return TimeSince(time) | ||
} |
This file contains 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 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,40 @@ | ||
package templates | ||
|
||
import ( | ||
issues_model "code.gitea.io/gitea/models/issues" | ||
"code.gitea.io/gitea/modules/translation" | ||
"context" | ||
"html/template" | ||
) | ||
|
||
func renderEmojiLegacy(ctx context.Context, text string) template.HTML { | ||
return NewRenderUtils(ctx).RenderEmoji(text) | ||
} | ||
|
||
func renderLabelLegacy(ctx context.Context, locale translation.Locale, label *issues_model.Label) template.HTML { | ||
return NewRenderUtils(ctx).RenderLabel(label) | ||
} | ||
|
||
func renderLabelsLegacy(ctx context.Context, locale translation.Locale, labels []*issues_model.Label, repoLink string, issue *issues_model.Issue) template.HTML { | ||
return NewRenderUtils(ctx).RenderLabels(labels, repoLink, issue) | ||
} | ||
|
||
func renderMarkdownToHtmlLegacy(ctx context.Context, input string) template.HTML { //nolint:revive | ||
return NewRenderUtils(ctx).MarkdownToHtml(input) | ||
} | ||
|
||
func renderCommitMessageLegacy(ctx context.Context, msg string, metas map[string]string) template.HTML { | ||
return NewRenderUtils(ctx).RenderCommitMessage(msg, metas) | ||
} | ||
|
||
func renderCommitMessageLinkSubjectLegacy(ctx context.Context, msg, urlDefault string, metas map[string]string) template.HTML { | ||
return NewRenderUtils(ctx).RenderCommitMessageLinkSubject(msg, urlDefault, metas) | ||
} | ||
|
||
func renderIssueTitleLegacy(ctx context.Context, text string, metas map[string]string) template.HTML { | ||
return NewRenderUtils(ctx).RenderIssueTitle(text, metas) | ||
} | ||
|
||
func renderCommitBodyLegacy(ctx context.Context, msg string, metas map[string]string) template.HTML { | ||
return NewRenderUtils(ctx).RenderCommitBody(msg, metas) | ||
} |
This file contains 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 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 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 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 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.