annotate src/thread.html.luan @ 44:96f0c3d65698

add /bbcode
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 10 Nov 2022 23:18:58 -0700
parents 0c1b820fff34
children 289718f121e4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local ipairs = Luan.ipairs or error()
18
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
4 local Time = require "luan:Time.luan"
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
5 local time_now = Time.now or error()
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
6 local Html = require "luan:Html.luan"
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
7 local html_encode = Html.encode or error()
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local Io = require "luan:Io.luan"
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local Http = require "luan:http/Http.luan"
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local Shared = require "site:/lib/Shared.luan"
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 local head = Shared.head or error()
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 local header = Shared.header or error()
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 local footer = Shared.footer or error()
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
14 local delete_post = Shared.delete_post or error()
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
15 local show_post = Shared.show_post or error()
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 local Forum = require "site:/lib/Forum.luan"
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 local forum_title = Forum.title or error()
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 local Db = require "site:/lib/Db.luan"
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 local Post = require "site:/lib/Post.luan"
16
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
20 local User = require "site:/lib/User.luan"
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21
11
3ed1e3f3a53a use bbcode_to_html
Franklin Schmidt <fschmidt@gmail.com>
parents: 9
diff changeset
22
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 return function()
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 local root_id = Http.request.parameters.root or error()
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 local docs, total_hits = Db.search("post_root_id:"..root_id,1,1000,{sort="id"})
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 local posts = Post.from_docs(docs)
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 local subject_html = posts[1].subject_html
16
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
28 local user = User.current()
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
29 local user_name = user and user.name
18
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
30 local now = time_now()
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 Io.stdout = Http.response.text_writer()
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 %>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 <!doctype html>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 <html>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 <head>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 <% head() %>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 <title><%=forum_title%>: <%=subject_html%></title>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 <style>
18
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
39 div[author] {
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
40 margin-bottom: 6px;
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
41 font-size: 10px;
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
42 }
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
43 div[author] img {
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
44 width: 28px;
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
45 vertical-align: middle;
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
46 border-radius: 50%;
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
47 }
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
48 div[author] a {
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
49 font-weight: bold;
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
50 }
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
51 span[ago] {
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
52 color: #888;
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
53 }
15
0edde02b908c edit in place
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
54 [message] {
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 white-space: pre-wrap;
26
0837820b97fb tinymce work
Franklin Schmidt <fschmidt@gmail.com>
parents: 25
diff changeset
56 line-height: 1.4;
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
57 }
25
66fd3784e60e back to textarea for bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
58 textarea {
66fd3784e60e back to textarea for bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
59 width: 100%;
66fd3784e60e back to textarea for bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
60 xmax-width: 450px;
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
61 xheight: 100px;
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
62 }
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
63 <% if user_name == nil then %>
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
64 [logged_in] {
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
65 display: none;
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
66 }
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
67 <% end %>
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
68 [only_user] {
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
69 display: none;
25
66fd3784e60e back to textarea for bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
70 }
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
71 <% if user_name ~= nil then %>
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
72 [only_user="<%=html_encode(user_name)%>"] {
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
73 display: initial;
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
74 }
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
75 <% end %>
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
76 div[post]:first-of-type [delete_opton] {
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
77 display: none;
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
78 }
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
79 body[thread_size="1"] div[post]:first-of-type [delete_opton] {
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
80 display: initial;
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
81 }
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
82 </style>
15
0edde02b908c edit in place
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
83 <script>
19
da006d1c1eba use contentEditable
Franklin Schmidt <fschmidt@gmail.com>
parents: 18
diff changeset
84 function getPostDiv(node) {
da006d1c1eba use contentEditable
Franklin Schmidt <fschmidt@gmail.com>
parents: 18
diff changeset
85 do {
da006d1c1eba use contentEditable
Franklin Schmidt <fschmidt@gmail.com>
parents: 18
diff changeset
86 if( node.getAttribute('post') )
da006d1c1eba use contentEditable
Franklin Schmidt <fschmidt@gmail.com>
parents: 18
diff changeset
87 return node;
da006d1c1eba use contentEditable
Franklin Schmidt <fschmidt@gmail.com>
parents: 18
diff changeset
88 } while( node = node.parentNode );
da006d1c1eba use contentEditable
Franklin Schmidt <fschmidt@gmail.com>
parents: 18
diff changeset
89 }
da006d1c1eba use contentEditable
Franklin Schmidt <fschmidt@gmail.com>
parents: 18
diff changeset
90
32
Franklin Schmidt <fschmidt@gmail.com>
parents: 26
diff changeset
91 function cancelEdit(src) {
Franklin Schmidt <fschmidt@gmail.com>
parents: 26
diff changeset
92 let postDiv = getPostDiv(src);
15
0edde02b908c edit in place
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
93 postDiv.querySelector('[output]').style.display = 'block';
0edde02b908c edit in place
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
94 postDiv.querySelector('[edit]').innerHTML = '';
0edde02b908c edit in place
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
95 }
32
Franklin Schmidt <fschmidt@gmail.com>
parents: 26
diff changeset
96 function saveEdit(src) {
Franklin Schmidt <fschmidt@gmail.com>
parents: 26
diff changeset
97 let postDiv = getPostDiv(src);
19
da006d1c1eba use contentEditable
Franklin Schmidt <fschmidt@gmail.com>
parents: 18
diff changeset
98 let post = postDiv.getAttribute('post');
25
66fd3784e60e back to textarea for bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
99 let text = postDiv.querySelector('textarea').value;
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
100 cancelEdit(src);
15
0edde02b908c edit in place
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
101 let postData = 'post=' + post + '&text=' + encodeURIComponent(text);
34
c8d47981c74f upload using ajax
Franklin Schmidt <fschmidt@gmail.com>
parents: 33
diff changeset
102 ajax('save_edit.js',postData);
15
0edde02b908c edit in place
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
103 }
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
104 function updated(postId,html) {
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
105 let postDiv = document.querySelector('[post="'+postId+'"]');
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
106 if(postDiv)
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
107 postDiv.querySelector('[message]').innerHTML = html;
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
108 }
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
109
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
110 function newPost() {
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
111 let postDiv = document.querySelector('[post="new"]');
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
112 let textarea = postDiv.querySelector('textarea')
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
113 let text = textarea.value;
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
114 textarea.value = '';
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
115 let postData = 'root=<%=root_id%>&text=' + encodeURIComponent(text);
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
116 ajax('new_post.js',postData);
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
117 }
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
118 function added(postId,html,thread_size) {
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
119 if( document.querySelector('[post="'+postId+'"]') )
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
120 return;
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
121 let newDiv = document.querySelector('[post="new"]');
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
122 newDiv.insertAdjacentHTML('beforebegin',html);
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
123 document.body.setAttribute('thread_size',thread_size);
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
124 }
16
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
125
35
Franklin Schmidt <fschmidt@gmail.com>
parents: 34
diff changeset
126 function uploaded(input,url,filename) {
Franklin Schmidt <fschmidt@gmail.com>
parents: 34
diff changeset
127 let postDiv = getPostDiv(input);
Franklin Schmidt <fschmidt@gmail.com>
parents: 34
diff changeset
128 let textarea = postDiv.querySelector('textarea');
Franklin Schmidt <fschmidt@gmail.com>
parents: 34
diff changeset
129 textarea.focus();
Franklin Schmidt <fschmidt@gmail.com>
parents: 34
diff changeset
130 textarea.setRangeText(url,textarea.selectionStart,textarea.selectionEnd,'select');
32
Franklin Schmidt <fschmidt@gmail.com>
parents: 26
diff changeset
131 }
Franklin Schmidt <fschmidt@gmail.com>
parents: 26
diff changeset
132
16
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
133 function deletePost(span) {
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
134 span.innerHTML = document.querySelector('[hidden][delete]').innerHTML;
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
135 }
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
136 function deleteNo(span) {
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
137 span.innerHTML = document.querySelector('[hidden][undelete]').innerHTML;
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
138 }
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
139 function deleteYes(span) {
19
da006d1c1eba use contentEditable
Franklin Schmidt <fschmidt@gmail.com>
parents: 18
diff changeset
140 let post = getPostDiv(span).getAttribute('post');
16
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
141 ajax( '/delete.js?post=' + post );
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
142 }
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
143 function deleted(postId,thread_size) {
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
144 let postDiv = document.querySelector('[post="'+postId+'"]');
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
145 if(!postDiv)
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
146 return
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
147 postDiv.outerHTML = '';
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
148 document.body.setAttribute('thread_size',thread_size);
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
149 }
18
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
150
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
151 function init() {
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
152 let spans = document.querySelectorAll('span[ago]');
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
153 for( let i=0; i<spans.length; i++ ) {
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
154 let span = spans[i];
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
155 let date = span.getAttribute('date');
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
156 date = parseInt(date);
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
157 span.title = new Date(date).toLocaleString();
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
158 }
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 16
diff changeset
159 }
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
160
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
161 let eventSource = new EventSource(location.href);
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
162 eventSource.onmessage = function(event) {
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
163 eval( event.data );
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
164 };
15
0edde02b908c edit in place
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
165 </script>
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
166 </head>
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
167 <body onload="init()" thread_size="<%=Post.thread_size(root_id)%>">
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
168 <% header() %>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
169 <div content>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
170 <h1><%=subject_html%></h1>
16
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
171 <% for _, post in ipairs(posts) do
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
172 show_post(post,now)
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
173 end %>
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
174 <div post=new logged_in>
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
175 <hr>
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
176 <textarea oninput="fixTextarea(this)"></textarea>
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
177 <p>
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
178 <input type=file onchange="upload(this,uploaded)">
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
179 <button onclick="fileButtonClick(this)">Upload File</button>
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
180 <button onclick="newPost()">save</button>
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
181 </p>
15
0edde02b908c edit in place
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
182 </div>
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
183 </div>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
184 <% footer() %>
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
185
16
bff178656073 delete function
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
186 <span hidden delete>Delete? <a href="javascript:" onclick="deleteYes(parentNode)">yes</a> / <a href="javascript:" onclick="deleteNo(parentNode)">no</a></span>
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
187 <span hidden undelete><%delete_post()%></span>
19
da006d1c1eba use contentEditable
Franklin Schmidt <fschmidt@gmail.com>
parents: 18
diff changeset
188 <div hidden edit>
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 35
diff changeset
189 <textarea oninput="fixTextarea(this)"></textarea>
19
da006d1c1eba use contentEditable
Franklin Schmidt <fschmidt@gmail.com>
parents: 18
diff changeset
190 <p>
35
Franklin Schmidt <fschmidt@gmail.com>
parents: 34
diff changeset
191 <input type=file onchange="upload(this,uploaded)">
34
c8d47981c74f upload using ajax
Franklin Schmidt <fschmidt@gmail.com>
parents: 33
diff changeset
192 <button onclick="fileButtonClick(this)">Upload File</button>
19
da006d1c1eba use contentEditable
Franklin Schmidt <fschmidt@gmail.com>
parents: 18
diff changeset
193 <button onclick="saveEdit(this)">save</button>
da006d1c1eba use contentEditable
Franklin Schmidt <fschmidt@gmail.com>
parents: 18
diff changeset
194 <button onclick="cancelEdit(this)">cancel</button>
da006d1c1eba use contentEditable
Franklin Schmidt <fschmidt@gmail.com>
parents: 18
diff changeset
195 </p>
da006d1c1eba use contentEditable
Franklin Schmidt <fschmidt@gmail.com>
parents: 18
diff changeset
196 </div>
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
197 </body>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
198 </html>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
199 <%
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
200 end