summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2014-03-21 18:12:17 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2014-03-21 18:12:17 +0800
commit3485c1a499a688e9053dc8f157a9704ecc6fb8f0 (patch)
treedaf84764f9eb97851f8c22c3d989639f21f1ae33
parentba73a3996c656f595a6c85221456b27569f8a032 (diff)
downloadpttbbs-3485c1a499a688e9053dc8f157a9704ecc6fb8f0.tar
pttbbs-3485c1a499a688e9053dc8f157a9704ecc6fb8f0.tar.gz
pttbbs-3485c1a499a688e9053dc8f157a9704ecc6fb8f0.tar.bz2
pttbbs-3485c1a499a688e9053dc8f157a9704ecc6fb8f0.tar.lz
pttbbs-3485c1a499a688e9053dc8f157a9704ecc6fb8f0.tar.xz
pttbbs-3485c1a499a688e9053dc8f157a9704ecc6fb8f0.tar.zst
pttbbs-3485c1a499a688e9053dc8f157a9704ecc6fb8f0.zip
Revise URL query code. Provide URL when trying to forward.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5951 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/include/proto.h1
-rw-r--r--pttbbs/mbbsd/bbs.c105
-rw-r--r--pttbbs/mbbsd/edit.c3
-rw-r--r--pttbbs/mbbsd/mail.c11
-rw-r--r--pttbbs/mbbsd/read.c20
5 files changed, 89 insertions, 51 deletions
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h
index 2df47a81..0ac0464a 100644
--- a/pttbbs/include/proto.h
+++ b/pttbbs/include/proto.h
@@ -485,6 +485,7 @@ int main_railway(void);
void i_read(int cmdmode, const char *direct, void (*dotitle)(), void (*doentry)(), const onekey_t *rcmdlist, int bidcache);
void fixkeep(const char *s, int first);
keeploc_t *getkeep(const char *s, int def_topline, int def_cursline);
+void forward_file(const fileheader_t * fhdr, const char *direct);
typedef struct
{
diff --git a/pttbbs/mbbsd/bbs.c b/pttbbs/mbbsd/bbs.c
index d17afdf8..2eeeb8ee 100644
--- a/pttbbs/mbbsd/bbs.c
+++ b/pttbbs/mbbsd/bbs.c
@@ -396,6 +396,46 @@ set_board(void)
}
}
+#ifdef QUERY_ARTICLE_URL
+
+static int
+IsBoardForWeb(const boardheader_t *bp) {
+ if (!bp || (bp->brdattr & BRD_HIDE) ||
+ (bp->level && !(bp->brdattr & BRD_POSTMASK))) // !POSTMASK = restricted
+ return 0;
+#ifdef BN_ALLPOST
+ if (strcmp(bp->brdname, BN_ALLPOST) == 0)
+ return 0;
+#endif
+ return 1;
+}
+
+static int
+GetWebUrl(const boardheader_t *bp, const fileheader_t *fhdr, char *buf,
+ size_t szbuf)
+{
+ const char *folder = bp->brdname, *fn = fhdr->filename, *ext = ".html";
+
+#ifdef USE_AID_URL
+ char aidc[32] = "";
+ aidu_t aidu = fn2aidu(fhdr->filename);
+ if (!aidu)
+ return 0;
+
+ aidu2aidc(aidc, aidu);
+ fn = aidc;
+ ext = "";
+#endif
+
+ if (!fhdr || !*fhdr->filename || *fhdr->filename == 'L' ||
+ *fhdr->filename == '.')
+ return 0;
+
+ return snprintf(buf, szbuf, URL_PREFIX "/%s/%s%s", folder, fn, ext);
+}
+
+#endif // QUERY_ARTICLE_URL
+
// post 文章不算錢的板
int IsFreeBoardName(const char *brdname)
{
@@ -1994,6 +2034,27 @@ edit_post(int ent, fileheader_t * fhdr, const char *direct)
return FULLUPDATE;
}
+int
+forward_post(int ent, fileheader_t * fhdr, const char *direct) {
+ if (!HasUserPerm(PERM_FORWARD))
+ return DONOTHING;
+
+#ifdef QUERY_ARTICLE_URL
+ if (currbid) {
+ char buf[STRLEN];
+ const boardheader_t *bp = getbcache(currbid);
+ if (bp && IsBoardForWeb(bp) &&
+ GetWebUrl(bp, fhdr, buf, sizeof(buf))) {
+ move(b_lines - 4, 0); clrtobot();
+ prints("\n" URL_DISPLAYNAME ": " ANSI_COLOR(1)
+ "%s" ANSI_RESET "\n", buf);
+ }
+ }
+#endif
+ forward_file(fhdr, direct);
+ return FULLUPDATE;
+}
+
#define UPDATE_USEREC (currmode |= MODE_DIRTY)
int
@@ -3742,43 +3803,19 @@ view_postinfo(int ent GCC_UNUSED, const fileheader_t * fhdr,
}
#ifdef QUERY_ARTICLE_URL
- {
- boardheader_t *bp = NULL;
-
- // XXX currbid should match currboard, right? can we use it?
- if (currboard && currboard[0])
- {
- int bnum = getbnum(currboard);
- if (bnum > 0)
- {
- assert(0<=bnum-1 && bnum-1<MAX_BOARD);
- bp = getbcache(bnum);
- }
- }
+ if (currbid) {
+ boardheader_t *bp = getbcache(currbid);
+ char url[STRLEN];
- if (!bp)
- {
+ if (!bp) {
prints("│\n");
- }
- else if ((bp->brdattr & BRD_HIDE) ||
-#ifdef BN_ALLPOST
- strcmp(bp->brdname, BN_ALLPOST) == 0 ||
-#endif
- (bp->level && !(bp->brdattr & BRD_POSTMASK)) // !POSTMASK = restricted read
- )
- {
- // over18 boards do not provide URL.
+ } else if (!IsBoardForWeb(bp)) {
prints("│ 本看板目前不提供" URL_DISPLAYNAME " \n");
- }
- else if (fhdr->filename[0] == 'L')
- {
+ } else if (!GetWebUrl(bp, fhdr, url, sizeof(url))) {
prints("│ 本文章不提供" URL_DISPLAYNAME " \n");
- }
- else
- {
- prints("│ " URL_DISPLAYNAME ": "
- ANSI_COLOR(1) URL_PREFIX "/%s/%s.html" ANSI_RESET "\n",
- currboard, fhdr->filename);
+ } else {
+ prints("│ " URL_DISPLAYNAME ": " ANSI_COLOR(1) "%s" ANSI_RESET
+ "\n", url);
}
}
#endif
@@ -4469,7 +4506,7 @@ const onekey_t read_comms[] = {
{ 1, do_limitedit }, // 'C'
{ 1, del_range_post }, // 'D'
{ 1, edit_post }, // 'E'
- { 0, NULL }, // 'F'
+ { 1, forward_post }, // 'F'
{ 0, NULL }, // 'G'
{ 0, NULL }, // 'H'
{ 0, b_config }, // 'I'
diff --git a/pttbbs/mbbsd/edit.c b/pttbbs/mbbsd/edit.c
index d3a5c104..c31e77f9 100644
--- a/pttbbs/mbbsd/edit.c
+++ b/pttbbs/mbbsd/edit.c
@@ -3694,6 +3694,9 @@ vedit2(const char *fpath, int saveheader, int *islocal, char title[STRLEN], int
case 's':
ch = Ctrl('S');
break;
+ case 'S':
+ curr_buf->synparser = !curr_buf->synparser;
+ break;
}
switch (ch) {
diff --git a/pttbbs/mbbsd/mail.c b/pttbbs/mbbsd/mail.c
index d703dde1..567cf96a 100644
--- a/pttbbs/mbbsd/mail.c
+++ b/pttbbs/mbbsd/mail.c
@@ -1230,6 +1230,15 @@ mail_mbox(void)
}
static int
+m_internet_forward(int ent GCC_UNUSED, fileheader_t * fhdr, const char *direct)
+{
+ if (!HasUserPerm(PERM_FORWARD))
+ return DONOTHING;
+ forward_file(fhdr, direct);
+ return FULLUPDATE;
+}
+
+static int
m_forward(int ent GCC_UNUSED, fileheader_t * fhdr, const char *direct GCC_UNUSED)
{
char uid[STRLEN];
@@ -2252,7 +2261,7 @@ static const onekey_t mail_comms[] = {
{ 0, NULL }, // 'C'
{ 1, del_range_mail }, // 'D'
{ 0, NULL }, // 'E'
- { 0, NULL }, // 'F'
+ { 1, m_internet_forward }, // 'F'
{ 0, NULL }, // 'G'
{ 0, NULL }, // 'H'
{ 0, NULL }, // 'I'
diff --git a/pttbbs/mbbsd/read.c b/pttbbs/mbbsd/read.c
index c8e6da7b..2e82aff9 100644
--- a/pttbbs/mbbsd/read.c
+++ b/pttbbs/mbbsd/read.c
@@ -535,18 +535,17 @@ select_by_aid(const keeploc_t * locmem, int *pnew_ln, int *pnewdirect_new_ln,
return DONOTHING;
}
-#ifdef INTERNET_EMAIL
-static void
-mail_forward(const fileheader_t * fhdr, const char *direct, int mode)
+void
+forward_file(const fileheader_t * fhdr, const char *direct)
{
int i;
- char buf[STRLEN];
+ char buf[PATHLEN];
char *p;
strlcpy(buf, direct, sizeof(buf));
if ((p = strrchr(buf, '/')))
*p = '\0';
- switch (i = doforward(buf, fhdr, mode)) {
+ switch (i = doforward(buf, fhdr, 'F')) {
case 0:
vmsg(msg_fwd_ok);
break;
@@ -565,7 +564,6 @@ mail_forward(const fileheader_t * fhdr, const char *direct, int mode)
break;
}
}
-#endif
static int
trim_blank(char *buf) {
@@ -1003,16 +1001,6 @@ i_read_key(const onekey_t * rcmdlist, keeploc_t * locmem,
new_top = p_lines-1;
break;
- case 'F':
- if (HasUserPerm(PERM_FORWARD) && locmem->crs_ln>0) {
- mail_forward(&headers[locmem->crs_ln - locmem->top_ln],
- currdirect, ch);
- /* by CharlieL */
- // mode = READ_REDRAW;
- return FULLUPDATE;
- }
- break;
-
case Ctrl('Q'):
if(locmem->crs_ln>0)
mode = my_query(headers[locmem->crs_ln - locmem->top_ln].owner);