frontend: beautiful URLs
This commit is contained in:
parent
bd75157a79
commit
0c540a39eb
13 changed files with 54 additions and 31 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Reference in a new issue