Skip to content

Commit

Permalink
v1.4-SNAPSHOT:Add MinIO support
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzewoo committed Feb 11, 2022
1 parent f6b1375 commit 24047ab
Show file tree
Hide file tree
Showing 14 changed files with 463 additions and 34 deletions.
9 changes: 5 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ plugins {
}

group = "com.github.wenzewoo.jetbrains.plugin"
version = "1.3-SNAPSHOT"
version = "1.4-SNAPSHOT"

repositories {
mavenCentral()
}

dependencies {
implementation(kotlin("stdlib-jdk8"))
compile("net.coobird", "thumbnailator", "0.4.8")
compile("com.qiniu", "qiniu-java-sdk", "7.2.28")
compile("com.aliyun.oss", "aliyun-sdk-oss", "3.13.0")
implementation("net.coobird", "thumbnailator", "0.4.8")
implementation("com.qiniu", "qiniu-java-sdk", "7.2.28")
implementation("com.aliyun.oss", "aliyun-sdk-oss", "3.13.0")
implementation("io.minio", "minio", "5.0.6")
}

// See https://github.com/JetBrains/gradle-intellij-plugin/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,173 @@
</grid>
</children>
</grid>
<grid id="c9473" layout-manager="GridLayoutManager" row-count="10" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="MinIO"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<hspacer id="18485">
<constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="-1" height="15"/>
</grid>
</constraints>
</hspacer>
<component id="6dd6d" class="javax.swing.JCheckBox" binding="checkMinioEnable">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<enabled value="true"/>
<selected value="false"/>
<text value="Enable?"/>
</properties>
</component>
<component id="682a" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Bucket"/>
</properties>
</component>
<component id="424bc" class="javax.swing.JTextField" binding="textMinioBucket">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="ae62c" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Endpoint"/>
</properties>
</component>
<component id="4d979" class="javax.swing.JTextField" binding="textMinioEndpoint">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value="http://121.43.32.181:9001"/>
</properties>
</component>
<component id="85973" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Access Key"/>
</properties>
</component>
<component id="5417a" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Secret Key"/>
</properties>
</component>
<component id="59cb" class="javax.swing.JTextField" binding="textMinioAccessKey">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value=""/>
</properties>
</component>
<component id="84c5e" class="javax.swing.JTextField" binding="textMinioSecretKey">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="4ddda" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="New fileame"/>
</properties>
</component>
<component id="8c974" class="javax.swing.JComboBox" binding="comboMinioNewFilenameTemplate">
<constraints>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<model>
<item value="images/${yyyyMMdd}/${UUID}.${Suffix}"/>
<item value="images/${MDFile}/${Timestamp}.${Suffix}"/>
<item value="${MDFile}-${Timestamp}.${Suffix}"/>
<item value="${yyyyMMdd}-${UUID}.${Suffix}"/>
<item value="${UUID}.${Suffix}"/>
<item value="${Timestamp}.${Suffix}"/>
<item value="Custom.."/>
</model>
</properties>
</component>
<component id="1506" class="javax.swing.JTextField" binding="textMinioNewFilenameCustomText">
<constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="b34c5" class="javax.swing.JLabel">
<constraints>
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&lt;html&gt;&#10;&lt;b&gt;Variable&lt;/b&gt;&lt;br/&gt; &#10;- &lt;code&gt;${MDFile}&lt;/code&gt;: Current markdown file name, such as &quot;example&quot; &lt;br/&gt;&#10;- &lt;code&gt;${Suffix}&lt;/code&gt;: Current image file suffix, such as &quot;png&quot; &lt;br/&gt;&#10;- &lt;code&gt;${yyyyMMdd}&lt;/code&gt;: Current date, such as &quot;20200401&quot; &lt;br/&gt;&#10;- &lt;code&gt;${Timestamp}&lt;/code&gt;: Current time stamp, such as &quot;1585819668627&quot; &lt;br/&gt;&#10;- &lt;code&gt;${UUID}&lt;/code&gt;: Random 32-bit string, such as &quot;67b52ab3e50643e08b8cb980c2ecdaed&quot; &lt;br/&gt;&#10;&lt;/html&gt;" noi18n="true"/>
</properties>
</component>
<grid id="cfbae" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="94e2c" class="javax.swing.JButton" binding="buttonTestMinio">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Test"/>
</properties>
</component>
<hspacer id="35c20">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<grid id="e2684" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
</children>
</grid>
</children>
</tabbedpane>
</children>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import javax.swing.*;

@SuppressWarnings("rawtypes")
public class MISConfigurationInterfaceForm {
protected JPanel rootPanel;
protected JTabbedPane tabPanel;
Expand Down Expand Up @@ -69,4 +70,15 @@ public class MISConfigurationInterfaceForm {
protected JTextField textAliyunNewFilenameCustomText;
protected JTextField textAliyunStyleSuffix;
protected JButton buttonTestAliyun;


// minio config
protected JCheckBox checkMinioEnable;
protected JTextField textMinioBucket;
protected JTextField textMinioEndpoint;
protected JTextField textMinioSecretKey;
protected JTextField textMinioAccessKey;
protected JComboBox comboMinioNewFilenameTemplate;
protected JTextField textMinioNewFilenameCustomText;
protected JButton buttonTestMinio;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import javax.swing.*;

@SuppressWarnings("rawtypes")
public class MISPreUploadImageConfirmForm extends JDialog {
private static final long serialVersionUID = -7499466859041980308L;
protected JPanel dialogPanel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ class DeleteImageSwingWorker(
// aliyun oss
else if (state.aliyunEnabled && markdownUrl.contains(state.aliyunEndpoint)) {
MISFileStoreFactory.of(Consts.FileStoreAliyunOSS).delete(null, markdownUrl)
}
// minio
else if (state.minioEnabled && markdownUrl.contains(state.minioEndpoint)) {
MISFileStoreFactory.of(Consts.FileStoreMinIO).delete(null, markdownUrl)
} else {
false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,14 @@ class MISPreUploadImageConfirmDialog(
// init comboUploadTo
this.comboUploadTo.removeAllItems()
MISConfigService.getInstance().state?.let {
if (it.localFileEnabled) {
if (it.localFileEnabled)
this.comboUploadTo.addItem(Consts.FileStoreLocal)
}
if (it.qiniuEnabled) {
if (it.qiniuEnabled)
this.comboUploadTo.addItem(Consts.FileStoreQiniu)
}
if (it.aliyunEnabled) {
if (it.aliyunEnabled)
this.comboUploadTo.addItem(Consts.FileStoreAliyunOSS)
}
if (it.minioEnabled)
this.comboUploadTo.addItem(Consts.FileStoreMinIO)
this.comboUploadTo.selectedItem = it.currentUploadTo
}

Expand Down Expand Up @@ -143,6 +142,14 @@ class MISPreUploadImageConfirmDialog(
this.replaceVariable(it.aliyunNewFilenameCustomText)
}
}
// init aliyun oss
Consts.FileStoreMinIO -> {
this.textSaveAs.text = if (it.minioNewFilenameTemplate != Consts.CustomFlag) {
this.replaceVariable(it.minioNewFilenameTemplate)
} else {
this.replaceVariable(it.minioNewFilenameCustomText)
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import com.github.wenzewoo.jetbrains.plugin.mis.toolkit.Consts
class MISConfig {

// local
var localFileEnabled: Boolean = false
var localFileEnabled: Boolean = true
var localFileSavePathTemplate: String = ""
var localFileSavePathCustomText: String = ""
var localFileNewFilenameTemplate: String = ""
Expand All @@ -42,9 +42,9 @@ class MISConfig {
var qiniuBucket: String = ""
var qiniuAccessKey: String = ""
var qiniuSecretKey: String = ""
var qiniuDomain: String = ""
var qiniuDomain: String = "http://qz7fmp0tv.hn-bkt.clouddn.com"
var qiniuBucketZone: Int = 0
var qiniuStyleSuffix: String? = ""
var qiniuStyleSuffix: String? = "?imageView2/0/interlace/1/q/50|imageslim"
var qiniuNewFilenameTemplate: String = ""
var qiniuNewFilenameCustomText: String = ""

Expand All @@ -54,11 +54,20 @@ class MISConfig {
var aliyunBucket: String = ""
var aliyunAccessKey: String = ""
var aliyunSecretKey: String = ""
var aliyunEndpoint: String = ""
var aliyunStyleSuffix: String? = ""
var aliyunEndpoint: String = "oss-cn-chengdu.aliyuncs.com"
var aliyunStyleSuffix: String? = "?x-oss-process=image/auto-orient,1/interlace,1/quality,q_50/format,jpg"
var aliyunNewFilenameTemplate: String = ""
var aliyunNewFilenameCustomText: String = ""

// minio
var minioEnabled: Boolean = false
var minioBucket: String = ""
var minioAccessKey: String = ""
var minioSecretKey: String = ""
var minioEndpoint: String = "https://play.min.io:9000"
var minioNewFilenameTemplate: String = ""
var minioNewFilenameCustomText: String = ""


var currentUploadTo = Consts.FileStoreLocal

Expand Down Expand Up @@ -132,6 +141,32 @@ class MISConfig {
}
}
}

// valid minio
if (this.minioEnabled) {
if (this.minioBucket.isEmpty()) {
this.minioEnabled = false
return "Please set minio bucket"
}
if (this.minioAccessKey.isEmpty()) {
this.minioEnabled = false
return "Please set minio accessKey"
}
if (this.minioSecretKey.isEmpty()) {
this.minioEnabled = false
return "Please set minio secretKey"
}
if (this.minioEndpoint.isEmpty()) {
this.minioEnabled = false
return "Please set minio endpoint"
}
if (this.minioNewFilenameTemplate == Consts.CustomFlag) {
if (this.minioNewFilenameCustomText.isEmpty()) {
this.minioEnabled = false
return "Please set minio new filename"
}
}
}
return null
}
}
Loading

0 comments on commit 24047ab

Please sign in to comment.