mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-03-13 15:39:18 +08:00
parent
e68a3c772f
commit
e8474b6fc1
@ -123,18 +123,18 @@ export default {
|
||||
open: Boolean,
|
||||
},
|
||||
watch: {
|
||||
preCooked() {
|
||||
this.$nextTick(() => {
|
||||
console.log("running");
|
||||
window.admonition();
|
||||
});
|
||||
},
|
||||
previewContent() {
|
||||
this.$nextTick(() => {
|
||||
console.log("running");
|
||||
window.admonition();
|
||||
});
|
||||
}
|
||||
preCooked() {
|
||||
this.$nextTick(() => {
|
||||
console.log('running');
|
||||
window.admonition();
|
||||
});
|
||||
},
|
||||
previewContent() {
|
||||
this.$nextTick(() => {
|
||||
console.log('running');
|
||||
window.admonition();
|
||||
});
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
content: {
|
||||
|
@ -130,7 +130,7 @@
|
||||
<div class="input-group-prepend">
|
||||
<label for="keywords-input" class="input-group-text"> <i class="fas fa-key"></i> Keywords </label>
|
||||
</div>
|
||||
<input id="keywords-input" name="keywords" type="text" class="form-control" />
|
||||
<input id="keywords-input" name="keywords" type="text" class="form-control" placeholder="(separated by spaces)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -26,8 +26,11 @@
|
||||
<i class="fas fa-download"></i>
|
||||
{{ $t('general.download') }}
|
||||
</a>
|
||||
<button type="button" class="btn btn-primary copy-url"
|
||||
:data-clipboard-text="baseUrl + ROUTES.parse('VERSIONS_DOWNLOAD_RECOMMENDED', project.ownerName, project.slug)">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary copy-url"
|
||||
:data-clipboard-text="baseUrl + ROUTES.parse('VERSIONS_DOWNLOAD_RECOMMENDED', project.ownerName, project.slug)"
|
||||
>
|
||||
<i class="fas fa-copy"></i>
|
||||
</button>
|
||||
</div>
|
||||
@ -217,7 +220,7 @@ export default {
|
||||
editorOpen: window.EDITOR_OPEN,
|
||||
canManageMembers: window.CAN_MANAGE_MEMBERS,
|
||||
filteredMembers: window.FILTERED_MEMBERS,
|
||||
baseUrl: window.location.origin
|
||||
baseUrl: window.location.origin,
|
||||
};
|
||||
},
|
||||
created() {
|
||||
|
@ -19,10 +19,10 @@ import {
|
||||
faCircle,
|
||||
faClipboard,
|
||||
faCode,
|
||||
faCopy,
|
||||
faCog,
|
||||
faComment,
|
||||
faComments,
|
||||
faCopy,
|
||||
faDownload,
|
||||
faEdit,
|
||||
faExclamationCircle,
|
||||
@ -184,7 +184,7 @@ library.add(
|
||||
faBirthdayCake,
|
||||
faArrowsAltV,
|
||||
faUndo,
|
||||
faCopy,
|
||||
faCopy
|
||||
);
|
||||
|
||||
dom.watch();
|
||||
|
@ -173,7 +173,7 @@ public class ProjectsController extends HangarController {
|
||||
project = projectFactory.createProject(ownerUser, category, newProjectForm);
|
||||
} catch (HangarException ex) {
|
||||
ModelAndView mav = showCreator();
|
||||
AlertUtil.showAlert(mav, AlertUtil.AlertType.ERROR, ex.getMessageKey());
|
||||
AlertUtil.showAlert(mav, AlertUtil.AlertType.ERROR, ex.getMessageKey(), ex.getArgs());
|
||||
return fillModel(mav);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,6 @@ import org.jdbi.v3.core.enums.EnumByOrdinal;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
public class ProjectsTable implements Visitable {
|
||||
|
||||
@ -39,7 +38,7 @@ public class ProjectsTable implements Visitable {
|
||||
|
||||
public ProjectsTable() { }
|
||||
|
||||
public ProjectsTable(ProjectOwner projectOwner, Category category, NewProjectForm newProjectForm) {
|
||||
public ProjectsTable(ProjectOwner projectOwner, Category category, NewProjectForm newProjectForm, Collection<String> keywords) {
|
||||
this.name = StringUtils.compact(newProjectForm.getName());
|
||||
this.slug = StringUtils.slugify(newProjectForm.getName());
|
||||
this.ownerName = projectOwner.getName();
|
||||
@ -51,8 +50,7 @@ public class ProjectsTable implements Visitable {
|
||||
this.issues = StringUtils.stringOrNull(newProjectForm.getIssueTrackerUrl());
|
||||
this.source = StringUtils.stringOrNull(newProjectForm.getSourceUrl());
|
||||
this.support = StringUtils.stringOrNull(newProjectForm.getExternalSupportUrl());
|
||||
|
||||
this.keywords = newProjectForm.getKeywords() != null ? Set.of(newProjectForm.getKeywords().split("\\s")) : Set.of();
|
||||
this.keywords = keywords;
|
||||
this.licenseName = StringUtils.stringOrNull("custom".equalsIgnoreCase(newProjectForm.getLicenseType()) ? newProjectForm.getLicenseName() : newProjectForm.getLicenseType());
|
||||
this.licenseUrl = StringUtils.stringOrNull(newProjectForm.getLicenseUrl());
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ public class HangarException extends RuntimeException {
|
||||
|
||||
public HangarException(String messageKey) {
|
||||
this.messageKey = messageKey;
|
||||
this.args = null;
|
||||
this.args = new String[0];
|
||||
}
|
||||
|
||||
public HangarException(String messageKey, String... args) {
|
||||
|
@ -43,6 +43,7 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -89,7 +90,16 @@ public class ProjectFactory {
|
||||
}
|
||||
|
||||
public ProjectsTable createProject(ProjectOwner ownerUser, Category category, NewProjectForm newProjectForm) {
|
||||
ProjectsTable projectsTable = new ProjectsTable(ownerUser, category, newProjectForm);
|
||||
Collection<String> keywords;
|
||||
try {
|
||||
keywords = StringUtils.parseKeywords(newProjectForm.getKeywords());
|
||||
if (keywords.size() > hangarConfig.projects.getMaxKeywords()) {
|
||||
throw new HangarException("error.project.maxKeywords", String.valueOf(hangarConfig.projects.getMaxKeywords()));
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new HangarException("error.project.duplicateKeyword");
|
||||
}
|
||||
ProjectsTable projectsTable = new ProjectsTable(ownerUser, category, newProjectForm, keywords);
|
||||
|
||||
ProjectChannelsTable channelsTable = new ProjectChannelsTable(hangarConfig.channels.getNameDefault(), hangarConfig.channels.getColorDefault(), -1, false);
|
||||
|
||||
|
@ -4,7 +4,9 @@ import org.springframework.lang.Nullable;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
@ -52,6 +54,11 @@ public class StringUtils {
|
||||
return input;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Collection<String> parseKeywords(@Nullable String input) {
|
||||
return input == null ? Set.of() : Set.of(input.split("\\s+"));
|
||||
}
|
||||
|
||||
public static <T extends Throwable> long getVersionId(@NotNull String versionString, T error) throws T {
|
||||
int index = versionString.lastIndexOf('.');
|
||||
try {
|
||||
|
@ -115,6 +115,7 @@ error.loginFailed = Authentication failed.
|
||||
error.project.categoryNotFound = No category with that name found.
|
||||
error.project.invalidPluginFile = Invalid plugin file.
|
||||
error.project.tooManyKeywords = Too many keywords specified.
|
||||
error.project.duplicateKeyword = Project keywords must be unique!
|
||||
error.channel.last = You cannot delete your only channel.
|
||||
error.channel.lastNonEmpty = You cannot delete your only non-empty channel.
|
||||
error.channel.lastReviewed = You cannot delete your only reviewed channel.
|
||||
|
Loading…
x
Reference in New Issue
Block a user