mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
chat: supporter only for now
This commit is contained in:
parent
07d578ab57
commit
d57e33d951
3 changed files with 11 additions and 9 deletions
|
@ -231,6 +231,7 @@ end
|
||||||
post '/site_files/chat' do
|
post '/site_files/chat' do
|
||||||
require_login
|
require_login
|
||||||
dont_browser_cache
|
dont_browser_cache
|
||||||
|
halt(403) unless parent_site.supporter?
|
||||||
|
|
||||||
# Ensure the request is treated as a stream
|
# Ensure the request is treated as a stream
|
||||||
stream do |out|
|
stream do |out|
|
||||||
|
|
|
@ -52,11 +52,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
var formData = new FormData();
|
var formData = new FormData();
|
||||||
formData.append('csrf_token', chatForm.querySelector('input[name="csrf_token"]').value);
|
formData.append('csrf_token', chatForm.querySelector('input[name="csrf_token"]').value);
|
||||||
|
|
||||||
|
// let systemWithFile = system + "\nThis is the user's current file they are editing:\n" + editor.getValue();
|
||||||
// uncomment this out if disable next two lines
|
let systemWithFile = system
|
||||||
//formData.append('system', system);
|
|
||||||
|
|
||||||
let systemWithFile = system + "\nThis is the user's current file they are editing:\n" + editor.getValue();
|
|
||||||
formData.append('system', systemWithFile);
|
formData.append('system', systemWithFile);
|
||||||
|
|
||||||
formData.append('messages', JSON.stringify(messages));
|
formData.append('messages', JSON.stringify(messages));
|
||||||
|
@ -229,6 +226,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
let chatContainer = document.getElementsByClassName('chat-container')[0];
|
let chatContainer = document.getElementsByClassName('chat-container')[0];
|
||||||
|
|
||||||
var chatEnabled = localStorage.getItem('chatEnabled');
|
var chatEnabled = localStorage.getItem('chatEnabled');
|
||||||
|
|
||||||
if (chatEnabled === 'true') {
|
if (chatEnabled === 'true') {
|
||||||
leftCol.style.width = localStorage.getItem('leftColPct') || '70%';
|
leftCol.style.width = localStorage.getItem('leftColPct') || '70%';
|
||||||
rightCol.style.width = localStorage.getItem('rightColPct') || '30%';
|
rightCol.style.width = localStorage.getItem('rightColPct') || '30%';
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
<a id="saveButton" class="btn-Action" href="#" onclick="saveTextFile(false); return false" style="opacity: 0.5"><span class="hide-on-mobile"><i class="fa fa-save"></i></span>Save</a>
|
<a id="saveButton" class="btn-Action" href="#" onclick="saveTextFile(false); return false" style="opacity: 0.5"><span class="hide-on-mobile"><i class="fa fa-save"></i></span>Save</a>
|
||||||
<span class="hide-on-mobile">
|
<span class="hide-on-mobile">
|
||||||
<a class="btn-Action" href="<%= current_site.uri %>/<%= @filename == 'index.html' ? '' : @filename %>" target="_blank"><i class="fa fa-globe"></i> View</a>
|
<a class="btn-Action" href="<%= current_site.uri %>/<%= @filename == 'index.html' ? '' : @filename %>" target="_blank"><i class="fa fa-globe"></i> View</a>
|
||||||
<a href="#" id="shareButton" class="btn-Action" data-container="body" data-toggle="popover" data-placement="bottom" data-content='<%== erb :'_share', layout: false, locals: {site: current_site, page_uri: "#{current_site.uri}/#{@filename}"} %>'><i class="fa fa-share-alt chat-button"></i> Share</a> <a class="btn-Action" id="chatButton"><i class="fa fa-comments"></i> Chat</a>
|
<a href="#" id="shareButton" class="btn-Action" data-container="body" data-toggle="popover" data-placement="bottom" data-content='<%== erb :'_share', layout: false, locals: {site: current_site, page_uri: "#{current_site.uri}/#{@filename}"} %>'><i class="fa fa-share-alt chat-button"></i> Share</a><% if current_site.supporter? %><a class="btn-Action" id="chatButton"><i class="fa fa-comments"></i> Chat</a><% end %>
|
||||||
</span>
|
</span>
|
||||||
<!-- <a id="saveAndExitButton" class="btn-Action" href="#" onclick="saveTextFile(true); return false" style="opacity: 0.5"><i class="fa fa-save"></i> Save and Exit</a> -->
|
<!-- <a id="saveAndExitButton" class="btn-Action" href="#" onclick="saveTextFile(true); return false" style="opacity: 0.5"><i class="fa fa-save"></i> Save and Exit</a> -->
|
||||||
<div id="editorUpdates" class="tooltip fade bottom in hidden" style="top: 90px;right: 12.5em;">
|
<div id="editorUpdates" class="tooltip fade bottom in hidden" style="top: 90px;right: 12.5em;">
|
||||||
|
@ -106,10 +106,13 @@
|
||||||
<script src="/js/purify.min.js"></script>
|
<script src="/js/purify.min.js"></script>
|
||||||
<script src="/js/marked.min.js"></script>
|
<script src="/js/marked.min.js"></script>
|
||||||
<script src="/js/sse.min.js"></script>
|
<script src="/js/sse.min.js"></script>
|
||||||
<script src="/js/chat.js"></script>
|
|
||||||
|
<% if current_site.supporter? %>
|
||||||
|
<script src="/js/chat.js"></script>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="row editor">
|
<div class="row editor">
|
||||||
<div class="col left-col" style="display: none">
|
<div class="col left-col" style="display: <% current_site.supporter? ? 'none' : 'block' %>; margin-left: 20px;">
|
||||||
<div id="editor"><h3>Loading...</h3></div>
|
<div id="editor"><h3>Loading...</h3></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col right-col chat-container" style="display: none">
|
<div class="col right-col chat-container" style="display: none">
|
||||||
|
|
Loading…
Add table
Reference in a new issue