/[LeafOK_CVS]/lbbs/src/article_post.c
ViewVC logotype

Diff of /lbbs/src/article_post.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.30 by sysadm, Fri Oct 10 04:33:40 2025 UTC Revision 1.40 by sysadm, Wed Nov 5 03:17:12 2025 UTC
# Line 1  Line 1 
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"
# Line 29  Line 21 
21  #include <stdlib.h>  #include <stdlib.h>
22  #include <time.h>  #include <time.h>
23    
24  #define TITLE_INPUT_MAX_LEN 72  enum _article_post_constant_t
25  #define ARTICLE_CONTENT_MAX_LEN 1024 * 1024 * 4 // 4MB  {
26  #define ARTICLE_QUOTE_MAX_LINES 20          TITLE_INPUT_MAX_LEN = 72,
27  #define ARTICLE_QUOTE_LINE_MAX_LEN 76          ARTICLE_QUOTE_MAX_LINES = 20,
28            MODIFY_DT_MAX_LEN = 50,
29  #define MODIFY_DT_MAX_LEN 50  };
30    
31  int article_post(const SECTION_LIST *p_section, ARTICLE *p_article_new)  int article_post(const SECTION_LIST *p_section, ARTICLE *p_article_new)
32  {  {
# Line 90  int article_post(const SECTION_LIST *p_s Line 82  int article_post(const SECTION_LIST *p_s
82          {          {
83                  clearscr();                  clearscr();
84                  moveto(21, 1);                  moveto(21, 1);
85                  prints("发表文章于 %s[%s] 讨论区,类型: %s,通知:%s",                  prints("发表文章于 %s[%s] 讨论区,类型: %s,回复通知:%s",
86                             p_section->stitle, p_section->sname,                             p_section->stitle, p_section->sname,
87                             (p_article_new->transship ? "转载" : "原创"),                             (p_article_new->transship ? "转载" : "原创"),
88                             (reply_note ? "开启" : "关闭"));                             (reply_note ? "开启" : "关闭"));
# Line 106  int article_post(const SECTION_LIST *p_s Line 98  int article_post(const SECTION_LIST *p_s
98                          moveto(24, 1);                          moveto(24, 1);
99                          prints("T改标题, C取消, Z设为%s, N%s, Enter继续: ",                          prints("T改标题, C取消, Z设为%s, N%s, Enter继续: ",
100                                     (p_article_new->transship ? "原创" : "转载"),                                     (p_article_new->transship ? "原创" : "转载"),
101                                     (reply_note ? "通知关闭" : "通知开启"));                                     (reply_note ? "关闭回复通知" : "开启回复通知"));
102                          iflush();                          iflush();
103                          ch = 0;                          ch = 0;
104                  }                  }
105    
106                  for (; !SYS_server_exit; ch = igetch_t(MAX_DELAY_TIME))                  for (; !SYS_server_exit; ch = igetch_t(BBS_max_user_idle_time))
107                  {                  {
108                          switch (toupper(ch))                          switch (toupper(ch))
109                          {                          {
# Line 119  int article_post(const SECTION_LIST *p_s Line 111  int article_post(const SECTION_LIST *p_s
111                          case KEY_TIMEOUT:                          case KEY_TIMEOUT:
112                                  goto cleanup;                                  goto cleanup;
113                          case CR:                          case CR:
                                 igetch_reset();  
114                                  break;                                  break;
115                          case 'T':                          case 'T':
116                                  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);
# Line 175  int article_post(const SECTION_LIST *p_s Line 166  int article_post(const SECTION_LIST *p_s
166                          prints("(S)发送, (C)取消, (T)更改标题 or (E)再编辑? [S]: ");                          prints("(S)发送, (C)取消, (T)更改标题 or (E)再编辑? [S]: ");
167                          iflush();                          iflush();
168    
169                          for (ch = 0; !SYS_server_exit; ch = igetch_t(MAX_DELAY_TIME))                          for (ch = 0; !SYS_server_exit; ch = igetch_t(BBS_max_user_idle_time))
170                          {                          {
171                                  switch (toupper(ch))                                  switch (toupper(ch))
172                                  {                                  {
# Line 183  int article_post(const SECTION_LIST *p_s Line 174  int article_post(const SECTION_LIST *p_s
174                                  case KEY_TIMEOUT:                                  case KEY_TIMEOUT:
175                                          goto cleanup;                                          goto cleanup;
176                                  case CR:                                  case CR:
                                         igetch_reset();  
177                                  case 'S':                                  case 'S':
178                                          break;                                          break;
179                                  case 'C':                                  case 'C':
# Line 523  int article_modify(const SECTION_LIST *p Line 513  int article_modify(const SECTION_LIST *p
513                  {                  {
514                          clearscr();                          clearscr();
515                          moveto(1, 1);                          moveto(1, 1);
516                          prints("(S)保存, (C)取消, (N)通知%s or (E)再编辑? [S]: ",                          prints("(S)保存, (C)取消, (N)%s回复通知 or (E)再编辑? [S]: ",
517                                     (reply_note ? "关闭" : "开启"));                                     (reply_note ? "关闭" : "开启"));
518                          iflush();                          iflush();
519    
520                          ch = igetch_t(MAX_DELAY_TIME);                          ch = igetch_t(BBS_max_user_idle_time);
521                          switch (toupper(ch))                          switch (toupper(ch))
522                          {                          {
523                          case KEY_NULL:                          case KEY_NULL:
524                          case KEY_TIMEOUT:                          case KEY_TIMEOUT:
525                                  goto cleanup;                                  goto cleanup;
526                          case CR:                          case CR:
                                 igetch_reset();  
527                          case 'S':                          case 'S':
528                                  break;                                  break;
529                          case 'C':                          case 'C':
# Line 854  int article_reply(const SECTION_LIST *p_ Line 843  int article_reply(const SECTION_LIST *p_
843                  }                  }
844    
845                  // Apply LML render to content body                  // Apply LML render to content body
846                  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);
847                  content_f[len] = '\0';                  content_f[len] = '\0';
848    
849                  // Remove control sequence                  // Remove control sequence
# Line 864  int article_reply(const SECTION_LIST *p_ Line 853  int article_reply(const SECTION_LIST *p_
853                                             "\n\n【 在 %s (%s) 的大作中提到: 】\n",                                             "\n\n【 在 %s (%s) 的大作中提到: 】\n",
854                                             p_article->username, p_article->nickname);                                             p_article->username, p_article->nickname);
855    
856                  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);
857                  for (i = 0; i < quote_content_lines; i++)                  for (i = 0; i < quote_content_lines; i++)
858                  {                  {
859                          memcpy(content + len, ": ", 2); // quote line prefix                          memcpy(content + len, ": ", 2); // quote line prefix
# Line 909  int article_reply(const SECTION_LIST *p_ Line 898  int article_reply(const SECTION_LIST *p_
898          {          {
899                  clearscr();                  clearscr();
900                  moveto(21, 1);                  moveto(21, 1);
901                  prints("回复文章于 %s[%s] 讨论区,通知:%s", p_section->stitle, p_section->sname, (reply_note ? "开启" : "关闭"));                  prints("回复文章于 %s[%s] 讨论区,回复通知:%s", p_section->stitle, p_section->sname, (reply_note ? "开启" : "关闭"));
902                  moveto(22, 1);                  moveto(22, 1);
903                  prints("标题: %s", (p_article_new->title[0] == '\0' ? "[无]" : p_article_new->title));                  prints("标题: %s", (p_article_new->title[0] == '\0' ? "[无]" : p_article_new->title));
904                  moveto(23, 1);                  moveto(23, 1);
# Line 921  int article_reply(const SECTION_LIST *p_ Line 910  int article_reply(const SECTION_LIST *p_
910    
911                          moveto(24, 1);                          moveto(24, 1);
912                          prints("T改标题, C取消, N%s, Enter继续: ",                          prints("T改标题, C取消, N%s, Enter继续: ",
913                                     (reply_note ? "通知关闭" : "通知开启"));                                     (reply_note ? "关闭回复通知" : "开启回复通知"));
914                          iflush();                          iflush();
915                          ch = 0;                          ch = 0;
916                  }                  }
917    
918                  for (; !SYS_server_exit; ch = igetch_t(MAX_DELAY_TIME))                  for (; !SYS_server_exit; ch = igetch_t(BBS_max_user_idle_time))
919                  {                  {
920                          switch (toupper(ch))                          switch (toupper(ch))
921                          {                          {
# Line 934  int article_reply(const SECTION_LIST *p_ Line 923  int article_reply(const SECTION_LIST *p_
923                          case KEY_TIMEOUT:                          case KEY_TIMEOUT:
924                                  goto cleanup;                                  goto cleanup;
925                          case CR:                          case CR:
                                 igetch_reset();  
926                                  break;                                  break;
927                          case 'T':                          case 'T':
928                                  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);
# Line 987  int article_reply(const SECTION_LIST *p_ Line 975  int article_reply(const SECTION_LIST *p_
975                          prints("(S)发送, (C)取消, (T)更改标题 or (E)再编辑? [S]: ");                          prints("(S)发送, (C)取消, (T)更改标题 or (E)再编辑? [S]: ");
976                          iflush();                          iflush();
977    
978                          for (ch = 0; !SYS_server_exit; ch = igetch_t(MAX_DELAY_TIME))                          for (ch = 0; !SYS_server_exit; ch = igetch_t(BBS_max_user_idle_time))
979                          {                          {
980                                  switch (toupper(ch))                                  switch (toupper(ch))
981                                  {                                  {
# Line 995  int article_reply(const SECTION_LIST *p_ Line 983  int article_reply(const SECTION_LIST *p_
983                                  case KEY_TIMEOUT:                                  case KEY_TIMEOUT:
984                                          goto cleanup;                                          goto cleanup;
985                                  case CR:                                  case CR:
                                         igetch_reset();  
986                                  case 'S':                                  case 'S':
987                                          break;                                          break;
988                                  case 'C':                                  case 'C':
# Line 1211  int article_reply(const SECTION_LIST *p_ Line 1198  int article_reply(const SECTION_LIST *p_
1198          {          {
1199                  // Send notification message                  // Send notification message
1200                  len_msg = snprintf(msg, BBS_msg_max_len,                  len_msg = snprintf(msg, BBS_msg_max_len,
1201                                                     "[hide]SYS_Reply_Article[/hide]有人回复了您所发表/回复的文章,快来"                                                     "有人回复了您所发表/回复的文章,快来"
1202                                                     "[article %d]看看[/article]《%s》吧!\n",                                                     "[article %d]看看[/article]《%s》吧!\n",
1203                                                     p_article_new->aid, title_f);                                                     p_article_new->aid, title_f);
1204    


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1