Skip to content

Commit

Permalink
change scripts position
Browse files Browse the repository at this point in the history
  • Loading branch information
PangBaiWork committed Apr 27, 2024
1 parent a289c33 commit d478e87
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 84 deletions.
2 changes: 1 addition & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ git clone https://x-access-token:你的令牌@github.com/your-username/your-repo
```shell
git config --global user.name "yourname"
git config --global user.email "youremail"
ssh-keygen -t rsa -C 你的邮箱
ssh-keygen -t rsa -C "youremail"
```
连续回车两次
终端输出完信息后,再执行
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Open the terminal at the bottom of WeBlog and type this.
```shell
git config --global user.name "yourname"
git config --global user.email "youremail"
ssh-keygen -t rsa -C your email.
ssh-keygen -t rsa -C "youremail"
```
Enter twice .
After the terminal has finished outputting the message, run
Expand Down
20 changes: 0 additions & 20 deletions app/release/output-metadata.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public void onClick(View v) {
AlertDialog dialog = DialogUtils.showLoadingDialog(this);
ThreadUtil.thread(() -> {
boolean init = projectManager.createProject();
if (init) projectManager.createScript(HomeActivity.this);
runOnUiThread(() -> {
dialog.dismiss();
if (init) {
Expand Down Expand Up @@ -117,7 +116,6 @@ public void onClick(View v) {
return;
}
selectProject = new Project(file.getName(), file.getAbsolutePath(), type);
new ProjectManager(selectProject).createScript(HomeActivity.this);
}
dialog.dismiss();
runOnUiThread(() -> {
Expand All @@ -142,7 +140,6 @@ public void onClick(View v) {
return;
}
selectProject = new Project(file.getName(), file.getAbsolutePath(), type);
new ProjectManager(selectProject).createScript(HomeActivity.this);
openProject(selectProject);
});
} else if (id == R.id.open_terminal) {
Expand Down
11 changes: 4 additions & 7 deletions app/src/main/java/com/pangbai/weblog/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.navigation.NavigationView;
import com.google.android.material.search.SearchView;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;

Expand Down Expand Up @@ -64,9 +63,7 @@

import br.tiagohm.markdownview.MarkdownView;
import br.tiagohm.markdownview.css.styles.Github;
import io.github.rosemoe.sora.event.EventReceiver;
import io.github.rosemoe.sora.event.PublishSearchResultEvent;
import io.github.rosemoe.sora.event.Unsubscribe;
import io.github.rosemoe.sora.text.Content;
import io.github.rosemoe.sora.text.ContentIO;
import io.github.rosemoe.sora.widget.EditorSearcher;
Expand All @@ -90,7 +87,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PrefManager.init(getApplicationContext());
project = ProjectManager.getCurrentProject();
if (PrefManager.isFirstLaunch() || project == null || !new File(project.getProjectPath()).exists()) {
if (PrefManager.isFirstOrReinstall(this) || project == null || !new File(project.getProjectPath()).exists()) {
util.startActivity(this, HomeActivity.class, false);
finish();
return;
Expand Down Expand Up @@ -202,14 +199,14 @@ void setLayout() {

int id = item.getItemId();
if (id == R.id.menu_run) {
File file = new File(project.scriptPath);
File file = new File(project.getScriptPath());
if (!file.exists()) return false;
DialogUtils.showMultiSelectDialog(this, getString(R.string.select_scripts), file.list(), selets -> {
binding.progressbar.setIndeterminate(true);
Snackbar.make(binding.getRoot(), "Excuting", Snackbar.LENGTH_SHORT).show();

ThreadUtil.thread(() -> {
boolean cmd = cmdExer.executeScripts(selets, project.scriptPath, true) == 0;
boolean cmd = cmdExer.executeScripts(selets, project.getScriptPath(), true) == 0;
runOnUiThread(() -> {
binding.progressbar.setIndeterminate(false);
if (cmd) {
Expand Down Expand Up @@ -415,7 +412,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {


} else if (id == R.id.project_script) {
new FileListSelect(this, getString(R.string.scripts_list), false, project.scriptPath, file -> {
new FileListSelect(this, getString(R.string.scripts_list), false, project.getScriptPath(), file -> {
setCodeText(file);
binding.drawerLayout.closeDrawer(GravityCompat.START);
}).showChooseDialog();
Expand Down
14 changes: 10 additions & 4 deletions app/src/main/java/com/pangbai/weblog/preference/PrefManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ public enum Keys {
category,
current_project,
current_file,
first_launch,
first_launch_mark,
bl_interface_undo_button_display,
bl_artical_title_to_md5
}

static SharedPreferences pref;
//1 for first installation , 2 for reinstalltation
public static int isFirstOrReinstall_flag=0;



Expand All @@ -30,9 +32,13 @@ public static void init(Context context) {

}

public static boolean isFirstLaunch() {
if (getBoolen(Keys.first_launch,true)) {
putBoolen(Keys.first_launch,false);
public static boolean isFirstOrReinstall(Context context) {
String mark= context.getApplicationInfo().nativeLibraryDir;
String defaults="defaults";
String marked=getString(Keys.first_launch_mark,defaults);
if (!mark.equals(marked)) {
putString(Keys.first_launch_mark,mark);
isFirstOrReinstall_flag=marked.equals(defaults)?1:2;
return true;
}
return false;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/pangbai/weblog/project/PostCreate.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public void setParams(String title, String path, String category, String descrip
File file = new File(path);
if (file.exists()) return ;
File dir = file.getParentFile();
if (!dir.exists()) dir.mkdirs();
if (!dir.exists()) dir.mkdirs();
try {
file.createNewFile();
writer = new PrintWriter(new FileWriter(file), true);
} catch (Exception e) {
} catch (Exception ignored) {
}
}

Expand Down
8 changes: 6 additions & 2 deletions app/src/main/java/com/pangbai/weblog/project/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import com.pangbai.weblog.execute.HexoExer;
import com.pangbai.weblog.execute.HugoExer;
import com.pangbai.weblog.project.ProjectManager;
import com.pangbai.weblog.tool.Init;

public class Project {
String projectPath;
String blogName;
public ProjectManager.Type blogType;
public String scriptPath;
//public String scriptPath;
public BlogCmd blogCmd;

public Project( String name,String path, ProjectManager.Type type) {
Expand All @@ -21,7 +22,7 @@ public Project( String name,String path, ProjectManager.Type type) {
} else if (type== ProjectManager.Type.hugo) {
blogCmd=new HugoExer(projectPath);
}
scriptPath=projectPath+"/.scripts";
// scriptPath=projectPath+"/.scripts";
}

public String getProjectPath() {
Expand All @@ -39,4 +40,7 @@ public String getBlogName() {
public void setBlogName(String blogName) {
this.blogName = blogName;
}
public String getScriptPath(){
return Init.scriptsPath+blogType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ public ProjectManager(Project project) {
}



public boolean createProject() {
boolean init = project.blogCmd.initBlog(project.projectPath);
if (!init) return false;
project.blogCmd.changeConfig("title", project.blogName);
return true;
}

public boolean createScript(Context context) {
/* public boolean createScript(Context context) {
if (new File(project.scriptPath).exists()) return true;
IO.copyAssetsDirToSDCard(context, "scripts/" + project.blogType.name(), project.scriptPath);
return true;
}
}*/

public static void saveCurrentProject(Project project) {
String[] infor = new String[]{project.blogName, project.getProjectPath(), project.blogType.name()};
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/pangbai/weblog/tool/IO.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static void copyAssetsDirToSDCard(Context context, String assetsDirName,
fos.write(mByte, 0, bt);
// dealtByte+=bt;
}
fos.getFD().sync();
fos.flush();
inputStream.close();
fos.close();
Expand Down
Loading

0 comments on commit d478e87

Please sign in to comment.