Version 15.126.1

This commit is contained in:
Antonio Cañas Vargas 2016-01-25 00:19:21 +01:00
parent 639b622d6b
commit 5ad6d494aa
11 changed files with 50 additions and 41 deletions

View File

@ -205,7 +205,7 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Course *Crs)
/* Write full content of the notice */
strncpy (Content,row[3],Cns_MAX_BYTES_TEXT);
Content[Cns_MAX_BYTES_TEXT] = '\0';
Str_InsertLinkInURLs (Content,Cns_MAX_BYTES_TEXT,40);
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,40);
fprintf (FileRSS,"<description><![CDATA[<p><em>%s %s %s:</em></p><p>%s</p>]]></description>\n",
UsrDat.FirstName,UsrDat.Surname1,UsrDat.Surname2,Content);

View File

@ -156,7 +156,7 @@ void Ann_ShowAllAnnouncements (void)
/* Get the content (row[4]) and insert links */
strncpy (Content,row[4],Cns_MAX_BYTES_TEXT);
Content[Cns_MAX_BYTES_TEXT] = '\0';
Str_InsertLinkInURLs (Content,Cns_MAX_BYTES_TEXT,50);
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50);
/* Show the announcement */
Ann_DrawAnAnnouncement (AnnCod,Status,Subject,Content,
@ -220,7 +220,7 @@ void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void)
/* Get the content (row[2]) and insert links */
strncpy (Content,row[2],Cns_MAX_BYTES_TEXT);
Content[Cns_MAX_BYTES_TEXT] = '\0';
Str_InsertLinkInURLs (Content,Cns_MAX_BYTES_TEXT,50);
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,50);
/* Show the announcement */
Ann_DrawAnAnnouncement (AnnCod,Ann_ACTIVE_ANNOUNCEMENT,Subject,Content,

View File

@ -328,7 +328,7 @@ static void Asg_ShowOneAssignment (long AsgCod)
Asg_GetAssignmentTxtFromDB (Asg.AsgCod,Txt);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML
Str_InsertLinkInURLs (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links
Str_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links
fprintf (Gbl.F.Out,"<td class=\"LEFT_TOP COLOR%u\">",
Gbl.RowEvenOdd);

View File

@ -373,7 +373,7 @@ static void Att_ShowOneAttEvent (struct AttendanceEvent *Att,bool ShowOnlyThisAt
Att_GetAttEventTxtFromDB (Att->AttCod,Txt);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML
Str_InsertLinkInURLs (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links
Str_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links
fprintf (Gbl.F.Out,"<td colspan=\"2\" class=\"LEFT_TOP COLOR%u\">",
Gbl.RowEvenOdd);

View File

@ -127,13 +127,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.126 (2016-01-24)"
#define Log_PLATFORM_VERSION "SWAD 15.126.1 (2016-01-24)"
#define CSS_FILE "swad15.121.7.css"
#define JS_FILE "swad15.121.7.js"
// Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/*
Version 15.126.1: Jan 24, 2016 Optimization in code to insert links. (194736 lines)
Version 15.126: Jan 24, 2016 In any text where URL is replaced by anchor, now @nickname is also replaced to link to user's profile. (194727 lines)
2 changes necessary in database:
UPDATE social_posts SET Content=REPLACE(Content,'&#64;','@');

View File

@ -1589,7 +1589,7 @@ static void Inf_ShowPlainTxtInfo (Inf_InfoType_t InfoType)
/***** Convert to respectful HTML and insert links *****/
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
TxtHTML,Cns_MAX_BYTES_LONG_TEXT,false); // Convert from HTML to recpectful HTML
Str_InsertLinkInURLs (TxtHTML,Cns_MAX_BYTES_LONG_TEXT,60); // Insert links
Str_InsertLinks (TxtHTML,Cns_MAX_BYTES_LONG_TEXT,60); // Insert links
/***** Write text *****/
fprintf (Gbl.F.Out,"%s",TxtHTML);
@ -1757,7 +1757,7 @@ int Inf_WritePlainTextIntoHTMLBuffer (Inf_InfoType_t InfoType,char **HTMLBuffer)
/* Convert to respectful HTML and insert links */
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
TxtHTML,Cns_MAX_BYTES_LONG_TEXT,false); // Convert from HTML to recpectful HTML
Str_InsertLinkInURLs (TxtHTML,Cns_MAX_BYTES_LONG_TEXT,60); // Insert links
Str_InsertLinks (TxtHTML,Cns_MAX_BYTES_LONG_TEXT,60); // Insert links
/* Write text */
fprintf (FileHTMLTmp,"%s",TxtHTML);

View File

@ -3392,7 +3392,7 @@ void Msg_WriteMsgContent (char *Content,unsigned long MaxLength,bool InsertLinks
{
/***** Insert links in URLs *****/
if (InsertLinks)
Str_InsertLinkInURLs (Content,MaxLength,60);
Str_InsertLinks (Content,MaxLength,60);
/***** Write message to file *****/
if (ChangeBRToRet)

View File

@ -449,7 +449,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,bool ICanEditNotices)
/* Get the content (row[3]) and insert links */
strncpy (Content,row[3],Cns_MAX_BYTES_TEXT);
Str_InsertLinkInURLs (Content,Cns_MAX_BYTES_TEXT,
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,
Not_MaxCharsURLOnScreen[TypeNoticesListing]);
if (TypeNoticesListing == Not_LIST_BRIEF_NOTICES)
Str_LimitLengthHTMLStr (Content,Not_MAX_CHARS_ON_NOTICE);
@ -514,7 +514,7 @@ static void Not_GetDataAndShowNotice (long NotCod,bool ICanEditNotices)
/* Get the content (row[2]) and insert links*/
strncpy (Content,row[2],Cns_MAX_BYTES_TEXT);
Str_InsertLinkInURLs (Content,Cns_MAX_BYTES_TEXT,
Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,
Not_MaxCharsURLOnScreen[Not_LIST_FULL_NOTICES]);
/* Get status of the notice (row[3]) */

View File

@ -76,7 +76,7 @@ static const char Str_CR[2] = {13,0};
/*****************************************************************************/
/*****************************************************************************/
/************************* Insert links in URLs ******************************/
/****************** Insert a link in every URL or nickname *******************/
/*****************************************************************************/
/*
Insertion example:
@ -91,20 +91,20 @@ The web site of <a href="https://openswad.org/?usr=@rms">@rms</a> is <a href="ht
#define MAX_BYTES_LIMITED_URL 1024 // Max. number of bytes of the URL shown on screen
void Str_InsertLinkInURLs (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScreen)
void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScreen)
{
extern const char *Txt_STR_LANG_ID[1+Txt_NUM_LANGUAGES];
char ANCHOR_1_NICK[256+Ses_LENGTH_SESSION_ID];
char ANCHOR_2_NICK[128];
unsigned long TxtLength;
unsigned long TxtLengthWithInsertedAnchors;
unsigned Anchor1URLLength;
unsigned Anchor1NickLength;
unsigned Anchor2URLLength;
unsigned Anchor2NickLength;
unsigned Anchor3Length;
unsigned AnchorURLTotalLength;
unsigned AnchorNickTotalLength;
size_t TxtLength;
size_t TxtLengthWithInsertedAnchors;
size_t Anchor1URLLength;
size_t Anchor1NickLength;
size_t Anchor2URLLength;
size_t Anchor2NickLength;
size_t Anchor3Length;
size_t AnchorURLTotalLength;
size_t AnchorNickTotalLength;
char *PtrSrc;
char *PtrDst;
bool URLStartFound;
@ -154,7 +154,7 @@ void Str_InsertLinkInURLs (char *Txt,unsigned long MaxLength,size_t MaxCharsURLO
AnchorURLTotalLength = Anchor1URLLength + Anchor2URLLength + Anchor3Length;
AnchorNickTotalLength = Anchor1NickLength + Anchor2NickLength + Anchor3Length;
/***** Find starts and ends of URLs *****/
/***** Find starts and ends of links (URLs and nicknames) *****/
for (PtrSrc = Txt;
*PtrSrc;)
/* Check if the next char is the start of a URL */
@ -349,15 +349,19 @@ void Str_InsertLinkInURLs (char *Txt,unsigned long MaxLength,size_t MaxCharsURLO
/* Step 4: Insert ANCHOR_2_LINK or ANCHOR_2_URL */
if (IsNickname)
for (i = 0, PtrSrc = ANCHOR_2_NICK + Anchor2NickLength - 1;
i < Anchor2NickLength;
i++)
*PtrDst-- = *PtrSrc--;
{
PtrSrc = ANCHOR_2_NICK + Anchor2NickLength - 1;
Length = Anchor2NickLength;
}
else
for (i = 0, PtrSrc = ANCHOR_2_URL + Anchor2URLLength - 1;
i < Anchor2URLLength;
i++)
*PtrDst-- = *PtrSrc--;
{
PtrSrc = ANCHOR_2_URL + Anchor2URLLength - 1;
Length = Anchor2URLLength;
}
for (i = 0;
i < Length;
i++)
*PtrDst-- = *PtrSrc--;
/* Step 5: Insert link into directive A
(it's mandatory to do the copy in reverse order
@ -369,15 +373,19 @@ void Str_InsertLinkInURLs (char *Txt,unsigned long MaxLength,size_t MaxCharsURLO
/* Step 6: Insert ANCHOR_1_NICK or ANCHOR_1_URL */
if (IsNickname)
for (i = 0, PtrSrc = ANCHOR_1_NICK + Anchor1NickLength - 1;
i < Anchor1NickLength;
i++)
*PtrDst-- = *PtrSrc--;
{
PtrSrc = ANCHOR_1_NICK + Anchor1NickLength - 1;
Length = Anchor1NickLength;
}
else
for (i = 0, PtrSrc = ANCHOR_1_URL + Anchor1URLLength - 1;
i < Anchor1URLLength;
i++)
*PtrDst-- = *PtrSrc--;
{
PtrSrc = ANCHOR_1_URL + Anchor1URLLength - 1;
Length = Anchor1URLLength;
}
for (i = 0;
i < Length;
i++)
*PtrDst-- = *PtrSrc--;
LinksTotalLength -= NumBytesToShow;
}

View File

@ -66,7 +66,7 @@ typedef enum
/***************************** Public prototypes ****************************/
/*****************************************************************************/
void Str_InsertLinkInURLs (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScreen);
void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScreen);
size_t Str_LimitLengthHTMLStr (char *Str,size_t MaxCharsOnScreen);
// bool Str_URLLooksValid (const char *URL);
void Str_ConvertToTitleType (char *Str);

View File

@ -483,7 +483,7 @@ static void Svy_ShowOneSurvey (long SvyCod,struct SurveyQuestion *SvyQst,bool Sh
Svy_GetSurveyTxtFromDB (Svy.SvyCod,Txt);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML
Str_InsertLinkInURLs (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links
Str_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links
fprintf (Gbl.F.Out,"<p class=\"%s\">"
"%s"
"</p>"