frontend: beautiful URLs

This commit is contained in:
nemunaire 2018-01-18 11:07:50 +01:00 committed by nemunaire
parent bd75157a79
commit 0c540a39eb
13 changed files with 54 additions and 31 deletions

View file

@ -120,7 +120,7 @@ func createExercice(theme fic.Theme, body []byte) (interface{}, error) {
}
}
return theme.AddExercice(ue.Title, ue.Path, ue.Statement, ue.Overview, depend, ue.Gain, ue.VideoURI)
return theme.AddExercice(ue.Title, ue.URLId, ue.Path, ue.Statement, ue.Overview, depend, ue.Gain, ue.VideoURI)
}

View file

@ -108,6 +108,7 @@ func showThemedExercice(theme fic.Theme, exercice fic.Exercice, body []byte) (in
type uploadedTheme struct {
Name string
URLId string
Authors string
Intro string
}
@ -122,7 +123,7 @@ func createTheme(_ httprouter.Params, body []byte) (interface{}, error) {
return nil, errors.New("Theme's name not filled")
}
return fic.CreateTheme(ut.Name, ut.Authors, ut.Intro)
return fic.CreateTheme(ut.Name, ut.URLId, ut.Authors, ut.Intro)
}
func updateTheme(theme fic.Theme, body []byte) (interface{}, error) {

View file

@ -816,7 +816,7 @@ angular.module("FICApp")
})
.controller("ThemeController", function($scope, Theme, $routeParams, $location, $rootScope, $http) {
$scope.theme = Theme.get({ themeId: $routeParams.themeId });
$scope.fields = ["name", "authors", "intro"];
$scope.fields = ["name", "urlid", "authors", "intro"];
$scope.saveTheme = function() {
if (this.theme.id) {
@ -914,7 +914,7 @@ angular.module("FICApp")
$scope.exercice = Exercice.get({ exerciceId: $routeParams.exerciceId });
}
$scope.exercices = Exercice.query();
$scope.fields = ["title", "statement", "overview", "depend", "gain", "coefficient", "videoURI"];
$scope.fields = ["title", "urlid", "statement", "overview", "depend", "gain", "coefficient", "videoURI"];
$scope.saveExercice = function() {
if (this.exercice.id) {

View file

@ -98,7 +98,7 @@ func SyncExercices(i Importer, theme fic.Theme) []string {
}
if e, err := theme.GetExerciceByTitle(ename); err != nil {
if ex, err := theme.AddExercice(ename, path.Join(theme.Name, edir), statement, overview, nil, gain, videoURI); err != nil {
if ex, err := theme.AddExercice(ename, fic.ToURLid(ename), path.Join(theme.Name, edir), statement, overview, nil, gain, videoURI); err != nil {
errs = append(errs, fmt.Sprintf("%q: error on exercice add: %s", edir, err))
continue
} else {

View file

@ -50,7 +50,7 @@ func SyncThemes(i Importer) []string {
} else if intro, err = getFileContent(i, path.Join(tname, "introduction.txt")); err != nil {
errs = append(errs, fmt.Sprintf("%q: unable to get introduction: %s", tname, err))
} else if theme, err = fic.GetThemeByName(tname); err != nil {
if _, err := fic.CreateTheme(tname, strings.Join(authors, ", "), intro); err != nil {
if _, err := fic.CreateTheme(tname, fic.ToURLid(tname), strings.Join(authors, ", "), intro); err != nil {
errs = append(errs, fmt.Sprintf("%q: an error occurs during add: %s", tname, err))
continue
}