diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a6dbeaf --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# IntelliJ IDEA +.idea/workspace.xml +.idea/tasks.xml + +# Mac OS X +.DS_Store \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/php.xml b/.idea/libraries/php.xml new file mode 100644 index 0000000..c1fae44 --- /dev/null +++ b/.idea/libraries/php.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/php_openapi.xml b/.idea/libraries/php_openapi.xml new file mode 100644 index 0000000..b7fe902 --- /dev/null +++ b/.idea/libraries/php_openapi.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3a57092 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + Assignment issuesJavaScript + + + Bitwise operation issuesJavaScript + + + Code quality toolsJavaScript + + + JavaScript + + + + + GjsLint + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..032ca63 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/1d34-3v4l-pl4g1n.iml b/1d34-3v4l-pl4g1n.iml new file mode 100644 index 0000000..89bf22d --- /dev/null +++ b/1d34-3v4l-pl4g1n.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 0b1ed5d..05f82b2 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # 1d34-3v4l-pl4g1n -IntelliJ IDEA plugin for 3v4l.org +The plugin allows to evaluate a PHP code using [3v4l.org](https://3v4l.org/). +Read more about the website [here](https://3v4l.org/about) and support its author if you like the idea. \ No newline at end of file diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml new file mode 100644 index 0000000..64bda3c --- /dev/null +++ b/resources/META-INF/plugin.xml @@ -0,0 +1,41 @@ + + me.artspb.idea.eval.plugin + 3v4l pl4g1n + 0.1 + Artem Khvastunov + + 3v4l.org. + Read more about the website here and support its author if you like the idea.
+ Source code can be found on GitHub. + ]]> +
+ + 0.1 + + ]]> + + + + + com.intellij.modules.platform + com.jetbrains.php + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/resources/icons/3v4l.png b/resources/icons/3v4l.png new file mode 100644 index 0000000..7f0be13 Binary files /dev/null and b/resources/icons/3v4l.png differ diff --git a/src/icons/Icons.kt b/src/icons/Icons.kt new file mode 100644 index 0000000..fa3e05c --- /dev/null +++ b/src/icons/Icons.kt @@ -0,0 +1,7 @@ +package icons + +import com.intellij.openapi.util.IconLoader + +object Icons { + @JvmField val EVAL = IconLoader.getIcon("/icons/3v4l.png") +} diff --git a/src/me/artspb/idea/eval/plugin/EvalAction.kt b/src/me/artspb/idea/eval/plugin/EvalAction.kt new file mode 100644 index 0000000..63b8ebf --- /dev/null +++ b/src/me/artspb/idea/eval/plugin/EvalAction.kt @@ -0,0 +1,29 @@ +package me.artspb.idea.eval.plugin + +import com.intellij.ide.BrowserUtil +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.CommonDataKeys +import org.apache.http.client.entity.UrlEncodedFormEntity +import org.apache.http.client.methods.HttpPost +import org.apache.http.impl.client.HttpClients +import org.apache.http.message.BasicNameValuePair + +class EvalAction : AnAction() { + override fun actionPerformed(e: AnActionEvent) { + val file = e.dataContext.getData(CommonDataKeys.VIRTUAL_FILE) + if (file != null) { + val content = file.contentsToByteArray() + val post = HttpPost("https://3v4l.org/new") + post.entity = UrlEncodedFormEntity(listOf( + BasicNameValuePair("title", file.name), + BasicNameValuePair("code", String(content)) + )) + val response = HttpClients.createDefault().execute(post) + val location = response.getFirstHeader("location") + if (location != null) { + BrowserUtil.browse("https://3v4l.org${location.value}") + } + } + } +}