News Post
Abstract List-friendly news article
Site Infrastructure / News Post

[show modes: view edit info]

[begin preamble]
if(title2id(_title) != _id)
	_bestlink = {id=[_id]}
else if(strcount(_title, "&"))
	_bestlink = {id=[_id]}
else
	_bestlink = urlencode(_title);
[end preamble]

[begin mode link]
<a href="/[_bestlink]">[_title]</a>
[end mode link]

[begin mode view]
[
	_abbr("full");

	$ps = 25;

	$q = query("children", $ps, "id ASC, title", "parent", $_id);
	$qc = query_count($q);
	if($qc != "0") {<h2>Comments</h2>[query_view("view", $q)]};

if($qc > $ps) {<center style="font-size: 80%">
[
$pp = previous_page($q);
$np = next_page($q);
if($pp != "-1") {<a href="[$pp]">older</a>};
if(and($pp != "-1", $np != "-1")) { · };
if($np != "-1") {<a href="[$np]">newer</a>};
]
<br><br>
[page_list($q)]
<br><br>
</center>
};
]
[end mode view]

[begin mode bare]
[$_body]
[end mode bare]

[begin mode abbr2]
<li><a href="/?[$_bestlink]">[$_title]</a> ([$_subtitle])
[$children = children("abbr", $_id);
iif($children, echo("<ol>" & $children & "</ol>"), "");]
</li>
[end mode abbr2]

[begin mode abbr3]
<li><a href="/?[$_bestlink]" title="[$_subtitle]">[$_title]</a></li>
[end mode abbr3]

[begin mode abbr4]
<span class="item"><b><a href="/?id=[_id]" title="[$_subtitle]">[$_title]</a></b>[
tt = get_template(_parent);
if((tt == title2id("Universe")) || (tt == title2id("User Profile"))) {[
	bt = getva("blog_title", get_body(_parent));
	if(bt != "") {
		<span class="subtext"><a href="/?id=[_parent]">[bt] ([get_title(_parent)])</a></span>
	} else if(tt == title2id("Universe")) {
		<span class="subtext"><a href="/?id=[_parent]">[get_title(_parent)] News</a></span>
	} else {
		<span class="subtext"><a href="/?id=[_parent]">[get_title(_parent)]'s Blog</a></span>
	}
]} else {
	<span class="subtext"><a href="/?id=[_parent]">[get_title(_parent)]</a></span>
}
]</span>
[end mode abbr4]

[begin mode delete]
[$n = delete_page($_id);
children("delete", $_id);
if($n == "1") {
	<p><b>[$_title]</b> has been removed from 
	<b>[get_title($_parent)]</b>.</p>
} else {
	<p><b>[$_title]</b> could not be removed from 
	<b>[get_title($_parent)]</b> by you ([$_viewer.name]). If 
	you feel that should be able to do so, now might be a good 
	time to	<a href="mailto:hexadecima@gmail.com">complain and/or 
	whine</a>.</p>
}]
<p><a href="/?id=[$_parent]">Return to [get_title($_parent)]</a></p>
[end mode delete]

[begin mode abbr]
[msg_start({position: relative; padding-bottom: 30px;})]

<div class="news_header">
[
if($_args[0] != "no_icon") {
<div style="display: inline-block; vertical-align: middle;" class="news_icon">
<style type="text/css">
	.news_icon img { width: 50px; height: 50px; }
</style>
	[
	if($_args[0] == "inherit") {[
		if(has_mode("icon", $_parent)) {[
			page("icon", $_parent);
		]} else if($_owner.profile_id != 0) {[
			page("icon", $_owner.profile_id);
		]};
	]} else if($_owner.profile_id != 0) {
		[page("icon", $_owner.profile_id);]
	};
	]
</div>};

if(can_edit() + can_direct()) {<p style="display: block; float: right; margin: 0px; font-size: 80%;">};
if(can_edit()) {<a href="/?id=[$_id]&mode=edit">edit</a>[if(can_direct()) { · }]};
if(can_direct()) {<a href="/?id=[$_id]&mode=delete">delete</a>};
if(can_edit() + can_direct()) {</p>};

]

<h2 style="display: inline-block; margin: 0; vertical-align: middle; font-size: 140%; font-weight: lighter;">
<a href="?id=[$_id]">[$_title]</a>
</h2>
</div>
<div>
[

$d = strpos($_body, "[snip]");
$b = replace($_body, "[snip]", "");
$lenb = len($b);

c = @_this.cache;
sc = @_this.shortcache;

if(c == "") if(len(_body) > 0) {[
	mute _do_cache();
	c = @_this.cache;
	sc = @_this.shortcache;
]};

if($_args[0] != "full") {[
	if($d != "-1") {[
		if(sc == "") {<i>This post has no content.</i>} else _emoticons(_dynamic_format(sc), _author);
	]} else {[
		if(c == "") {<i>This post has no content.</i>} else _emoticons(_dynamic_format(c), _author);
	]};
]} else {[
	if(c == "") {<i>This post has no content.</i>} else _emoticons(_dynamic_format(c), _author);
]};

]
</div>

<span class="caption newstag" style="font-size: 80%; bottom: 8px; left: 8px; position: absolute;">
<a href="/?id=[$_parent]">[if(get_template($_parent) != 8) get_title($_parent) else page("blog_title", $_parent)]</a>
</span>

<span class="caption newstag" style="font-size: 80%; bottom: 8px; right: 8px; position: absolute;">

[
$q = query({children_[$_id]}, 0, "id", "parent", $_id);

if(can_comment())
  {<a href="?id=[$_id]&mode=comment">comment</a> · };

$qc = query_count($q);

$qc = $qc + reduce( split(children("children_count", _id), chr(10)) ) ?(x, y) (x + y);
if($qc == "") $qc = 0;

if($d == "-1") {[
	$bleft = 0;
]} else {[
	$bleft = ($lenb - $d);
]};

if($_args[0] != "full") {[
	if($bleft != 0) {[
		if($qc != "0") {
			<a href="/?id=[$_id]">read more
			([$qc] comment[iif($qc != 1, "s", "")], [$bleft] bytes)</a> · } else {<a href="/?id=[$_id]">read more
			([$bleft] bytes)</a> · };
	]} else {[
		if($qc != 0) {<a href="/?id=[$_id]">read more
		([$qc] comment[iif($qc != 1, "s", "")])</a> · };
	]};
]};
]

[if(soft_age[$_subtitle] == "") {
	[soft_age($_date)] ago
} else {
	[soft_age($_subtitle)] ago
};
]

</span>

[msg_end()]
[end mode abbr]

[begin mode table]
<tr><td style="width: 120px !important">
    [substr($_subtitle, 5, 11)]
</td><td style="width: 240px !important">
    <a href="/?[$_bestlink]">[$_title]</a>
</td></tr>
[end mode table]

[begin mode info]
<table>
<tr><th>Title:</th><td>[info_display($_title)]</td></tr>
<tr><th>Date (subtitle):</th><td>[info_display($_subtitle)]</td></tr>
<tr><th>Parent:</th><td>[$_parent]</td></tr>
<tr><th>Permissions:</th><td>[$_permissions]</td></tr>
<tr><th>Author:</th><td>[$_author]</td></tr>
<tr><th>Group:</th><td>[$_group]</td></tr>
<tr><th>ID:</th><td>[$_id]</td></tr>
<tr><th>Template:</th><td>[$_template]</td></tr>
<tr><th>Body:</th><td>[info_display($_body)]</td></tr>
<tr><th>Body Alternate:</th><td>[replace(info_display($_body), "&", "&")]</td></tr>
</table>
[end mode info]

[begin mode edit]
<form method="post" action="/">
<input type="hidden" name="id" value="[$_id]">
<input type="hidden" name="mode" value="submit">
<table>
<tr><th>Title:</th><td><input type="text" class="textbox" name="title" value="[edit_display($_title)]" style="width: 100%"></td></tr>
[if($_subtitle == "") $_subtitle = $_date;]
<tr><th>Category:</th><td><select name="parent">
<option value="[$_parent]" selected>[get_title($_parent)]</option>
[
// index("option", title2id("Galaxy"));
]
</select>
</td></tr>
<tr><th>Body:</th><td><textarea class="textbox" name="body" rows="20" cols="70">[edit_display($_body)]</textarea>
<style type="text/css">
@keyframes blink {
	0% {color: blue}
	50% {color: black}
}
</style>
<span style="font-size: 80%; display: block;">You may use <a href="/?Formatting and Markup">WF-style wiki formatting</a> here. <b style="[
if(_viewer._id == 3) {animation: blink 1s step-end infinite; font-size: 200%};
if(_viewer._id == 8) {animation: blink 1s step-end infinite};
if(_viewer._id == 21) {animation: blink 1s step-end infinite};
]">Type <tt>["[snip]"]</tt> to hide the rest of the post until the user opens it specifically.</b></span>
</td></tr>
<tr><td></td><td>
<input name="submitButton" class="submit" type="submit" value="Submit"> <i>your permissions</i>: [summarize_permissions($_viewer.permissions)]</td></tr></table>
</form>
[end mode edit]
[begin mode do_cache][
	$d = strpos($_body, "[snip]");
	$b = replace($_body, "[snip]", "");
	$lenb = len($b);

	@_this.cache = _static_format($b);

	if($d != "-1")
		@_this.shortcache = _static_format({[substr(_body, 0, $d)] ["["]#[$_id]["|(…)]"]}, "no toc")
	else
		@_this.shortcache = @_this.cache;

	return $d;
][end mode do_cache]
[begin mode submit]
[
	$_title = $_params.title;
	$_parent = $_params.parent;
	$_body = $_params.body;

	$d = _do_cache();

	refresh_to({./?id=[_id]}, 2);
]
<h2>It was submitted.</h2>
<p>(Cache updated.[if($d == -1) " No [snip] found."])</p>
<a href="/?id=[$_id]">Return to it.</a>
[end mode submit]

[begin mode comment]
	[_post_comment($_id)]
[end mode comment]

[begin mode comment_submit]
    [$title = {Comment on [$_title] at [now()] by [$_viewer.name]};
	$e = new_page($title, $_id);
	if($e) {[
	    set_body($e, $_params.body);
	    set_template($e, title2id("Generic Comment"));
            set_permissions($e, "cadrec--r-c-dr-c--r-");
            set_group($e, $_group);

            if($_group != 0) {[
			if(not(is_user_in_group($_author, $_group)))
				$n = _post_message($_author, (if(_viewer.profile_id > 0) {<a href="[bare_url()]/?id=[$_viewer.profile_id]">[_viewer.name]</a>} else $_viewer.name) & { posted a reply to 
				<a href="[bare_url()]?id=[$_id]">[$_title]</a> [if($_group != 0) { (Project: <a href="[bare_url()]?id=[get_group_profile_id($_group)]">
		        	[get_title(get_group_profile_id($_group))]</a>)}]:
				<br>[_emoticons(_wiki_format($_params.body, "no toc"))]
			});
			$m = _post_message_group($_group, {
				[page("link", $_viewer.profile_id)] posted a reply to 
				<a href="[bare_url()]?id=[$_id]">[$_title]</a>[
					if($_group != 0)
						{ (Project: <a href="[bare_url()]?id=[get_group_profile_id($_group)]">
						[get_title(get_group_profile_id($_group))]</a>)}
					]:<br>
				[_emoticons(_wiki_format($_params.body, "no toc"))]
			});
		]} else
			$m = _post_message($_author, {
				[page("link", $_viewer.profile_id)] posted a reply to 
				<a href="[bare_url()]?id=[$_id]">[$_title]</a>:
				<br>[_emoticons(_wiki_format($_params.body, "no toc"))]
			});


            refresh_to({./?id=[_id]}, 1);
            msg_start();]
            Commented successfully!<br>
            <a href="/?id=[$_id]">Return to the article.</a>
            [msg_end();
        ]} else {[
            msg_start();]
            Couldn't comment.<br>
            Maybe you don't have permissions?<br>
            Are you logged in?<br>
            <a href="/?id=[$_id]">Return to the article.</a>
            [msg_end();
        ]};
    ]
[end mode comment_submit]