From 43621937306c4424cb9db696ad9e6ea91f503db0 Mon Sep 17 00:00:00 2001 From: acanas Date: Mon, 22 Feb 2021 19:16:28 +0100 Subject: [PATCH] Version 20.33.9: Feb 22, 2021 Code refactoring related to writing a timeline comment. --- css/{swad20.8.css => swad20.33.9.css} | 1 + swad_changelog.h | 5 +- swad_timeline.c | 11 +++-- swad_timeline.h | 4 +- swad_timeline_comment.c | 69 ++++++++++----------------- swad_timeline_note.c | 45 +++++++---------- swad_timeline_note.h | 10 ++-- swad_timeline_publication.c | 18 +++---- 8 files changed, 67 insertions(+), 96 deletions(-) rename css/{swad20.8.css => swad20.33.9.css} (99%) diff --git a/css/swad20.8.css b/css/swad20.33.9.css similarity index 99% rename from css/swad20.8.css rename to css/swad20.33.9.css index b9abef5f..ee313e42 100644 --- a/css/swad20.8.css +++ b/css/swad20.33.9.css @@ -3655,6 +3655,7 @@ table.CELLS_PAD_10 > tbody > tr > td {padding:10px;} } .TL_TXT { + text-align:left; padding-top:5px; color:#202020; font-size:13pt; diff --git a/swad_changelog.h b/swad_changelog.h index 30ee1519..6b68756e 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -553,8 +553,8 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 20.33.8 (2021-02-22)" -#define CSS_FILE "swad20.8.css" +#define Log_PLATFORM_VERSION "SWAD 20.33.9 (2021-02-22)" +#define CSS_FILE "swad20.33.9.css" #define JS_FILE "swad20.6.2.js" /* TODO: Juan Miguel Boyero Corral: Este verano ha habido varias personas que han solicitado incluir la funcionalidad del apartado de Actividades en SWADroid. Si lo ves viable podríamos estudiarlo. @@ -601,6 +601,7 @@ TODO: DNI de un estudiante sale err TODO: BUG: Cuando un tipo de grupo sólo tiene un grupo, inscribirse es voluntario, el estudiante sólo puede pertenecer a un grupo, y se inscribe en él, debería poder desapuntarse. Ahora no puede. TODO: Salvador Romero Cortés: @acanas opción para editar posts + Version 20.33.9: Feb 22, 2021 Code refactoring related to writing a timeline comment. (304949 lines) Version 20.33.8: Feb 22, 2021 Code refactoring related to writing a timeline note. (304971 lines) Version 20.33.7: Feb 22, 2021 Code refactoring related to writing a timeline note. (304923 lines) Version 20.33.6: Feb 22, 2021 Code refactoring related to writing a timeline note. (304898 lines) diff --git a/swad_timeline.c b/swad_timeline.c index 6566e02c..f1ceb86f 100644 --- a/swad_timeline.c +++ b/swad_timeline.c @@ -469,11 +469,12 @@ static void TL_ShowTimeline (struct TL_Timeline *Timeline, TL_Not_GetDataOfNoteByCod (&Not); /* Write note */ - TL_Not_WriteNoteInList (Timeline,&Not, - TL_Pub_GetTopMessage (Pub->PubType),Pub->PublisherCod, - Not.NotCod == NotCodToHighlight ? TL_HIGHLIGHT : - TL_DONT_HIGHLIGHT, - TL_DONT_SHOW_ALONE); + HTM_LI_Begin ("class=\"%s\"",Not.NotCod == NotCodToHighlight ? "TL_WIDTH TL_SEP TL_NEW_PUB" : + "TL_WIDTH TL_SEP"); + TL_Not_WriteNoteWithTopMsg (Timeline,&Not, + TL_Pub_GetTopMessage (Pub->PubType), + Pub->PublisherCod); + HTM_LI_End (); } HTM_UL_End (); diff --git a/swad_timeline.h b/swad_timeline.h index c77e6466..4b331ee0 100644 --- a/swad_timeline.h +++ b/swad_timeline.h @@ -90,7 +90,7 @@ struct TL_Timeline long NotCod; // Used as parameter about social note to be edited, removed... long PubCod; // Used as parameter about social publishing to be edited, removed... }; - +/* typedef enum { TL_DONT_HIGHLIGHT, @@ -102,7 +102,7 @@ typedef enum TL_DONT_SHOW_ALONE, TL_SHOW_ALONE, } TL_ShowAlone_t; - +*/ /*****************************************************************************/ /****************************** Public prototypes ****************************/ /*****************************************************************************/ diff --git a/swad_timeline_comment.c b/swad_timeline_comment.c index 1b9a5f6a..16b4c438 100644 --- a/swad_timeline_comment.c +++ b/swad_timeline_comment.c @@ -80,8 +80,7 @@ static void TL_Com_LinkToShowPreviousComments (const char IdComments[Frm_MAX_BYT static void TL_Com_PutIconToToggleComments (const char *UniqueId, const char *Icon,const char *Text); static void TL_Com_WriteComment (const struct TL_Timeline *Timeline, - struct TL_Com_Comment *Com, - TL_ShowAlone_t ShowCommentAlone); // Comment is shown alone, not in a list + struct TL_Com_Comment *Com); static void TL_Com_WriteAuthorComment (struct UsrData *UsrDat); static void TL_Com_PutFormToRemoveComment (const struct TL_Timeline *Timeline, @@ -427,8 +426,9 @@ static void TL_Com_WriteOneCommentInList (const struct TL_Timeline *Timeline, TL_Com_GetDataOfCommentFromRow (row,&Com); /***** Write comment *****/ - TL_Com_WriteComment (Timeline,&Com, - TL_DONT_SHOW_ALONE); + HTM_LI_Begin ("class=\"TL_COM\""); + TL_Com_WriteComment (Timeline,&Com); + HTM_LI_End (); /***** Free image *****/ Med_MediaDestructor (&Com.Content.Media); @@ -497,8 +497,7 @@ static void TL_Com_PutIconToToggleComments (const char *UniqueId, /*****************************************************************************/ static void TL_Com_WriteComment (const struct TL_Timeline *Timeline, - struct TL_Com_Comment *Com, - TL_ShowAlone_t ShowCommentAlone) // Comment is shown alone, not in a list + struct TL_Com_Comment *Com) { struct UsrData AuthorDat; bool IAmTheAuthor; @@ -508,29 +507,9 @@ static void TL_Com_WriteComment (const struct TL_Timeline *Timeline, NumDiv++; - if (ShowCommentAlone == TL_SHOW_ALONE) - { - /***** Box begin *****/ - Box_BoxBegin (NULL,NULL, - NULL,NULL, - NULL,Box_NOT_CLOSABLE); - - HTM_DIV_Begin ("class=\"TL_LEFT_PHOTO\""); - HTM_DIV_End (); - - HTM_DIV_Begin ("class=\"TL_RIGHT_CONT TL_RIGHT_WIDTH\""); - HTM_UL_Begin ("class=\"LIST_LEFT\""); - } - - /***** Start list item *****/ - HTM_LI_Begin (ShowCommentAlone == TL_SHOW_ALONE ? NULL : - "class=\"TL_COM\""); - - if (Com->PubCod <= 0 || - Com->NotCod <= 0 || - Com->UsrCod <= 0) - Ale_ShowAlert (Ale_ERROR,"Error in comment."); - else + if (Com->PubCod > 0 && + Com->NotCod > 0 && + Com->UsrCod > 0) { /***** Get author's data *****/ Usr_UsrDataConstructor (&AuthorDat); @@ -578,8 +557,9 @@ static void TL_Com_WriteComment (const struct TL_Timeline *Timeline, /* Put icon to remove this comment */ HTM_DIV_Begin ("class=\"TL_REM\""); - if (IAmTheAuthor && - ShowCommentAlone == TL_DONT_SHOW_ALONE) + // if (IAmTheAuthor && + // ShowCommentAlone == TL_DONT_SHOW_ALONE) + if (IAmTheAuthor) TL_Com_PutFormToRemoveComment (Timeline,Com->PubCod); HTM_DIV_End (); @@ -589,17 +569,8 @@ static void TL_Com_WriteComment (const struct TL_Timeline *Timeline, /***** Free memory used for user's data *****/ Usr_UsrDataDestructor (&AuthorDat); } - - /***** End list item *****/ - HTM_LI_End (); - - if (ShowCommentAlone == TL_SHOW_ALONE) - { - /***** Box end *****/ - HTM_UL_End (); - HTM_DIV_End (); - Box_BoxEnd (); - } + else + Ale_ShowAlert (Ale_ERROR,"Error in comment."); } /*****************************************************************************/ @@ -816,8 +787,18 @@ static void TL_Com_RequestRemovalComment (struct TL_Timeline *Timeline) TL_Frm_BeginAlertRemove (Txt_Do_you_really_want_to_remove_the_following_comment); /* Show comment */ - TL_Com_WriteComment (Timeline,&Com, - TL_SHOW_ALONE); + Box_BoxBegin (NULL,NULL, + NULL,NULL, + NULL,Box_NOT_CLOSABLE); + + HTM_DIV_Begin ("class=\"TL_LEFT_PHOTO\""); + HTM_DIV_End (); + + HTM_DIV_Begin ("class=\"TL_RIGHT_CONT TL_RIGHT_WIDTH\""); + TL_Com_WriteComment (Timeline,&Com); + HTM_DIV_End (); + + Box_BoxEnd (); /* End alert */ Timeline->PubCod = Com.PubCod; // Publication to be removed diff --git a/swad_timeline_note.c b/swad_timeline_note.c index 7272d1e8..a96178ce 100644 --- a/swad_timeline_note.c +++ b/swad_timeline_note.c @@ -69,6 +69,8 @@ extern struct Globals Gbl; /*****************************************************************************/ static void TL_Not_WriteTopMessage (TL_TopMessage_t TopMessage,long PublisherCod); +static void TL_Not_WriteNote (const struct TL_Timeline *Timeline, + const struct TL_Not_Note *Not); static void TL_Not_ShowAuthorPhoto (struct UsrData *UsrDat); static void TL_Not_WriteTop (const struct TL_Not_Note *Not, const struct UsrData *UsrDat); @@ -174,12 +176,11 @@ void TL_Not_ShowHighlightedNote (struct TL_Timeline *Timeline, Box_BoxBegin (NULL,NULL, NULL,NULL, NULL,Box_CLOSABLE); - HTM_UL_Begin ("class=\"TL_LIST\""); - TL_Not_WriteNoteInList (Timeline,Not, - TopMessages[NotifyEvent],PublisherDat.UsrCod, - TL_HIGHLIGHT, - TL_SHOW_ALONE); - HTM_UL_End (); + HTM_DIV_Begin ("class=\"TL_WIDTH TL_NEW_PUB\""); + TL_Not_WriteNoteWithTopMsg (Timeline,Not, + TopMessages[NotifyEvent], + PublisherDat.UsrCod); + HTM_DIV_End (); Box_BoxEnd (); } @@ -211,21 +212,11 @@ void TL_Not_InsertNoteInVisibleTimeline (long NotCod) /******************************** Write note *********************************/ /*****************************************************************************/ -void TL_Not_WriteNoteInList (const struct TL_Timeline *Timeline, - const struct TL_Not_Note *Not, - TL_TopMessage_t TopMessage, - long PublisherCod, // Who did the action (publication, commenting, faving, sharing, mentioning) - TL_Highlight_t Highlight, // Highlight note - TL_ShowAlone_t ShowNoteAlone) // Note is shown alone, not in a list +void TL_Not_WriteNoteWithTopMsg (const struct TL_Timeline *Timeline, + const struct TL_Not_Note *Not, + TL_TopMessage_t TopMessage, + long PublisherCod) // Who did the action (publication, commenting, faving, sharing, mentioning) { - /***** Start list item *****/ - HTM_LI_Begin ("class=\"%s\"", - ShowNoteAlone == TL_SHOW_ALONE ? - (Highlight == TL_HIGHLIGHT ? "TL_WIDTH TL_NEW_PUB" : - "TL_WIDTH") : - (Highlight == TL_HIGHLIGHT ? "TL_WIDTH TL_SEP TL_NEW_PUB" : - "TL_WIDTH TL_SEP")); - if (Not->NotCod > 0 && Not->UsrCod > 0 && Not->NoteType != TL_NOTE_UNKNOWN) @@ -239,9 +230,6 @@ void TL_Not_WriteNoteInList (const struct TL_Timeline *Timeline, } else Ale_ShowAlert (Ale_ERROR,"Error in note."); - - /***** End list item *****/ - HTM_LI_End (); } /*****************************************************************************/ @@ -1129,12 +1117,11 @@ static void TL_Not_RequestRemovalNote (struct TL_Timeline *Timeline) Box_BoxBegin (NULL,NULL, NULL,NULL, NULL,Box_CLOSABLE); - HTM_UL_Begin ("class=\"TL_LIST\""); - TL_Not_WriteNoteInList (Timeline,&Not, - TL_TOP_MESSAGE_NONE,-1L, - TL_DONT_HIGHLIGHT, - TL_SHOW_ALONE); - HTM_UL_End (); + HTM_DIV_Begin ("class=\"TL_WIDTH\""); + TL_Not_WriteNoteWithTopMsg (Timeline,&Not, + TL_TOP_MESSAGE_NONE, + -1L); + HTM_DIV_End (); Box_BoxEnd (); /* End alert */ diff --git a/swad_timeline_note.h b/swad_timeline_note.h index 66339fbd..268dabb9 100644 --- a/swad_timeline_note.h +++ b/swad_timeline_note.h @@ -90,12 +90,10 @@ void TL_Not_ShowHighlightedNote (struct TL_Timeline *Timeline, void TL_Not_InsertNoteInJustRetrievedNotes (long NotCod); void TL_Not_InsertNoteInVisibleTimeline (long NotCod); -void TL_Not_WriteNoteInList (const struct TL_Timeline *Timeline, - const struct TL_Not_Note *Not, - TL_TopMessage_t TopMessage, - long PublisherCod, // Who did the action (publication, commenting, faving, sharing, mentioning) - TL_Highlight_t Highlight, // Highlight note - TL_ShowAlone_t ShowNoteAlone); // Note is shown alone, not in a list +void TL_Not_WriteNoteWithTopMsg (const struct TL_Timeline *Timeline, + const struct TL_Not_Note *Not, + TL_TopMessage_t TopMessage, + long PublisherCod); void TL_Not_WriteAuthorName (const struct UsrData *UsrDat); void TL_Not_GetNoteSummary (const struct TL_Not_Note *Not, diff --git a/swad_timeline_publication.c b/swad_timeline_publication.c index b7a63073..04a560ee 100644 --- a/swad_timeline_publication.c +++ b/swad_timeline_publication.c @@ -539,10 +539,11 @@ void TL_Pub_InsertNewPubsInTimeline (struct TL_Timeline *Timeline) TL_Not_GetDataOfNoteByCod (&Not); /* Write note */ - TL_Not_WriteNoteInList (Timeline,&Not, - TL_Pub_GetTopMessage (Pub->PubType),Pub->PublisherCod, - TL_DONT_HIGHLIGHT, - TL_DONT_SHOW_ALONE); + HTM_LI_Begin ("class=\"TL_WIDTH TL_SEP TL_NEW_PUB\""); + TL_Not_WriteNoteWithTopMsg (Timeline,&Not, + TL_Pub_GetTopMessage (Pub->PubType), + Pub->PublisherCod); + HTM_LI_End (); } } @@ -566,10 +567,11 @@ void TL_Pub_ShowOldPubsInTimeline (struct TL_Timeline *Timeline) TL_Not_GetDataOfNoteByCod (&Not); /* Write note */ - TL_Not_WriteNoteInList (Timeline,&Not, - TL_Pub_GetTopMessage (Pub->PubType),Pub->PublisherCod, - TL_DONT_HIGHLIGHT, - TL_DONT_SHOW_ALONE); + HTM_LI_Begin ("class=\"TL_WIDTH TL_SEP\""); + TL_Not_WriteNoteWithTopMsg (Timeline,&Not, + TL_Pub_GetTopMessage (Pub->PubType), + Pub->PublisherCod); + HTM_LI_End (); } }