Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
674b7b9
MAS
gee1k Jan 15, 2021
725f135
删除打赏、重启 Finder
gee1k Jan 16, 2021
15e9ece
修改一些信息
L1cardo Jan 16, 2021
96e67cc
Merge branch 'feature/mas' into feature/mas
L1cardo Jan 16, 2021
71be7e4
Merge pull request #169 from L1cardo/feature/mas
gee1k Jan 16, 2021
f8229e8
增加 自定义输出格式配置
L1cardo Jan 17, 2021
e9f6e80
输出格式支持自定义、上传记录图床、大小、时间
gee1k Jan 18, 2021
601e275
修正 Share 分享路径
gee1k Jan 18, 2021
cef4c05
添加磁盘访问授权
L1cardo Jan 18, 2021
ba9dba0
授权磁盘访问
gee1k Jan 19, 2021
a443774
添加欢迎界面,优化数据库页面
L1cardo Jan 20, 2021
3ff0689
接入欢迎页、改造磁盘授权逻辑
gee1k Jan 20, 2021
9ba3447
releasing v1.1.0
gee1k Jan 20, 2021
d55d5d0
添加重启 finder 的帮助
L1cardo Jan 20, 2021
cc8c139
Releasing v1.1.0 build 7
gee1k Jan 20, 2021
9b26605
增加截图权限获取教程、首次请求磁盘权限改为用户主目录
gee1k Jan 21, 2021
62111f7
修复问题
gee1k Jan 23, 2021
765fe5e
数据库界面增加新功能
L1cardo Jan 24, 2021
a48dd1f
录屏权限页面添加约束
L1cardo Jan 24, 2021
467d42a
修复 Bugs 和更新阿里云区域数据
gee1k Jan 25, 2021
be36231
更新命令行参数
gee1k Feb 18, 2021
9cbefbe
移除 Finder Toolbar
gee1k Apr 25, 2021
2f0b4b0
添加 apple script支持
L1cardo Jun 6, 2021
9fe4ab0
升级LoginServiceKit 到版本2.2.1,修复问题#180
L1cardo Jun 6, 2021
ba8d8ac
v1.2.0
gee1k Jun 7, 2021
4d548d2
Add ImageCodec #194
bqlin Jun 15, 2021
832dfe5
Remove ImageCodec meta files
bqlin Jun 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
更新命令行参数
  • Loading branch information
gee1k committed Feb 18, 2021
commit be362310e9ec849cb4d1425f8b2419aee1830f16
30 changes: 30 additions & 0 deletions uPic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
16068C7822AECB34004D39B7 /* PreferencesWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16068C7722AECB34004D39B7 /* PreferencesWindowController.swift */; };
16068C7C22AECD9F004D39B7 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16068C7B22AECD9F004D39B7 /* Constants.swift */; };
160CAA2522B1ED6F00D04FBD /* PreferenceKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 160CAA2422B1ED6F00D04FBD /* PreferenceKey.swift */; };
1613D88725C9826B009E348A /* AutoGenStrings.py in Resources */ = {isa = PBXBuildFile; fileRef = 1613D88625C9826B009E348A /* AutoGenStrings.py */; };
161539122408EC7B00CC662F /* LskyProUploader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 161539102408E7F200CC662F /* LskyProUploader.swift */; };
161539132408EC7D00CC662F /* LskyProHostConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 161539112408E7F200CC662F /* LskyProHostConfig.swift */; };
161539152408F0E200CC662F /* LskyProConfigView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 161539142408F0E200CC662F /* LskyProConfigView.swift */; };
Expand Down Expand Up @@ -215,6 +216,7 @@
16068C7722AECB34004D39B7 /* PreferencesWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesWindowController.swift; sourceTree = "<group>"; };
16068C7B22AECD9F004D39B7 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
160CAA2422B1ED6F00D04FBD /* PreferenceKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferenceKey.swift; sourceTree = "<group>"; };
1613D88625C9826B009E348A /* AutoGenStrings.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = AutoGenStrings.py; sourceTree = "<group>"; };
161539102408E7F200CC662F /* LskyProUploader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LskyProUploader.swift; sourceTree = "<group>"; };
161539112408E7F200CC662F /* LskyProHostConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LskyProHostConfig.swift; sourceTree = "<group>"; };
161539142408F0E200CC662F /* LskyProConfigView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LskyProConfigView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -429,6 +431,14 @@
path = PreferencesWindow;
sourceTree = "<group>";
};
1613D88525C98256009E348A /* Script */ = {
isa = PBXGroup;
children = (
1613D88625C9826B009E348A /* AutoGenStrings.py */,
);
path = Script;
sourceTree = "<group>";
};
1615390E2408E7DE00CC662F /* LskyPro */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -671,6 +681,7 @@
16A6DC5622AA375700813706 /* uPic */ = {
isa = PBXGroup;
children = (
1613D88525C98256009E348A /* Script */,
1648A214238E742600B99B9D /* Main.storyboard */,
16BDDE0222EAA2920080E467 /* Assets.xcassets */,
16A6DC5722AA375700813706 /* AppDelegate.swift */,
Expand Down Expand Up @@ -878,6 +889,7 @@
8B11FF3895E709812B771F7E /* [CP] Embed Pods Frameworks */,
16EA205922AF8C680006FB9C /* CopyFiles */,
16F7467D22E994A300480A62 /* Embed App Extensions */,
1613D88B25C98273009E348A /* ShellScript */,
);
buildRules = (
);
Expand Down Expand Up @@ -1001,6 +1013,7 @@
1648A216238E742600B99B9D /* Main.storyboard in Resources */,
96F633FF25AF008F005514EB /* Database.storyboard in Resources */,
165C86D325B91F8000C538AD /* ScreenshotAuthorizationHelp.storyboard in Resources */,
1613D88725C9826B009E348A /* AutoGenStrings.py in Resources */,
169F073B22AF53DE008E8525 /* Preferences.storyboard in Resources */,
16BDDE0322EAA2920080E467 /* Assets.xcassets in Resources */,
);
Expand Down Expand Up @@ -1031,6 +1044,23 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
1613D88B25C98273009E348A /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "#!/bin/bash\npython ${SRCROOT}/${TARGET_NAME}/Script/AutoGenStrings.py ${SRCROOT}/${TARGET_NAME}\n";
};
8B11FF3895E709812B771F7E /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
2 changes: 1 addition & 1 deletion uPic.xcodeproj/xcshareddata/xcschemes/uPic.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1230"
LastUpgradeVersion = "1240"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
34 changes: 33 additions & 1 deletion uPic/Cli/Cli.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,39 @@ extension Cli {
/// Upload progress
/// - Parameter url: current url
func uploadProgress(_ url: String) {
resultUrls.append(OutputFormatModel.formatUrl(url, outputFormat: nil))
var outputUrl = ""
if let output = output?.value?.lowercased() {
var formatUrl = url
if Defaults[.outputFormatEncoded] {
formatUrl = url.urlEncoded()
}
var filename = url.lastPathComponent.deletingPathExtension.trim()
let tempArr = filename.components(separatedBy: .whitespaces).map{ $0.trim() }.filter{ !$0.isEmpty }
filename = tempArr.joined(separator: "")
switch output {
case "url":
outputUrl = formatUrl
break
case "html":
outputUrl = "<img src='\(formatUrl)' alt='\(filename)'/>"
break
case "md":
outputUrl = "![\(filename)](\(formatUrl))"
break
case "markdown":
outputUrl = "![\(filename)](\(formatUrl))"
break
case "ubb":
outputUrl = "[img]\(formatUrl)[/img]"
break
default:
outputUrl = OutputFormatModel.formatUrl(url, outputFormat: nil)
}
} else {
outputUrl = OutputFormatModel.formatUrl(url, outputFormat: nil)
}

resultUrls.append(outputUrl)
progress += 1
Console.write("Uploading \(progress)/\(allDataList.count)")
}
Expand Down
242 changes: 242 additions & 0 deletions uPic/Script/AutoGenStrings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
#!/usr/bin/env python
# encoding: utf-8

"""
AutoGenStrings.py
Created by linyu on 2015-02-13.
Modify by wz on 2017-06-02.
Copyright (c) 2017 __MyCompanyName__. All rights reserved.

"""

import imp
import sys
import os
import glob
import string
import re
import time

imp.reload(sys)
sys.setdefaultencoding('utf-8') #设置默认编码,只能是utf-8,下面\u4e00-\u9fa5要求的

KTargetFile = '*.lproj/*.strings'

KGenerateStringsFile = 'TempfileOfStoryboardNew.strings'

ColonRegex = ur'["](.*?)["]'

KeyParamRegex = ur'["](.*?)["](\s*)=(\s*)["](.*?)["];'

AnotationRegexPrefix = ur'/(.*?)/'

def getCharaset(string_txt):
filedata = bytearray(string_txt[:4])
if len(filedata) < 4 :
return 0
if (filedata[0] == 0xEF) and (filedata[1] == 0xBB) and (filedata[2] == 0xBF):
print 'utf-8'
return 1
elif (filedata[0] == 0xFF) and (filedata[1] == 0xFE) and (filedata[2] == 0x00) and (filedata[3] == 0x00):
print 'utf-32/UCS-4,little endian'
return 3
elif (filedata[0] == 0x00) and (filedata[1] == 0x00) and (filedata[2] == 0xFE) and (filedata[3] == 0xFF):
print 'utf-32/UCS-4,big endian'
return 3
elif (filedata[0] == 0xFE) and (filedata[1] == 0xFF):
print 'utf-16/UCS-2,little endian'
return 2
elif (filedata[0] == 0xFF) and (filedata[1] == 0xFE):
print 'utf-16/UCS-2,big endian'
return 2
else:
print 'can not recognize!'
return 0

def decoder(string_txt):
var = getCharaset(string_txt)
if var == 1:
return string_txt.decode("utf-8")
elif var == 2:
return string_txt.decode("utf-16")
elif var == 3:
return string_txt.decode("utf-32")
else:
return string_txt

def constructAnotationRegex(str):
return AnotationRegexPrefix + '\n' + str

def getAnotationOfString(string_txt,suffix):
anotationRegex = constructAnotationRegex(suffix)
anotationMatch = re.search(anotationRegex,string_txt)
anotationString = ''
if anotationMatch:
match = re.search(AnotationRegexPrefix,anotationMatch.group(0))
if match:
anotationString = match.group(0)
return anotationString

def compareWithFilePath(newStringPath,originalStringPath):
print(newStringPath)
print(originalStringPath)
#read newStringfile
nspf=open(newStringPath,"r")
#newString_txt = str(nspf.read(5000000)).decode("utf-16")
newString_txt = decoder(str(nspf.read(5000000)))
nspf.close()
newString_dic = {}
anotation_dic = {}
for stfmatch in re.finditer(KeyParamRegex , newString_txt):
linestr = stfmatch.group(0)
anotationString = getAnotationOfString(newString_txt,linestr)
linematchs = re.findall(ColonRegex, linestr)
if len(linematchs) == 2:
leftvalue = linematchs[0]
rightvalue = linematchs[1]
newString_dic[leftvalue] = rightvalue
anotation_dic[leftvalue] = anotationString
#read originalStringfile
ospf=open(originalStringPath,"r")
originalString_txt = decoder(str(ospf.read(5000000)))
ospf.close()
originalString_dic = {}
for stfmatch in re.finditer(KeyParamRegex , originalString_txt):
linestr = stfmatch.group(0)
linematchs = re.findall(ColonRegex, linestr)
if len(linematchs) == 2:
leftvalue = linematchs[0]
rightvalue = linematchs[1]
originalString_dic[leftvalue] = rightvalue
#compare and remove the useless param in original string
for key in originalString_dic:
if(key not in newString_dic):
keystr = '"%s"'%key
replacestr = '//'+keystr
match = re.search(replacestr , originalString_txt)
if match is None:
originalString_txt = originalString_txt.replace(keystr,replacestr)
#compare and add new param to original string
executeOnce = 1
for key in newString_dic:
values = (key, newString_dic[key])
if(key not in originalString_dic):
newline = ''
if executeOnce == 1:
timestamp = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
newline = '\n//##################################################################################\n'
newline +='//# AutoGenStrings '+timestamp+'\n'
newline +='//##################################################################################\n'
executeOnce = 0
newline += '\n'+anotation_dic[key]
newline += '\n"%s" = "%s";\n'%values
originalString_txt += newline
#write into origial file
sbfw=open(originalStringPath,"w")
sbfw.write(originalString_txt)
sbfw.close()

def extractFileName(file_path):
seg = file_path.split('/')
lastindex = len(seg) - 1
return seg[lastindex]

def extractFilePrefix(file_path):
seg = file_path.split('/')
lastindex = len(seg) - 1
prefix = seg[lastindex].split('.')[0]
return prefix

def generateStoryboardStringsfile(storyboard_path,tempstrings_path):
cmdstring = 'ibtool '+storyboard_path+' --generate-strings-file '+tempstrings_path
if os.system(cmdstring) == 0:
return 1

def generateLocalizableFiles(filePath ,sourceFilePath):
print ('-------> sourceFilePath: ' + sourceFilePath + ' filePath: ' + filePath)
sourceFile_list = glob.glob(sourceFilePath)
if len(sourceFile_list) == 0:
print 'error dictionary,you should choose the dic upper the Base.lproj'
return
targetFilePath = filePath + '/' + KTargetFile
targetFile_list = glob.glob(targetFilePath)
tempFile_Path = filePath + '/' + KGenerateStringsFile
if len(targetFile_list) == 0:
print 'error framework , no .lproj dic was found'
return
for sourcePath in sourceFile_list:
sourceprefix = extractFilePrefix(sourcePath)
sourcename = extractFileName(sourcePath)
print 'init with %s'%sourcename
if generateStoryboardStringsfile(sourcePath,tempFile_Path) == 1:
print '- - genstrings %s successfully'%sourcename
for targetPath in targetFile_list:
targetprefix = extractFilePrefix(targetPath)
targetname = extractFileName(targetPath)
if cmp(sourceprefix,targetprefix) == 0:
print '- - dealing with %s'%targetPath
compareWithFilePath(tempFile_Path,targetPath)
print 'finish with %s'%sourcename
os.remove(tempFile_Path)
else:
print '- - genstrings %s error'%sourcename



#根据项目根目录遍历所有的xib和storyboard的文件路径
def getAllNibSrcPathFor(dir):
sourceFilePaths = []
#三个参数:1.父目录 2.所有文件夹名字(不含路径) 3.所有文件名字
for parent,dirnames,filenames in os.walk(dir):
for filename in filenames: #输出文件信息
print filename
if (('.xib' in filename) | ('.storyboard' in filename)):
filePath = os.path.join(parent)
if filePath not in sourceFilePaths:
sourceFilePaths.append(filePath)
#print sourceFilePaths
return sourceFilePaths


def main():
print(sys.argv)
if len(sys.argv) == 1 :
#如果在终端运行,注意要修改自己需要国际化的项目文件夹的路径!
filePath = '/Users/wz/Documents/git/AutoLocalization/AutoLocalization/'
else:
filePath = sys.argv[1]
# if filePath == None or filePath == '':
# print('[Error] filePath can not None!')
# exit(1)
sourceFilePaths = getAllNibSrcPathFor(filePath)

# *.storyboard 国际化
for sourceFilePath in sourceFilePaths:
baseStrIdx = 0
try:
baseStrIdx = sourceFilePath.index('Base.lproj')
except Exception as e:
pass
else:
sourceFilePathName = sourceFilePath + '/*.storyboard'
upperFilePath = sourceFilePath[0:(baseStrIdx-1)]
#print upperFilePath
generateLocalizableFiles(upperFilePath, sourceFilePathName)
# *.xib 国际化
for sourceFilePath in sourceFilePaths:
baseStrIdx = 0
try:
baseStrIdx = sourceFilePath.index('Base.lproj')
except Exception as e:
pass
else:
sourceFilePathName = sourceFilePath + '/*.xib'
upperFilePath = sourceFilePath[0:(baseStrIdx-1)]
#print upperFilePath
generateLocalizableFiles(upperFilePath, sourceFilePathName)




if __name__ == '__main__':
main()
7 changes: 7 additions & 0 deletions uPic/StatusMenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ class StatusMenuController: NSObject, NSMenuDelegate {
menuItem.target = self
compressFactorMenuItem.submenu?.addItem(menuItem)
}

// TinyPNG
let menuItem = NSMenuItem(title: "TinyPNG", action: #selector(changeCompressFactor(_:)), keyEquivalent: "")
menuItem.tag = -1
menuItem.isEnabled = true
menuItem.target = self
compressFactorMenuItem.submenu?.addItem(menuItem)

compressFactorMenuItem.submenu?.delegate = self
self.refreshCompressFactor()
Expand Down
Loading