-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# IntelliJ IDEA | ||
.idea/workspace.xml | ||
.idea/tasks.xml | ||
|
||
# Mac OS X | ||
.DS_Store |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="PLUGIN_MODULE" version="4"> | ||
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/resources/META-INF/plugin.xml" /> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" scope="PROVIDED" name="php" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="php-openapi" level="project" /> | ||
</component> | ||
</module> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<idea-plugin version="2"> | ||
<id>me.artspb.idea.eval.plugin</id> | ||
<name>3v4l pl4g1n</name> | ||
<version>0.1</version> | ||
<vendor email="[email protected]" url="https://artspb.me">Artem Khvastunov</vendor> | ||
|
||
<description><![CDATA[ | ||
The plugin allows to evaluate a PHP code using <a href="https://3v4l.org/">3v4l.org</a>. | ||
Read more about the website <a href="https://3v4l.org/about">here</a> and support its author if you like the idea.<br/> | ||
Source code can be found on <a href="https://github.com/artspb/1d34-3v4l-pl4g1n">GitHub</a>. | ||
]]> | ||
</description> | ||
|
||
<change-notes><![CDATA[ | ||
<h3>0.1</h3> | ||
<ul> | ||
<li>Implemented a simple action to submit an execution request. | ||
Default web browser will be opened automatically.</li> | ||
</ul> | ||
]]> | ||
</change-notes> | ||
|
||
<idea-version since-build="145.0"/> | ||
|
||
<depends>com.intellij.modules.platform</depends> | ||
<depends>com.jetbrains.php</depends> | ||
|
||
<extensions defaultExtensionNs="com.intellij"> | ||
<!-- Add your extensions here --> | ||
</extensions> | ||
|
||
<actions> | ||
<action id="EvalAction" class="me.artspb.idea.eval.plugin.EvalAction" text="3v4l();" description="3v4l();" icon="Icons.EVAL"> | ||
<keyboard-shortcut keymap="$default" first-keystroke="shift meta alt E"/> | ||
<add-to-group group-id="EditorPopupMenu"/> | ||
<add-to-group group-id="ProjectViewPopupMenu"/> | ||
<add-to-group group-id="EditorTabPopupMenu"/> | ||
</action> | ||
</actions> | ||
|
||
</idea-plugin> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package icons | ||
|
||
import com.intellij.openapi.util.IconLoader | ||
|
||
object Icons { | ||
@JvmField val EVAL = IconLoader.getIcon("/icons/3v4l.png") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}") | ||
} | ||
} | ||
} | ||
} |