Linear Post
Site Infrastructure / Linear Post

[read modes: view]
[edit modes: edit]

[begin mode admin]
[clean_title = get_title(_parent);
if(strpos(clean_title, "<!>") >= 0) clean_title = substr(clean_title, 0, strpos(clean_title, "<!>"));

override_parent({/?id=[_parent]&posts_pagenum=[_pagenumber()]#[_id]}, info_display(clean_title));

if(not(is_user_in_group(_viewer.id, 1))) return "can't show that in a christian manga";]
<form method="post" action="/">
<input type="hidden" name="id" value="[_id]">
<input type="hidden" name="mode" value="admin_submit">
<textarea name="css">[edit_display(_this.css)]</textarea>
<input type="submit" value="Update">
</form>
[end mode admin]

[begin mode do_cache][
	@_this.cache = _static_format(_body);
][end mode do_cache]

[begin mode admin_submit][clean_title = get_title(_parent);
	if(strpos(clean_title, "<!>") >= 0) clean_title = substr(clean_title, 0, strpos(clean_title, "<!>"));
	override_parent({/?id=[_parent]&posts_pagenum=[_pagenumber()]#[_id]}, info_display(clean_title));

	_this.css = _params.css;
	refresh_to({/?id=[_id]}, 1);
][end mode admin_submit]

[begin mode preview][clean_title = get_title(_parent);
	if(strpos(clean_title, "<!>") >= 0) clean_title = substr(clean_title, 0, strpos(clean_title, "<!>"));
	override_parent({/?id=[_parent]&posts_pagenum=[_pagenumber()]#[_id]}, info_display(clean_title));

	override_title("Preview Edit", info_display(_title));
	_postform(_params.title, _params.body);
][end mode preview]

[begin mode pagenumber][
	parent = (import entry _parent);
	ind = parent._postindex(_id) - 1;
	return 20 * int(ind / 20);
][end mode pagenumber]

[begin mode delete_submit][clean_title = get_title(_parent);
if(strpos(clean_title, "<!>") >= 0) clean_title = substr(clean_title, 0, strpos(clean_title, "<!>"));
override_parent({/?id=[_parent]&posts_pagenum=[_pagenumber()]#[_id]}, info_display(clean_title));
]
See <a href="/?id=[_id]&mode=delete">the delete mode</a> instead.
[end mode delete_submit]

[begin mode delete]
[
	clean_title = get_title(_parent);
	if(strpos(clean_title, "<!>") >= 0) clean_title = substr(clean_title, 0, strpos(clean_title, "<!>"));
	override_parent({/?id=[_parent]&posts_pagenum=[_pagenumber()]#[_id]}, info_display(clean_title));

	override_title(replace(info_display(_title), "<!>", ""), info_display(clean_title));

	if(can_direct()) {[
		origin = getva("origin", get_body(_parent));

		if(_id == origin) {[
			page("delete", _parent);
		]} else {[
			pagenum = _pagenumber();
			if((pagenum % 20) == 1) pagenum = pagenum - 20;
			if(pagenum < 0) pagenum = 0;

			if(delete_page(_id)) {
				[refresh_to({/?id=[_parent]&posts_pagenum=[pagenum]}, 1)]
				Deleted!
				<a href="/?id=[_parent]">Back to the thread!</a>
			};
		]};
	]} else {
		Go away!
	};
]
[end mode delete]

[begin mode delete_confirm]
[
	clean_title = get_title(_parent);
	if(strpos(clean_title, "<!>") >= 0) clean_title = substr(clean_title, 0, strpos(clean_title, "<!>"));
	override_parent({/?id=[_parent]&posts_pagenum=[_pagenumber()]#[_id]}, info_display(clean_title));

	override_title(replace(info_display(_title), "<!>", ""), info_display(clean_title));
]
<p><b>Are you sure you really want to delete this post?</b></p>
<br>
<p><b><a href="/?id=[_id]&mode=delete">Yes! Let it happen.</a></b></p>
<br>
<p><b><a href="/?id=[_parent]">No! Get me out of here.</a></b></p>
[end mode delete_confirm]

[begin mode abbr]
[_view()]
<div style="text-align: right; font-size: 80%;"><i>in thread:</i> <a href="/?id=[_parent]&posts_pagenum=[_pagenumber()]#[_id]">[
clean_title = get_title(_parent);
if(strpos(clean_title, "<!>") >= 0) clean_title = substr(clean_title, 0, strpos(clean_title, "<!>"));
info_display(clean_title)]</a></div>
[end mode abbr]

[begin mode mark_read][
if(_this[_viewer.id] != "") _this[_viewer.id] = "";
][end mode mark_read]

[begin mode view]<a name="[_id]" style="font-size: 0px;"></a><div id="post_[_id]" style="overflow: hidden; margin-top: 5px; margin-bottom: 10px">[
	clean_title = get_title(_parent);
	if(strpos(clean_title, "<!>") >= 0) clean_title = substr(clean_title, 0, strpos(clean_title, "<!>"));

	override_title(replace(info_display(_title), "<!>", ""), info_display(clean_title));
	override_parent({/?id=[_parent]&posts_pagenum=[_pagenumber()]#[_id]}, info_display(clean_title));
]
<style type="text/css">[if(_this.css != "") _this.css]
.post_body, .post_title, .post_left {
	-webkit-hyphens: auto;
	-moz-hyphens: auto;
	-ms-hyphens: auto;
        hyphens: auto;
	z-index: 1;
	position: relative;
}
.post_title {
	word-break: break-all;
}
</style>
[
if(_this[_viewer.id] == "") 
	msg_start({margin-top: 0px; margin-bottom: 0px})
else {[
	msg_start({border-color: #0086b6; margin-top: 0px; margin-bottom: 0px}, "new_post");
	prog(delete_data(_id, _viewer.id));
	// _this[_viewer.id] = "";
]};

if(_owner.profile_id > 0) page("post_bg", _owner.profile_id, list(_id));
]
<div class="post_left">
[
	if(_owner.profile_id > 0) {
		<span class="mobile_only" style="float: right"><a href="/?id=[_owner.profile_id]&mode=message">?</a></span>
		[page("icon", _owner.profile_id)]
		<span style="display: block; font-size: 90%;"><b><a href="/?id=[_owner.profile_id]">[_owner.name]</a></b>
		</span>
	} else {
		<b style="display: block; font-size: 90%;">[_owner.name]</b>
	}
]
[
ge = get_extended(_author);
pcount = getva("posts", ge);

// force post count consistency—slow and undesirable

//if(_owner.profile_id == 0) {[
	pcount2 = query_count(query("posts", 0, "id", "author", _author, "template", _template));
//	debug("Real post count for " & _owner.name & ": " & pcount2);
	if(pcount2 > pcount) {[
		putva("posts", pcount2, ge);
		set_extended(_author, ge);
		pcount = pcount2;
	]};
//]};
]

<span style="font-size: 60%; display: block; max-width: 100px;" class="no_max_width_in_mobile">
[
	st = "";
	if(_owner.profile_id != 0) st = get_subtitle(_owner.profile_id);
	info_display(st);
	if(st != "") "<br>";
]
posts: [pcount]<br class="no_mobile"><span class="mobile_only_inline">, </span>
<span title="next rank: [
	if(_owner.profile_id != 0) {[
		a = (2 ^ int(1 + log2(pcount)));
		if(a < 32) a = 32;
		if(a > 8192) {max level} else a;
	]} else {[
		a = (10 ^ int(1 + log10(pcount)));
		if(a > 1000) {max level} else a;
	]};
]">[if(strpos(_this.location, "(rank)") >= 0) {[
		_this.rankloc = replace(_this.location, "(rank)", _postrank(pcount, _owner));
		_this.rankloc & "<br>";
	]} else {
		[if(_this.location != "") {[
			_postrank(pcount, _owner);
			lead = substr(_this.location, 0, 1);
			if(lead != ",") if(lead != " ") ", ";
			_this.location & "<br>";
		]} else  {[
			_postrank(pcount, _owner);
		]};]
	}]
</span>
<a href="/?id=[_owner.profile_id]&mode=message" class="no_mobile" style="display: block">message</a></span>
</div>

<div class="post_right">

[
	origin = getva("origin", get_body(_parent));

	if((substr(_title, 0, 3) == "<!>") || (_id == origin))
		{}
	else
		{<div class="post_title">[
			if(strpos(_title, "<!>#") == -1)
				info_display(_title)
			else
				info_display(substr(_title, 0, strpos(_title, "<!>#")));
		]</div>};
]
<div class="post_body">

[
	c = @_this.cache;
	if(c == "") {[
		_do_cache();
		c = @_this.cache;
	]};

	bv = _emoticons(_dynamic_format(c), _author);

	opens = strcount(bv, "<div");
	closes = strcount(bv, "</div>");

	while(closes > opens) {[
		bv = "<div>" & bv;
		opens = strcount(bv, "<div");
	]};

	while(opens > closes) {[
		bv = bv & "</div>";
		closes = strcount(bv, "</div>");
	]};
	bv;
]
</div>

<div class="post_footer"><nobr>[

	// {#[page("postindex", _parent, list(_id))] };

	if(int(_this.edits) > 1) {
		edited [int(_this.edits)] time[if(_this.edits > 1) {s}], last update
	} else if(int(_this.edits == 1)) {
		edited once, last update
	}

]<span title="[_date]">[soft_age(_date)] ago</span></nobr>
<nobr>
[if(can_edit() || can_direct() || can_comment(_parent)) {

	[		
		if(can_edit()) {   <a href="/?id=[_id]&mode=edit">edit</a> };
		if(can_direct()) {   <a href="/?id=[_id]&mode=delete_confirm">delete</a> };

		if(is_user_in_group(_viewer.id, 1)) {   <a href="/?id=[_id]&mode=admin">css</a> 
		  <a href="/lists.star?mode=edit_page&id=[_id]">manage</a>};

		if(can_comment(_parent)) {   <a href="/?id=[_parent]&mode=reply"e=[_id]#[_id]">quote</a> };
	]
};
]
  <a href="/?id=[_id]">link</a>
	</nobr>
</div>
<div style="clear: left"></div>
</div>
[msg_end()]</div>
[end mode view]
[begin mode edit]
[
	clean_title = get_title(_parent);
	if(strpos(clean_title, "<!>") >= 0) clean_title = substr(clean_title, 0, strpos(clean_title, "<!>"));
	override_parent({/?id=[_parent]&posts_pagenum=[_pagenumber()]#[_id]}, info_display(clean_title));
	override_title(replace(_title, "<!>", ""), info_display(clean_title));

	page("view", 63);

	_postform(_title, _body);
]
[end mode edit]
[begin mode post]
[
	clean_title = get_title(_parent);
	if(strpos(clean_title, "<!>") >= 0) clean_title = substr(clean_title, 0, strpos(clean_title, "<!>"));
	override_parent({/?id=[_parent]&posts_pagenum=[_pagenumber()]#[_id]}, info_display(clean_title));
	override_title(replace(info_display(_title), "<!>", ""), info_display(clean_title));

if(can_edit()) {
	[
		_title = _params.title;
		_body = _params.body;
		_do_cache();
		_this.edits = int(_this.edits) + 1;
		origin = getva("origin", get_body(_parent));
		if(_id == origin)
			set_title(_parent, _title);

		if(_author == _viewer.id) {[
			locstyle = getu("locstyle");
			if(locstyle == "country") {[
				locinfo = ip2location(_viewer.ip);
				loc = locinfo.geoplugin_countryName;
			]} else if(locstyle == "city") {[
				locinfo = ip2location(_viewer.ip);
				loc = {[locinfo.geoplugin_city], [locinfo.geoplugin_countryName]};
			]} else if(locstyle == "custom") {[
				loc = getu("locfantasy");
			]} else {[
				loc = "";
			]};

				if(loc != "") {[
				locstring = getu("locstring");
				if(len(locstring) > 0) {[
					if(strpos(locstring, "(loc)") >= 0) {[
						customlocation = replace(locstring, "(loc)", loc);
					]} else {[
						customlocation = locstring & ", " & loc;
					]};
				]};
				
				if(len(customlocation) > 0) {[
					_this.location = customlocation;
				]} else {[
					_this.location = ", " & loc;
				]};
			]};
		]};

		// q = query("posts", 20, "id", "parent", _id);
		// qc = query_count(q);
		pagenum = _pagenumber();
		_date = now();
		refresh_to({/?id=[_parent]&posts_pagenum=[pagenum]#[_id]}, 1);
	]

	<p>Success! <b><a href="/?id=[_parent]&posts_pagenum=[pagenum]#[_id]">Click here to go view it.</a></b></p>
} else {
	<p><b>Outside of your permissions!</b></p>
	<p>Keep trying...</p>
	<p><b><a href="##" onClick="history.go(-1); return false;">Or go back.</a></b></p>
};
]
[end mode post]