Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAstraea committed May 17, 2024
1 parent d799298 commit 05a8d73
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)**
32 changes: 18 additions & 14 deletions assets/javascripts/discourse/initializers/custom-modal-button.js
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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);
},
});
});

Expand All @@ -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.");

Check failure on line 64 in assets/javascripts/discourse/initializers/custom-modal-button.js

View workflow job for this annotation

GitHub Actions / ci / linting

Unexpected console statement
}
Expand Down
4 changes: 2 additions & 2 deletions plugin.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 05a8d73

Please sign in to comment.