Skip to content

Commit ae2bd8c

Browse files
committed
Show latest article of the DBlog on the frontpage
1 parent 999cbfb commit ae2bd8c

File tree

4 files changed

+38
-27
lines changed

4 files changed

+38
-27
lines changed

dlang.org.ddoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ DDOCKEYVAL2=$(DIVC keyval $1, $(SPANC key key$1, $2:) $(DIVC val val$1, $(TAIL $
136136
DDSUBLINK=$(LINK2 $(ROOT_DIR)$1.html#$2, $3)
137137
_=
138138

139+
DBLOG_LATEST_AUTHOR=
140+
DBLOG_LATEST_DATE=
141+
DBLOG_LATEST_LINK=
142+
DBLOG_LATEST_TITLE=
139143
DMDSRC=$(HTTPS github.com/dlang/dmd/blob/master/src/dmd/$0, $0)
140144
DOT_PREFIXED=.$1$(DOT_PREFIXED $+)
141145
DOT_PREFIXED_SKIP=$(DOT_PREFIXED $+)
@@ -469,6 +473,9 @@ TR2=$(TR $1 $2)
469473
TR3=$(TR $1 $2 $3)
470474
TROW=$(TR $(TDX $1, $+))
471475
TROW_EXPLANATORY=<td colspan="10">$0</td>
476+
TWID_LATEST_DATE=
477+
TWID_LATEST_LINK=
478+
TWID_LATEST_TITLE=
472479
_=
473480

474481
UNDERSCORE=_

index.dd

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,17 @@ $(DIVID news,
8484
$(DIVC boxes,
8585
$(DIVC row,
8686
$(TOUR newspaper-o, News,
87-
$(P $(LINK2 http://dconf.org/2017/index.html, DConf 2017)
88-
has successfully concluded!
87+
$(P Stay updated with the
88+
$(LINK2 http://blog.dlang.org,
89+
<cite>Official D Blog</cite>) from $(DBLOG_LATEST_DATE):
90+
$(LINK2 $(DBLOG_LATEST_LINK), $(DBLOG_LATEST_TITLE)) by
91+
$(DBLOG_LATEST_AUTHOR).
8992
)
90-
$(P
91-
Whether you were with us in Berlin or watching from
92-
home, we thank everyone for participating. You can
93-
review the conference through $(LINK2
94-
http://youtube.com/playlist?list=PL3jwVPmk_PRxo23yyoc0Ip_cP3-rCm7eB,
95-
this YouTube playlist).
96-
)
97-
$(P Stay updated with
98-
$(LINK2 http://arsdnet.net/this-week-in-d,
99-
<cite>This Week in D</cite>) -
100-
$(SPANC twid)
93+
$(P Browse weekly summaries in
94+
$(LINK2 http://arsdnet.net/this-week-in-d,
95+
<cite>This Week in D</cite>) -
96+
$(LINK2 $(TWID_LATEST_LINK), $(TWID_LATEST_DATE)):
97+
$(TWID_LATEST_TITLE)
10198
)
10299
)
103100
$(TOUR graduation-cap, Learn,
@@ -424,7 +421,6 @@ Macros:
424421
LAYOUT_SUFFIX=
425422
$(SCRIPTLOAD $(ROOT_DIR)js/platform-downloads.js, data-latest="$(LATEST)")
426423
$(SCRIPTLOAD $(ROOT_DIR)js/run-main-website.js)
427-
$(SCRIPTLOAD //arsdnet.net/this-week-in-d/twid-latest.js)
428424
LAYOUT_TITLE=
429425
TOUR=$(DIVC item, $(SECTION4 $(LINK2 $1, $(TC i, fa fa-$2 big-icon)$3), $4))
430426
TOUR=$(DIVC item, $(SECTION4 $(TC i, fa fa-$1 big-icon)$2, $3))

js/dlang.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,3 @@
8484
});
8585
});
8686
})(jQuery);
87-
88-
// "This Week in D" integration
89-
// setTwid is called from http://arsdnet.net/this-week-in-d/twid-latest.js
90-
// which is included in index.html
91-
function setTwid(url, title, description) {
92-
var twid = $('body#Home .boxes .twid');
93-
twid
94-
.empty()
95-
.append($('<a>').attr('href', url).text(title))
96-
.append(': ')
97-
.append(description);
98-
}

posix.mak

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ CHANGE_SUFFIX = \
9797
for f in `find "$3" -iname '*.$1'`; do\
9898
mv $$f `dirname $$f`/`basename $$f .$1`.$2; done
9999

100+
# Caches the latest D blog post for the front page
101+
DBLOG_LATEST=
102+
100103
# Disable all dynamic content that could potentially have an unrelated impact
101104
# on a diff
102105
ifeq (1,$(DIFFABLE))
@@ -105,6 +108,7 @@ ifeq (1,$(DIFFABLE))
105108
else
106109
CHANGELOG_VERSION_MASTER := "v${LATEST}..upstream/master"
107110
CHANGELOG_VERSION_STABLE := "v${LATEST}..upstream/stable"
111+
DBLOG_LATEST=$G/dblog_latest.ddoc $G/twid_latest.ddoc
108112
endif
109113

110114
################################################################################
@@ -166,7 +170,7 @@ STYLES=$(addsuffix .css, $(addprefix css/, \
166170
# HTML Files
167171
################################################################################
168172

169-
DDOC=$(addsuffix .ddoc, macros html dlang.org doc ${GENERATED}/${LATEST}) $(NODATETIME)
173+
DDOC=$(addsuffix .ddoc, macros html dlang.org doc ${GENERATED}/${LATEST}) $(NODATETIME) $(DBLOG_LATEST)
170174
STD_DDOC=$(addsuffix .ddoc, macros html dlang.org ${GENERATED}/${LATEST} std std_navbar-release ${GENERATED}/modlist-${LATEST}) $(NODATETIME)
171175
STD_DDOC_PRE=$(addsuffix .ddoc, macros html dlang.org ${GENERATED}/${LATEST} std std_navbar-prerelease ${GENERATED}/modlist-prerelease) $(NODATETIME)
172176
SPEC_DDOC=${DDOC} spec/spec.ddoc
@@ -377,6 +381,22 @@ dlangspec.txt : $(DMD) macros.ddoc plaintext.ddoc dlangspec-consolidated.d
377381
dlangspec.verbatim.txt : $(DMD) verbatim.ddoc dlangspec-consolidated.d
378382
$(DMD) -conf= -Df$@ verbatim.ddoc dlangspec-consolidated.d
379383

384+
################################################################################
385+
# Fetch the latest article from the official D blog
386+
################################################################################
387+
388+
$G/dblog_latest.ddoc:
389+
@echo "Receiving the latest DBlog article. Disable with DIIFABLE=1"
390+
curl -s --retry 3 --retry-delay 5 http://blog.dlang.org | grep -m1 'entry-title' | \
391+
sed -E 's/^.*<a href="(.+)" rel="bookmark">([^<]+)<\/a>.*<time class="updated" datetime="[^"]+">([^<]*)<\/time>.*Author *<\/span><a [^>]+>([^<]+)<\/a>.*/DBLOG_LATEST_TITLE=\2|DBLOG_LATEST_LINK=\1|DBLOG_LATEST_DATE=\3|DBLOG_LATEST_AUTHOR=\4/' | \
392+
tr '|' '\n' > $@
393+
394+
$G/twid_latest.ddoc:
395+
@echo "Receiving the latest TWID article. Disable with DIIFABLE=1"
396+
curl -s --retry 3 --retry-delay 5 http://arsdnet.net/this-week-in-d/twid-latest.js | grep setTwid | \
397+
sed -E 's/.*setTwid\("([^"]+)", "([^"]+)", "([^"]+)"\).*/TWID_LATEST_LINK=\1|TWID_LATEST_DATE=\2|TWID_LATEST_TITLE=\3/' | \
398+
tr '|' '\n' > $@
399+
380400
################################################################################
381401
# Git rules
382402
################################################################################

0 commit comments

Comments
 (0)