Skip to content

Commit

Permalink
implemented a simple action to submit an execution request
Browse files Browse the repository at this point in the history
  • Loading branch information
artspb committed Sep 2, 2016
1 parent 16ac0cc commit d796501
Show file tree
Hide file tree
Showing 14 changed files with 197 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .gitignore
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
3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/libraries/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/libraries/php_openapi.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions 1d34-3v4l-pl4g1n.iml
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>
3 changes: 2 additions & 1 deletion README.md
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.
41 changes: 41 additions & 0 deletions resources/META-INF/plugin.xml
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>
Binary file added resources/icons/3v4l.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/icons/Icons.kt
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")
}
29 changes: 29 additions & 0 deletions src/me/artspb/idea/eval/plugin/EvalAction.kt
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}")
}
}
}
}

0 comments on commit d796501

Please sign in to comment.