| 1 |
/*************************************************************************** |
/* SPDX-License-Identifier: GPL-3.0-or-later */ |
| 2 |
article_post.c - description |
/* |
| 3 |
------------------- |
* article_post |
| 4 |
copyright : (C) 2004-2025 by Leaflet |
* - user interactive feature to post / modify / reply article |
| 5 |
email : leaflet@leafok.com |
* |
| 6 |
***************************************************************************/ |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com> |
| 7 |
|
*/ |
|
/*************************************************************************** |
|
|
* * |
|
|
* This program is free software; you can redistribute it and/or modify * |
|
|
* it under the terms of the GNU General Public License as published by * |
|
|
* the Free Software Foundation; either version 3 of the License, or * |
|
|
* (at your option) any later version. * |
|
|
* * |
|
|
***************************************************************************/ |
|
| 8 |
|
|
| 9 |
#include "article_cache.h" |
#include "article_cache.h" |
| 10 |
#include "article_post.h" |
#include "article_post.h" |
| 24 |
#define TITLE_INPUT_MAX_LEN 72 |
#define TITLE_INPUT_MAX_LEN 72 |
| 25 |
#define ARTICLE_CONTENT_MAX_LEN 1024 * 1024 * 4 // 4MB |
#define ARTICLE_CONTENT_MAX_LEN 1024 * 1024 * 4 // 4MB |
| 26 |
#define ARTICLE_QUOTE_MAX_LINES 20 |
#define ARTICLE_QUOTE_MAX_LINES 20 |
|
#define ARTICLE_QUOTE_LINE_MAX_LEN 76 |
|
| 27 |
|
|
| 28 |
#define MODIFY_DT_MAX_LEN 50 |
#define MODIFY_DT_MAX_LEN 50 |
| 29 |
|
|
| 81 |
{ |
{ |
| 82 |
clearscr(); |
clearscr(); |
| 83 |
moveto(21, 1); |
moveto(21, 1); |
| 84 |
prints("发表文章于 %s[%s] 讨论区,类型: %s,通知:%s", |
prints("发表文章于 %s[%s] 讨论区,类型: %s,回复通知:%s", |
| 85 |
p_section->stitle, p_section->sname, |
p_section->stitle, p_section->sname, |
| 86 |
(p_article_new->transship ? "转载" : "原创"), |
(p_article_new->transship ? "转载" : "原创"), |
| 87 |
(reply_note ? "开启" : "关闭")); |
(reply_note ? "开启" : "关闭")); |
| 97 |
moveto(24, 1); |
moveto(24, 1); |
| 98 |
prints("[1;32mT[m改标题, [1;32mC[m取消, [1;32mZ[m设为%s, [1;32mN[m%s, [1;32mEnter[m继续: ", |
prints("[1;32mT[m改标题, [1;32mC[m取消, [1;32mZ[m设为%s, [1;32mN[m%s, [1;32mEnter[m继续: ", |
| 99 |
(p_article_new->transship ? "原创" : "转载"), |
(p_article_new->transship ? "原创" : "转载"), |
| 100 |
(reply_note ? "通知关闭" : "通知开启")); |
(reply_note ? "关闭回复通知" : "开启回复通知")); |
| 101 |
iflush(); |
iflush(); |
| 102 |
ch = 0; |
ch = 0; |
| 103 |
} |
} |
| 110 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 111 |
goto cleanup; |
goto cleanup; |
| 112 |
case CR: |
case CR: |
|
igetch_reset(); |
|
| 113 |
break; |
break; |
| 114 |
case 'T': |
case 'T': |
| 115 |
len = get_data(24, 1, "标题: ", title_input, sizeof(title_input), TITLE_INPUT_MAX_LEN); |
len = get_data(24, 1, "标题: ", title_input, sizeof(title_input), TITLE_INPUT_MAX_LEN); |
| 173 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 174 |
goto cleanup; |
goto cleanup; |
| 175 |
case CR: |
case CR: |
|
igetch_reset(); |
|
| 176 |
case 'S': |
case 'S': |
| 177 |
break; |
break; |
| 178 |
case 'C': |
case 'C': |
| 512 |
{ |
{ |
| 513 |
clearscr(); |
clearscr(); |
| 514 |
moveto(1, 1); |
moveto(1, 1); |
| 515 |
prints("(S)保存, (C)取消, (N)通知%s or (E)再编辑? [S]: ", |
prints("(S)保存, (C)取消, (N)%s回复通知 or (E)再编辑? [S]: ", |
| 516 |
(reply_note ? "关闭" : "开启")); |
(reply_note ? "关闭" : "开启")); |
| 517 |
iflush(); |
iflush(); |
| 518 |
|
|
| 523 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 524 |
goto cleanup; |
goto cleanup; |
| 525 |
case CR: |
case CR: |
|
igetch_reset(); |
|
| 526 |
case 'S': |
case 'S': |
| 527 |
break; |
break; |
| 528 |
case 'C': |
case 'C': |
| 722 |
int content_display_length; |
int content_display_length; |
| 723 |
char nickname_f[BBS_nickname_max_len * 2 + 1]; |
char nickname_f[BBS_nickname_max_len * 2 + 1]; |
| 724 |
int sign_id = 0; |
int sign_id = 0; |
| 725 |
int reply_note = 1; |
int reply_note = 0; |
| 726 |
long len; |
long len; |
| 727 |
int ch; |
int ch; |
| 728 |
char *p, *q; |
char *p, *q; |
| 842 |
} |
} |
| 843 |
|
|
| 844 |
// Apply LML render to content body |
// Apply LML render to content body |
| 845 |
len = lml_render(row[1], content_f, ARTICLE_CONTENT_MAX_LEN, 0); |
len = lml_render(row[1], content_f, ARTICLE_CONTENT_MAX_LEN, MAX_EDITOR_DATA_LINE_LENGTH - 3, 1); |
| 846 |
content_f[len] = '\0'; |
content_f[len] = '\0'; |
| 847 |
|
|
| 848 |
// Remove control sequence |
// Remove control sequence |
| 852 |
"\n\n【 在 %s (%s) 的大作中提到: 】\n", |
"\n\n【 在 %s (%s) 的大作中提到: 】\n", |
| 853 |
p_article->username, p_article->nickname); |
p_article->username, p_article->nickname); |
| 854 |
|
|
| 855 |
quote_content_lines = split_data_lines(content_f, ARTICLE_QUOTE_LINE_MAX_LEN, line_offsets, ARTICLE_QUOTE_MAX_LINES + 1, 0, NULL); |
quote_content_lines = split_data_lines(content_f, MAX_EDITOR_DATA_LINE_LENGTH - 2, line_offsets, ARTICLE_QUOTE_MAX_LINES + 1, 0, NULL); |
| 856 |
for (i = 0; i < quote_content_lines; i++) |
for (i = 0; i < quote_content_lines; i++) |
| 857 |
{ |
{ |
| 858 |
memcpy(content + len, ": ", 2); // quote line prefix |
memcpy(content + len, ": ", 2); // quote line prefix |
| 897 |
{ |
{ |
| 898 |
clearscr(); |
clearscr(); |
| 899 |
moveto(21, 1); |
moveto(21, 1); |
| 900 |
prints("回复文章于 %s[%s] 讨论区,通知:%s", p_section->stitle, p_section->sname, (reply_note ? "开启" : "关闭")); |
prints("回复文章于 %s[%s] 讨论区,回复通知:%s", p_section->stitle, p_section->sname, (reply_note ? "开启" : "关闭")); |
| 901 |
moveto(22, 1); |
moveto(22, 1); |
| 902 |
prints("标题: %s", (p_article_new->title[0] == '\0' ? "[无]" : p_article_new->title)); |
prints("标题: %s", (p_article_new->title[0] == '\0' ? "[无]" : p_article_new->title)); |
| 903 |
moveto(23, 1); |
moveto(23, 1); |
| 909 |
|
|
| 910 |
moveto(24, 1); |
moveto(24, 1); |
| 911 |
prints("[1;32mT[m改标题, [1;32mC[m取消, [1;32mN[m%s, [1;32mEnter[m继续: ", |
prints("[1;32mT[m改标题, [1;32mC[m取消, [1;32mN[m%s, [1;32mEnter[m继续: ", |
| 912 |
(reply_note ? "通知关闭" : "通知开启")); |
(reply_note ? "关闭回复通知" : "开启回复通知")); |
| 913 |
iflush(); |
iflush(); |
| 914 |
ch = 0; |
ch = 0; |
| 915 |
} |
} |
| 922 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 923 |
goto cleanup; |
goto cleanup; |
| 924 |
case CR: |
case CR: |
|
igetch_reset(); |
|
| 925 |
break; |
break; |
| 926 |
case 'T': |
case 'T': |
| 927 |
len = get_data(24, 1, "标题: ", title_input, sizeof(title_input), TITLE_INPUT_MAX_LEN); |
len = get_data(24, 1, "标题: ", title_input, sizeof(title_input), TITLE_INPUT_MAX_LEN); |
| 982 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 983 |
goto cleanup; |
goto cleanup; |
| 984 |
case CR: |
case CR: |
|
igetch_reset(); |
|
| 985 |
case 'S': |
case 'S': |
| 986 |
break; |
break; |
| 987 |
case 'C': |
case 'C': |
| 1197 |
{ |
{ |
| 1198 |
// Send notification message |
// Send notification message |
| 1199 |
len_msg = snprintf(msg, BBS_msg_max_len, |
len_msg = snprintf(msg, BBS_msg_max_len, |
| 1200 |
"[hide]SYS_Reply_Article[/hide]有人回复了您所发表/回复的文章,快来" |
"有人回复了您所发表/回复的文章,快来" |
| 1201 |
"[article %d]看看[/article]《%s》吧!\n", |
"[article %d]看看[/article]《%s》吧!\n", |
| 1202 |
p_article_new->aid, title_f); |
p_article_new->aid, title_f); |
| 1203 |
|
|