Implement and display headlines in interface
This commit is contained in:
parent
abd7fc6bef
commit
8c95782eff
13 changed files with 85 additions and 58 deletions
|
|
@ -144,6 +144,10 @@ func partUpdateExercice(exercice fic.Exercice, body []byte) (interface{}, error)
|
|||
exercice.Statement = ue.Statement
|
||||
}
|
||||
|
||||
if len(ue.Headline) > 0 {
|
||||
exercice.Headline = ue.Headline
|
||||
}
|
||||
|
||||
if len(ue.Overview) > 0 {
|
||||
exercice.Overview = ue.Overview
|
||||
}
|
||||
|
|
@ -199,7 +203,7 @@ func createExercice(theme fic.Theme, body []byte) (interface{}, error) {
|
|||
}
|
||||
}
|
||||
|
||||
return theme.AddExercice(ue.Title, ue.URLId, ue.Path, ue.Statement, ue.Overview, depend, ue.Gain, ue.VideoURI)
|
||||
return theme.AddExercice(ue.Title, ue.URLId, ue.Path, ue.Statement, ue.Overview, ue.Headline, depend, ue.Gain, ue.VideoURI)
|
||||
}
|
||||
|
||||
type uploadedHint struct {
|
||||
|
|
|
|||
|
|
@ -146,15 +146,8 @@ func showThemedExercice(theme fic.Theme, exercice fic.Exercice, body []byte) (in
|
|||
return exercice, nil
|
||||
}
|
||||
|
||||
type uploadedTheme struct {
|
||||
Name string
|
||||
URLId string
|
||||
Authors string
|
||||
Intro string
|
||||
}
|
||||
|
||||
func createTheme(_ httprouter.Params, body []byte) (interface{}, error) {
|
||||
var ut uploadedTheme
|
||||
var ut fic.Theme
|
||||
if err := json.Unmarshal(body, &ut); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -163,7 +156,7 @@ func createTheme(_ httprouter.Params, body []byte) (interface{}, error) {
|
|||
return nil, errors.New("Theme's name not filled")
|
||||
}
|
||||
|
||||
return fic.CreateTheme(ut.Name, ut.URLId, "", ut.Authors, ut.Intro, "")
|
||||
return fic.CreateTheme(ut.Name, ut.URLId, "", ut.Authors, ut.Intro, ut.Headline, ut.Image)
|
||||
}
|
||||
|
||||
func updateTheme(theme fic.Theme, body []byte) (interface{}, error) {
|
||||
|
|
|
|||
|
|
@ -929,7 +929,7 @@ angular.module("FICApp")
|
|||
})
|
||||
.controller("ThemeController", function($scope, Theme, $routeParams, $location, $rootScope, $http) {
|
||||
$scope.theme = Theme.get({ themeId: $routeParams.themeId });
|
||||
$scope.fields = ["name", "urlid", "authors", "intro", "image"];
|
||||
$scope.fields = ["name", "urlid", "authors", "headline", "intro", "image"];
|
||||
|
||||
$scope.saveTheme = function() {
|
||||
if (this.theme.id) {
|
||||
|
|
@ -1044,7 +1044,7 @@ angular.module("FICApp")
|
|||
$scope.exercice = Exercice.get({ exerciceId: $routeParams.exerciceId });
|
||||
}
|
||||
$scope.exercices = Exercice.query();
|
||||
$scope.fields = ["title", "urlid", "statement", "overview", "depend", "gain", "coefficient", "videoURI", "issue", "issuekind"];
|
||||
$scope.fields = ["title", "urlid", "statement", "headline", "overview", "depend", "gain", "coefficient", "videoURI", "issue", "issuekind"];
|
||||
|
||||
$scope.showTags = false;
|
||||
$scope.toggleTags = function(val) {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ func SyncExercices(i Importer, theme fic.Theme) []string {
|
|||
if err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: overview.txt: %s", edir, err))
|
||||
}
|
||||
ovrvw := strings.Split(overview, "\n")
|
||||
headline := ovrvw[0]
|
||||
if len(ovrvw) > 1 {
|
||||
overview = strings.Join(ovrvw[1:], "\n")
|
||||
}
|
||||
|
||||
statement, err := getFileContent(i, path.Join(theme.Path, edir, "statement.txt"))
|
||||
if err != nil {
|
||||
|
|
@ -111,18 +116,20 @@ func SyncExercices(i Importer, theme fic.Theme) []string {
|
|||
// Markdown pre-formating
|
||||
statement = string(blackfriday.Run([]byte(statement)))
|
||||
overview = string(blackfriday.Run([]byte(overview)))
|
||||
headline = string(blackfriday.Run([]byte(headline)))
|
||||
|
||||
e, err := theme.GetExerciceByTitle(ename)
|
||||
if err != nil {
|
||||
if e, err = theme.AddExercice(ename, fic.ToURLid(ename), path.Join(theme.Path, edir), statement, overview, depend, gain, videoURI); err != nil {
|
||||
if e, err = theme.AddExercice(ename, fic.ToURLid(ename), path.Join(theme.Path, edir), statement, overview, headline, depend, gain, videoURI); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: error on exercice add: %s", edir, err))
|
||||
continue
|
||||
}
|
||||
} else if e.Title != ename || e.URLId == "" || e.Statement != statement || e.Overview != overview || e.Gain != gain || e.VideoURI != videoURI {
|
||||
} else if e.Title != ename || e.URLId == "" || e.Statement != statement || e.Overview != overview || e.Headline != headline || e.Gain != gain || e.VideoURI != videoURI {
|
||||
e.Title = ename
|
||||
e.URLId = fic.ToURLid(ename)
|
||||
e.Statement = statement
|
||||
e.Overview = overview
|
||||
e.Headline = headline
|
||||
e.Gain = gain
|
||||
e.VideoURI = videoURI
|
||||
if _, err := e.Update(); err != nil {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ func SyncThemes(i Importer) []string {
|
|||
for _, tdir := range themes {
|
||||
var authors []string
|
||||
var intro string
|
||||
var headline string
|
||||
var image string
|
||||
var theme fic.Theme
|
||||
var tname string
|
||||
|
|
@ -78,10 +79,19 @@ func SyncThemes(i Importer) []string {
|
|||
continue
|
||||
} else if intro, err = getFileContent(i, path.Join(tdir, "overview.txt")); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: unable to get theme's overview: %s", tname, err))
|
||||
} else if theme, err = fic.GetThemeByName(tname); err != nil {
|
||||
if _, err := fic.CreateTheme(tname, fic.ToURLid(tname), tdir, strings.Join(authors, ", "), intro, image); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: an error occurs during add: %s", tdir, err))
|
||||
continue
|
||||
} else {
|
||||
// Split headline from intro
|
||||
ovrvw := strings.Split(intro, "\n")
|
||||
headline = ovrvw[0]
|
||||
if len(ovrvw) > 1 {
|
||||
intro = strings.Join(ovrvw[1:], "\n")
|
||||
}
|
||||
|
||||
if theme, err = fic.GetThemeByName(tname); err != nil {
|
||||
if _, err := fic.CreateTheme(tname, fic.ToURLid(tname), tdir, strings.Join(authors, ", "), intro, headline, image); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: an error occurs during add: %s", tdir, err))
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -90,6 +100,7 @@ func SyncThemes(i Importer) []string {
|
|||
|
||||
// Format overview (markdown)
|
||||
intro = string(blackfriday.Run([]byte(intro)))
|
||||
headline = string(blackfriday.Run([]byte(headline)))
|
||||
|
||||
if i.exists(path.Join(tdir, "heading.jpg")) {
|
||||
image = path.Join(tdir, "heading.jpg")
|
||||
|
|
@ -108,10 +119,11 @@ func SyncThemes(i Importer) []string {
|
|||
}
|
||||
}
|
||||
|
||||
if theme.Name != tname || theme.Authors != authors_str || theme.Intro != intro || theme.Image != image {
|
||||
if theme.Name != tname || theme.Authors != authors_str || theme.Headline != headline || theme.Intro != intro || theme.Image != image {
|
||||
theme.Name = tname
|
||||
theme.Authors = authors_str
|
||||
theme.Intro = intro
|
||||
theme.Headline = headline
|
||||
theme.Image = image
|
||||
theme.Path = tdir
|
||||
if _, err := theme.Update(); err != nil {
|
||||
|
|
|
|||
Reference in a new issue