Skip to content

Commit

Permalink
Release prep (#3)
Browse files Browse the repository at this point in the history
* Prepare for release

Clean up data folder

* Add README

* Fix README extension

* Fix stat window issue.
  • Loading branch information
creativeArtie authored Oct 29, 2017
1 parent 99e2b38 commit 8c4ad90
Show file tree
Hide file tree
Showing 20 changed files with 123 additions and 124 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# JWriter
This is a writing software foucsed on writing for both fiction and non-fiction. It is simpiler to project like [FoucsWriter](https://gottcode.org/focuswriter/). This project is currently in alpha version, and will be optimized and will have more features.
Screen shots:
![Main Window](design/main.png)
![Stats Window](design/stats.png)
11 changes: 8 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<property name="dir.debug-data" location="${dir.debug}/data" />
<!-- Jar and assoicated files -->
<property name="dir.jar" location="${dir.out}/jar" />
<property name="dir.jar-tmp" location="${dir.out}/tmp" />
<property name="dir.jar-tmp" location="${dir.out}/jar-bin" />
<property name="dir.jar-res" location="${dir.jar-tmp}/data" />
<property name="dir.jar-data" location="${dir.jar}/data" />
<property name="dir.jar-lib" location="${dir.jar}/lib" />
Expand All @@ -60,6 +60,7 @@
<property name="dir.data-run" location="${dir.data}/run" />
<property name="dir.data-jar" location="${dir.data}/jar" />
<property name="dir.data-test" location="${dir.data}/tests" />
<property name="dir.jar-root" location="${dir.data}/jar-root" />

<!-- .......................... Libraries ........................... -->
<property name="dir.lib" location="${loc.lib}" />
Expand Down Expand Up @@ -136,10 +137,13 @@

<!-- ......................... Jar Targets .......................... -->
<target name="compile.jar" depends="compile.run">
<!-- copy data -->
<!-- copy files -->
<copy toDir="${dir.jar-data}" overwrite="true">
<fileset dir="${dir.data-run}" />
</copy>
<copy toDir="${dir.jar}" overwrite="true">
<fileset dir="${dir.jar-root}" />
</copy>
<!-- copy 3rd party libraries -->
<copy toDir="${dir.jar-lib}" overwrite="true">
<fileset dir="${dir.3rd}" />
Expand All @@ -150,6 +154,7 @@
<exclude name="${loc.data}" />
</fileset>
</copy>
<!-- copy files into future jar file-->
<copy toDir="${dir.jar-res}" overwrite="true">
<fileset dir="${dir.data-jar}" />
</copy>
Expand All @@ -169,7 +174,7 @@
</manifest>
</jar>
<!-- set execute flag -->
<chmod file="${dir.jar-main}" perm="u+x" />
<chmod file="${dir.jar-main}" perm="a+x" />
</target>

<target name="jar" depends="compile.jar">
Expand Down
8 changes: 8 additions & 0 deletions data/jar-root/linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

cd $DIR


java -jar JWriter.jar
6 changes: 0 additions & 6 deletions data/jar/main.css

This file was deleted.

35 changes: 0 additions & 35 deletions data/jar/startWindow.fxml

This file was deleted.

Binary file removed data/jar/window1.tar.gz
Binary file not shown.
File renamed without changes.
1 change: 1 addition & 0 deletions data/jar/windowText_en.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MainWindow.Title=JWriter
23 changes: 0 additions & 23 deletions data/jar/windowtext/text.properties

This file was deleted.

35 changes: 35 additions & 0 deletions data/run/help-text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
=@head-id:This is heading 1 with id and the id is in a category
=List of formats
The list of formats avaiable: `coded`, _underline_, *italics*, and **bold**
Also has <@ref|link with reference> <www.google.com|direct link> {@citation}, {*endnote}, and {^footnote}
=List of line styles avaiable
Basic paragraph
> quote block
- bullet
# Level 1 numbered
# Level 2 numbered
# Level 3 numbered (to level 6)

- Level 2 bullet without being nested
Section break (below)
***
!*endnote: these are notes to end of a published section/document
!^footnote: these are notes at the end of a published page.
!@ref:https://github.com/creativeArtie/JWriter
=More on heading
==This is a subheading with a stub status #STUB detail of the status
!# This is a outline with a draft status #DRAFT
status can be `#STUB`, `#DRAFT`, `#FINAL`, `#` (None)
All outline and heading can have id and status
=Note and comments
!!This is full line agenda
This has a {!in line agenda}
Agendas are to-do list and will create warning while trying to print or export
!%@note: This is a note
!% put them anywhere
!%@citation:This is another note (separated because of the id) with citation
!%`source` is what in the reference section
!%`in-text` appears inside the text for APA or MLA styles
!%`footnote` appears as a footnote like CMS style
!>source:Author. *Book Title* Publish place: publish house, year. Print
!>in-text:(Author, page)
Binary file added design/main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added design/stats.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
38 changes: 19 additions & 19 deletions src/com/creativeartie/jwriter/file/ManuscriptFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.io.*;
import java.util.zip.*;
import java.util.*;

import static com.creativeartie.jwriter.lang.markup.AuxiliaryData.*;
import com.creativeartie.jwriter.main.Checker;
Expand All @@ -15,16 +16,7 @@ public class ManuscriptFile {
private static final String POST_FIX = ".txt";
private final ManuscriptDocument documentText;
private final RecordTable recordsFile;
private final File zipFile;

/*public ManuscriptFile(File file){
zipFile = file;
if (file.exists()){
} else {
documentText = new ManuscriptDocument();
recordsFile = new RecordTable();
}
}*/
private Optional<File> zipFile;

public static ManuscriptFile open(File file) throws IOException{
try (ZipInputStream input = new ZipInputStream(new
Expand Down Expand Up @@ -57,28 +49,29 @@ record = new RecordTable(builder.toString());
}
}

public static ManuscriptFile newFile(File file) throws IOException{
if (file.exists()){
throw new IOException("File exists.");
}
return new ManuscriptFile(file, new ManuscriptDocument(),
public static ManuscriptFile newFile() {
return new ManuscriptFile(null, new ManuscriptDocument(),
new RecordTable());
}

private ManuscriptFile(File file, ManuscriptDocument doc,
RecordTable table)
{
zipFile = file;
zipFile = Optional.ofNullable(file);
documentText = doc;
recordsFile = table;
}

public ManuscriptFile(File file, File doc) throws IOException{
zipFile = file;
public ManuscriptFile(File doc) throws IOException{
zipFile = Optional.empty();
documentText = new ManuscriptDocument(doc);
recordsFile = new RecordTable();
}

public void setSave(File file){
zipFile = Optional.of(file);
}

public ManuscriptDocument getDocument(){
return documentText;
}
Expand All @@ -87,9 +80,16 @@ public RecordTable getRecords(){
return recordsFile;
}

public boolean canSave(){
return zipFile.isPresent();
}

public void save() throws IOException{
if (! zipFile.isPresent()){
throw new IOException("No file to save.");
}
try (ZipOutputStream writeTo = new ZipOutputStream(new FileOutputStream
(zipFile)))
(zipFile.get())))
{
save(writeTo, MAIN + POST_FIX, documentText.getRaw());
save(writeTo, RECORDS + POST_FIX, recordsFile.getSaveText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public boolean isId(){
@Override
public int getNoteCount(){
return getAgendaSpan().map(span -> span.wordCount())
.orElse(new Integer(0)).intValue();
.orElse(0);
}
}
19 changes: 14 additions & 5 deletions src/com/creativeartie/jwriter/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Main extends Application{
private Stage mainStage;

public final static ResourceBundle TEXTS = PropertyResourceBundle
.getBundle("data.window_text");
.getBundle("data.windowText", Locale.ENGLISH);

public static void main(String[] args) {
launch(args);
Expand All @@ -29,15 +29,24 @@ public void start(Stage stage) throws Exception{
stage.setTitle(TEXTS.getString("MainWindow.Title"));

// testStatsWindow(stage);
testMainWindow(stage);
// testMainWindow(stage);
jarMainWindow(stage);
}

private void testMainWindow(Stage stage) throws Exception{
setupWindow(stage, new File("data/help-text.txt"));
}

private void jarMainWindow(Stage stage) throws Exception{
File classPath = new File(System.getProperty("java.class.path"));
File file = new File(classPath.getParent(), "data/help-text.txt");
setupWindow(stage, file);
}

private void setupWindow(Stage stage, File file) throws Exception{
SceneWriterControl writer = new SceneWriterControl(stage);
Scene scene = new Scene(writer, 800, 600);
writer.setManuscriptFile(new ManuscriptFile(
new File("testDoc2.zip"), new File("data/sectionDebug4.txt")
));
writer.setManuscriptFile(new ManuscriptFile(file));
stage.setScene(scene);
stage.setMaximized(true);
stage.show();
Expand Down
2 changes: 1 addition & 1 deletion src/com/creativeartie/jwriter/main/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static String getCss(String key){

public static ResourceBundle getWindowText(){
if (texts == null){
texts = PropertyResourceBundle.getBundle("window_text");
texts = PropertyResourceBundle.getBundle("data.windowText", Locale.ENGLISH);
}
return texts;
}
Expand Down
26 changes: 12 additions & 14 deletions src/com/creativeartie/jwriter/property/PropertyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
public class PropertyManager{
private static final String EXTENSION = ".properties";
private final HashMap<String, Property<?>> properties;

private final Properties defaultProp;
private final Properties currentProp;

private final String baseFile;
private final String userFile;
public PropertyManager(String base, String user) throws IOException{
baseFile = base + EXTENSION;
baseFile = "/" + base + EXTENSION;
defaultProp = new Properties();
try(FileInputStream load = new FileInputStream(baseFile)){
defaultProp.load(load);
}
defaultProp.load(PropertyManager.class.getResourceAsStream(baseFile));
currentProp = new Properties(defaultProp);
userFile = user + EXTENSION;
File data = new File(userFile);
Expand All @@ -28,7 +26,7 @@ public PropertyManager(String base, String user) throws IOException{
}
properties = new HashMap<>();
}

public MapProperty getMapProperty(String key, String field, String line){
MapProperty ans = getProperty(key, MapProperty.class);
if (ans == null){
Expand All @@ -37,7 +35,7 @@ public MapProperty getMapProperty(String key, String field, String line){
}
return ans;
}

public StyleProperty getStyleProperty(String key){
StyleProperty ans = getProperty(key, StyleProperty.class);
if (ans == null){
Expand All @@ -46,7 +44,7 @@ public StyleProperty getStyleProperty(String key){
}
return ans;
}

public IntegerProperty getIntProperty(String key){
IntegerProperty ans = getProperty(key, IntegerProperty.class);
if (ans == null){
Expand All @@ -55,7 +53,7 @@ public IntegerProperty getIntProperty(String key){
}
return ans;
}

private <T> T getProperty(String key, Class<T> cast){
Property<?> ans = found(key);
if (ans != null){
Expand All @@ -67,7 +65,7 @@ private <T> T getProperty(String key, Class<T> cast){
}
return null;
}

private Property<?> found(String key){
if (currentProp.getProperty(key) == null){
throw new IllegalArgumentException("Property is not found: " + key +
Expand All @@ -78,17 +76,17 @@ private Property<?> found(String key){
}
return null;
}

public void store() throws Exception{
try(FileOutputStream out = new FileOutputStream(userFile)){
currentProp.store(out, "");
}
}

String get(String key){
return currentProp.getProperty(key);
}

void set(String key, String property){
currentProp.setProperty(key, property);
}
Expand Down
Loading

0 comments on commit 8c4ad90

Please sign in to comment.