From 05a8d7394808b4f9b2e54b492d6851c9c132d680 Mon Sep 17 00:00:00 2001 From: Matias Date: Fri, 17 May 2024 14:07:53 -0300 Subject: [PATCH] updates --- README.md | 4 +-- .../initializers/custom-modal-button.js | 32 +++++++++++-------- plugin.rb | 4 +-- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index b0dc1c0..c9b8ae4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# **Plugin Name** Plugin +# **Socratic Bot** Plugin **Plugin Summary** -For more information, please see: **url to meta topic** +For more information, please see: **[about page](https://socratic.bot/about)** diff --git a/assets/javascripts/discourse/initializers/custom-modal-button.js b/assets/javascripts/discourse/initializers/custom-modal-button.js index 4f56272..a41dd86 100644 --- a/assets/javascripts/discourse/initializers/custom-modal-button.js +++ b/assets/javascripts/discourse/initializers/custom-modal-button.js @@ -1,18 +1,18 @@ import { withPluginApi } from "discourse/lib/plugin-api"; -// import showModal from "discourse/lib/show-modal"; -import MyModal from '../components/custom-modal' +import MyModal from "../components/custom-modal"; function initializeWithApi(api) { api.modifyClass("component:d-editor", { - pluginId: 'socratic-modal', + pluginId: "socratic-modal", actions: { openSocraticModal(text, encodedTextValue) { - this.modal.show(MyModal, { model: { textValue: text, Url: encodedTextValue } }); - } - } + this.modal.show(MyModal, { + model: { textValue: text, Url: encodedTextValue }, + }); + }, + }, }); - api.onToolbarCreate((toolbar) => { toolbar.addButton({ id: "think_critically", @@ -21,10 +21,10 @@ function initializeWithApi(api) { sendAction: (editor) => { const textValue = editor.getText(); const test = encodeURIComponent(textValue); - const encodedTextValue = `https://www.google.com/search?q=${test}` - console.log(encodedTextValue) - toolbar.context.send('openSocraticModal', textValue, encodedTextValue); - } + //Replace with actual URL + const encodedTextValue = `https://www.google.com/search?q=${test}`; + toolbar.context.send("openSocraticModal", textValue, encodedTextValue); + }, }); }); @@ -41,21 +41,25 @@ function initializeWithApi(api) { function getTextAreaValue(api) { // Select the textarea element with the specified classes - const textarea = document.querySelector(".ember-text-area.ember-view.d-editor-input"); + const textarea = document.querySelector( + ".ember-text-area.ember-view.d-editor-input" + ); // Check if textarea is found if (textarea) { // Retrieve the value of the textarea const textValue = textarea.value; const test = encodeURIComponent(textValue); + //Replace with actual URL + //TO DO: Considerar pass the base URL as param or with .env, could be fun ! const encodedTextValue = `https://www.google.com/search?q=${test}`; // Open the modal const context = api.container.lookup("component:d-editor"); - context.send('openSocraticModal', textValue, encodedTextValue); + context.send("openSocraticModal", textValue, encodedTextValue); // Do something with the retrieved text value - console.log("Textarea value:", textValue); + // console.log("Textarea value:", textValue); } else { console.error("Textarea element not found."); } diff --git a/plugin.rb b/plugin.rb index 6de1060..3adb38d 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true # name: socratic-bot -# about: This socratic bot will allow you to debate +# about: This socratic bot will allow you to critically analyze your post to identify any fallacies or biases, ensuring your content is clear and impactful. # meta_topic_id: TODO # version: 0.0.1 -# authors: Discourse +# authors: Agoracity # url: TODO # required_version: 2.7.0