Skip to content

Commit

Permalink
Drop novel title field (#1669)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo authored Jan 26, 2024
2 parents e03305d + d6eafcc commit ed3e513
Show file tree
Hide file tree
Showing 29 changed files with 318 additions and 388 deletions.
597 changes: 288 additions & 309 deletions docs/FileFormatSpec-1.5.fodt

Large diffs are not rendered by default.

Binary file modified docs/source/fileformatspec15.pdf
Binary file not shown.
3 changes: 1 addition & 2 deletions novelwriter/core/coretools.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ def _buildAndPopulate(self, path: Path, data: dict) -> bool:

project.data.setUuid(None)
project.data.setName(projName)
project.data.setTitle(projName)
project.data.setAuthor(projAuthor)
project.data.setLanguage(projLang)
project.setDefaultStatusImport()
Expand All @@ -383,7 +382,7 @@ def _buildAndPopulate(self, path: Path, data: dict) -> bool:
# Add Root Folders
hNovelRoot = project.newRoot(nwItemClass.NOVEL)
hTitlePage = project.newFile(lblTitlePage, hNovelRoot)
novelTitle = project.data.title if project.data.title else project.data.name
novelTitle = project.data.name

titlePage = f"#! {novelTitle}\n\n"
if project.data.author:
Expand Down
15 changes: 1 addition & 14 deletions novelwriter/core/projectdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def __init__(self, project: NWProject) -> None:
# Project Meta
self._uuid = ""
self._name = ""
self._title = ""
self._author = ""
self._saveCount = 0
self._autoCount = 0
Expand Down Expand Up @@ -102,11 +101,6 @@ def name(self) -> str:
"""Return the project name."""
return self._name

@property
def title(self) -> str:
"""Return the project title."""
return self._title

@property
def author(self) -> str:
"""Return the project author."""
Expand Down Expand Up @@ -228,16 +222,9 @@ def setName(self, value: str | None) -> None:
self._project.setProjectChanged(True)
return

def setTitle(self, value: str | None) -> None:
"""Set a new novel title."""
if value != self._title:
self._title = simplified(str(value or ""))
self._project.setProjectChanged(True)
return

def setAuthor(self, value: str | None) -> None:
"""Set the author value."""
if value != self._title:
if value != self._author:
self._author = simplified(str(value or ""))
self._project.setProjectChanged(True)
return
Expand Down
8 changes: 3 additions & 5 deletions novelwriter/core/projectxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
logger = logging.getLogger(__name__)

FILE_VERSION = "1.5" # The current project file format version
FILE_REVISION = "1" # The current project file format revision
FILE_REVISION = "2" # The current project file format revision
HEX_VERSION = 0x0105

NUM_VERSION = {
Expand Down Expand Up @@ -106,7 +106,8 @@ class ProjectXMLReader:
the project or the content into their respective section nodes
as attributes. The id attribute was also added to the project.
Rev 1: Drops the titleFormat section of settings.
Rev 1: Drops the titleFormat node from settings. 2.1 Beta 1.
Rev 2: Drops the title node from project. 2.3 Beta 1.
"""

def __init__(self, path: str | Path) -> None:
Expand Down Expand Up @@ -247,8 +248,6 @@ def _parseProjectMeta(self, xSection: ET.Element, data: NWProjectData) -> None:
for xItem in xSection:
if xItem.tag == "name":
data.setName(xItem.text)
elif xItem.tag == "title":
data.setTitle(xItem.text)
elif xItem.tag == "author":
data.setAuthor(xItem.text)
else:
Expand Down Expand Up @@ -520,7 +519,6 @@ def write(self, data: NWProjectData, content: list, saveTime: float, editTime: i

xProject = ET.SubElement(xRoot, "project", attrib=projAttr)
self._packSingleValue(xProject, "name", data.name)
self._packSingleValue(xProject, "title", data.title)
self._packSingleValue(xProject, "author", data.author)

# Save Project Settings
Expand Down
1 change: 0 additions & 1 deletion novelwriter/core/tohtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ def saveHtmlJson(self, path: str | Path) -> None:
data = {
"meta": {
"projectName": self._project.data.name,
"novelTitle": self._project.data.title,
"novelAuthor": self._project.data.author,
"buildTime": int(timeStamp),
"buildTimeStr": formatTimeStamp(timeStamp),
Expand Down
1 change: 0 additions & 1 deletion novelwriter/core/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,6 @@ def saveRawMarkdownJSON(self, path: str | Path) -> None:
data = {
"meta": {
"projectName": self._project.data.name,
"novelTitle": self._project.data.title,
"novelAuthor": self._project.data.author,
"buildTime": int(timeStamp),
"buildTimeStr": formatTimeStamp(timeStamp),
Expand Down
6 changes: 2 additions & 4 deletions novelwriter/core/toodt.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,7 @@ def initDocument(self) -> None:
# ===============

if self._headerText == "":
theTitle = self._project.data.title or self._project.data.name
theAuth = self._project.data.author
self._headerText = f"{theTitle} / {theAuth} /"
self._headerText = f"{self._project.data.name} / {self._project.data.author} /"

# Create Roots
# ============
Expand Down Expand Up @@ -373,7 +371,7 @@ def initDocument(self) -> None:

# Dublin Core Meta Data
xMeta = ET.SubElement(self._xMeta, _mkTag("dc", "title"))
xMeta.text = self._project.data.title or self._project.data.name
xMeta.text = self._project.data.name

xMeta = ET.SubElement(self._xMeta, _mkTag("dc", "date"))
xMeta.text = timeStamp
Expand Down
5 changes: 2 additions & 3 deletions sample/nwProject.nwx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.3a1" hexVersion="0x020300a1" fileVersion="1.5" fileRevision="1" timeStamp="2024-01-23 13:06:53">
<project id="e2be99af-f9bf-4403-857a-c3d1ac25abea" saveCount="1619" autoCount="255" editTime="81251">
<novelWriterXML appVersion="2.3a1" hexVersion="0x020300a1" fileVersion="1.5" fileRevision="2" timeStamp="2024-01-26 22:42:30">
<project id="e2be99af-f9bf-4403-857a-c3d1ac25abea" saveCount="1620" autoCount="255" editTime="81255">
<name>Sample Project</name>
<title>Sample Project</title>
<author>Jane Smith</author>
</project>
<settings>
Expand Down
3 changes: 1 addition & 2 deletions tests/files/nwProject-1.5.nwx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.0-rc1" hexVersion="0x020000c1" fileVersion="1.5" fileRevision="1" timeStamp="2022-11-07 13:00:48">
<novelWriterXML appVersion="2.0-rc1" hexVersion="0x020000c1" fileVersion="1.5" fileRevision="2" timeStamp="2022-11-07 13:00:48">
<project id="e2be99af-f9bf-4403-857a-c3d1ac25abea" saveCount="5" autoCount="10" editTime="1000">
<name>Sample Project</name>
<title>Sample Project</title>
<author>Jane Smith</author>
</project>
<settings>
Expand Down
3 changes: 1 addition & 2 deletions tests/reference/coreProject_NewFileFolder_nwProject.nwx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.0.7" hexVersion="0x020007f0" fileVersion="1.5" fileRevision="1" timeStamp="2023-06-03 18:18:23">
<novelWriterXML appVersion="2.3a1" hexVersion="0x020300a1" fileVersion="1.5" fileRevision="2" timeStamp="2024-01-26 22:50:57">
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="1" autoCount="1" editTime="0">
<name>New Project</name>
<title>New Novel</title>
<author>Jane Doe</author>
</project>
<settings>
Expand Down
3 changes: 1 addition & 2 deletions tests/reference/coreProject_NewRoot_nwProject.nwx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.0.7" hexVersion="0x020007f0" fileVersion="1.5" fileRevision="1" timeStamp="2023-06-03 18:18:23">
<novelWriterXML appVersion="2.3a1" hexVersion="0x020300a1" fileVersion="1.5" fileRevision="2" timeStamp="2024-01-26 22:50:57">
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="1" autoCount="1" editTime="0">
<name>New Project</name>
<title>New Novel</title>
<author>Jane Doe</author>
</project>
<settings>
Expand Down
3 changes: 1 addition & 2 deletions tests/reference/coreTools_DocDuplicator_nwProject.nwx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.1-beta1" hexVersion="0x020100b1" fileVersion="1.5" fileRevision="1" timeStamp="2023-07-20 20:33:41">
<novelWriterXML appVersion="2.3a1" hexVersion="0x020300a1" fileVersion="1.5" fileRevision="2" timeStamp="2024-01-26 22:53:40">
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="1" autoCount="1" editTime="0">
<name>New Project</name>
<title>New Novel</title>
<author>Jane Doe</author>
</project>
<settings>
Expand Down
3 changes: 1 addition & 2 deletions tests/reference/coreTools_ProjectBuilderA_nwProject.nwx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.3-alpha1" hexVersion="0x020300a1" fileVersion="1.5" fileRevision="1" timeStamp="2023-12-29 14:34:07">
<novelWriterXML appVersion="2.3a1" hexVersion="0x020300a1" fileVersion="1.5" fileRevision="2" timeStamp="2024-01-26 22:53:40">
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="1" autoCount="0" editTime="0">
<name>Test Project A</name>
<title>Test Project A</title>
<author>Jane Doe</author>
</project>
<settings>
Expand Down
3 changes: 1 addition & 2 deletions tests/reference/coreTools_ProjectBuilderB_nwProject.nwx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.3-alpha1" hexVersion="0x020300a1" fileVersion="1.5" fileRevision="1" timeStamp="2023-12-29 14:36:07">
<novelWriterXML appVersion="2.3a1" hexVersion="0x020300a1" fileVersion="1.5" fileRevision="2" timeStamp="2024-01-26 22:53:40">
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="1" autoCount="0" editTime="0">
<name>Test Project B</name>
<title>Test Project B</title>
<author>Jane Doe</author>
</project>
<settings>
Expand Down
5 changes: 2 additions & 3 deletions tests/reference/guiEditor_Main_Final_nwProject.nwx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.2-alpha1" hexVersion="0x020200a1" fileVersion="1.5" fileRevision="1" timeStamp="2023-10-17 20:52:34">
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="3" autoCount="2" editTime="4">
<novelWriterXML appVersion="2.3a1" hexVersion="0x020300a1" fileVersion="1.5" fileRevision="2" timeStamp="2024-01-26 22:48:13">
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="3" autoCount="2" editTime="3">
<name>New Project</name>
<title>New Novel</title>
<author>Jane Doe</author>
</project>
<settings>
Expand Down
3 changes: 1 addition & 2 deletions tests/reference/guiEditor_Main_Initial_nwProject.nwx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.0.7" hexVersion="0x020007f0" fileVersion="1.5" fileRevision="1" timeStamp="2023-06-03 18:18:30">
<novelWriterXML appVersion="2.3a1" hexVersion="0x020300a1" fileVersion="1.5" fileRevision="2" timeStamp="2024-01-26 22:45:36">
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="2" autoCount="1" editTime="0">
<name>New Project</name>
<title>New Novel</title>
<author>Jane Doe</author>
</project>
<settings>
Expand Down
5 changes: 2 additions & 3 deletions tests/reference/mBuildDocBuild_HTML5_Lorem_Ipsum.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"meta": {
"projectName": "Lorem Ipsum",
"novelTitle": "Lorem Ipsum",
"novelAuthor": "lipsum.com",
"buildTime": 1687620769,
"buildTimeStr": "2023-06-24 17:32:49"
"buildTime": 1706306020,
"buildTimeStr": "2024-01-26 22:53:40"
},
"text": {
"css": [
Expand Down
5 changes: 2 additions & 3 deletions tests/reference/mBuildDocBuild_NWD_Lorem_Ipsum.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"meta": {
"projectName": "Lorem Ipsum",
"novelTitle": "Lorem Ipsum",
"novelAuthor": "lipsum.com",
"buildTime": 1687621222,
"buildTimeStr": "2023-06-24 17:40:22"
"buildTime": 1706306020,
"buildTimeStr": "2024-01-26 22:53:40"
},
"text": {
"nwd": [
Expand Down
3 changes: 1 addition & 2 deletions tests/reference/projectXML_ReadLegacy10.nwx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.0-rc1" hexVersion="0x020000c1" fileVersion="1.5" fileRevision="1" timeStamp="2020-05-28 09:59:15">
<novelWriterXML appVersion="2.0-rc1" hexVersion="0x020000c1" fileVersion="1.5" fileRevision="2" timeStamp="2020-05-28 09:59:15">
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="0" autoCount="0" editTime="1000">
<name>Sample Project</name>
<title>Sample Project</title>
<author>Jay Doh</author>
</project>
<settings>
Expand Down
3 changes: 1 addition & 2 deletions tests/reference/projectXML_ReadLegacy11.nwx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.0-rc1" hexVersion="0x020000c1" fileVersion="1.5" fileRevision="1" timeStamp="2020-06-26 21:20:24">
<novelWriterXML appVersion="2.0-rc1" hexVersion="0x020000c1" fileVersion="1.5" fileRevision="2" timeStamp="2020-06-26 21:20:24">
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="5" autoCount="10" editTime="1000">
<name>Sample Project</name>
<title>Sample Project</title>
<author>Jay Doh</author>
</project>
<settings>
Expand Down
3 changes: 1 addition & 2 deletions tests/reference/projectXML_ReadLegacy12.nwx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.0-rc1" hexVersion="0x020000c1" fileVersion="1.5" fileRevision="1" timeStamp="2021-08-30 23:33:44">
<novelWriterXML appVersion="2.0-rc1" hexVersion="0x020000c1" fileVersion="1.5" fileRevision="2" timeStamp="2021-08-30 23:33:44">
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="5" autoCount="10" editTime="1000">
<name>Sample Project</name>
<title>Sample Project</title>
<author>Jay Doh</author>
</project>
<settings>
Expand Down
3 changes: 1 addition & 2 deletions tests/reference/projectXML_ReadLegacy13.nwx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.0-rc1" hexVersion="0x020000c1" fileVersion="1.5" fileRevision="1" timeStamp="2022-10-25 18:26:15">
<novelWriterXML appVersion="2.0-rc1" hexVersion="0x020000c1" fileVersion="1.5" fileRevision="2" timeStamp="2022-10-25 18:26:15">
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="5" autoCount="10" editTime="1000">
<name>Sample Project</name>
<title>Sample Project</title>
<author>Jay Doh</author>
</project>
<settings>
Expand Down
3 changes: 1 addition & 2 deletions tests/reference/projectXML_ReadLegacy14.nwx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="2.0-rc1" hexVersion="0x020000c1" fileVersion="1.5" fileRevision="1" timeStamp="2022-10-15 12:12:59">
<novelWriterXML appVersion="2.0-rc1" hexVersion="0x020000c1" fileVersion="1.5" fileRevision="2" timeStamp="2022-10-15 12:12:59">
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="5" autoCount="10" editTime="1000">
<name>Sample Project</name>
<title>Sample Project</title>
<author>Jay Doh</author>
</project>
<settings>
Expand Down
4 changes: 2 additions & 2 deletions tests/test_core/test_core_docbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def testCoreDocBuild_HTML(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
assert error == []

copyfile(docFile, tstFile)
assert cmpFiles(tstFile, cmpFile, ignoreLines=[6, 7])
assert cmpFiles(tstFile, cmpFile, ignoreLines=[5, 6])

# Check Error Handling
# ====================
Expand Down Expand Up @@ -370,7 +370,7 @@ def testCoreDocBuild_NWD(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
assert error == []

copyfile(docFile, tstFile)
assert cmpFiles(tstFile, cmpFile, ignoreLines=[6, 7])
assert cmpFiles(tstFile, cmpFile, ignoreLines=[5, 6])

# Check Error Handling
# ====================
Expand Down
4 changes: 0 additions & 4 deletions tests/test_core/test_core_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,6 @@ def testCoreProject_Methods(monkeypatch, mockGUI, fncPath, mockRnd):
project.data.setName(" A Name ")
assert project.data.name == "A Name"

# Project Title
project.data.setTitle(" A Title ")
assert project.data.title == "A Title"

# Project Author
project.data.setAuthor(" Jane\tDoe ")
assert project.data.author == "Jane Doe"
Expand Down
8 changes: 1 addition & 7 deletions tests/test_core/test_core_projectxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,12 @@ def testCoreProjectXML_ReadCurrent(monkeypatch, tstPaths, fncPath):
assert xmlReader.state == XMLReadState.PARSED_OK
assert xmlReader.xmlRoot == "novelWriterXML"
assert xmlReader.xmlVersion == 0x0105
assert xmlReader.xmlRevision == 1
assert xmlReader.xmlRevision == 2
assert xmlReader.appVersion == "2.0-rc1"
assert xmlReader.hexVersion == 0x020000c1

# Check loaded data
assert data.name == "Sample Project"
assert data.title == "Sample Project"
assert data.author == "Jane Smith"
assert data.saveCount == 5
assert data.autoCount == 10
Expand Down Expand Up @@ -267,7 +266,6 @@ def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockRnd):

# Check loaded data
assert data.name == "Sample Project"
assert data.title == "Sample Project"
assert data.author == "Jay Doh" # Only last author is preserved
assert data.saveCount == 0 # Doesn't exist in 1.0
assert data.autoCount == 0 # Doesn't exist in 1.0
Expand Down Expand Up @@ -402,7 +400,6 @@ def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockRnd):

# Check loaded data
assert data.name == "Sample Project"
assert data.title == "Sample Project"
assert data.author == "Jay Doh" # Only last author is preserved
assert data.saveCount == 5
assert data.autoCount == 10
Expand Down Expand Up @@ -537,7 +534,6 @@ def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockRnd):

# Check loaded data
assert data.name == "Sample Project"
assert data.title == "Sample Project"
assert data.author == "Jay Doh" # Only last author is preserved
assert data.saveCount == 5
assert data.autoCount == 10
Expand Down Expand Up @@ -675,7 +671,6 @@ def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockRnd):

# Check loaded data
assert data.name == "Sample Project"
assert data.title == "Sample Project"
assert data.author == "Jay Doh" # Only last author is preserved
assert data.saveCount == 5
assert data.autoCount == 10
Expand Down Expand Up @@ -813,7 +808,6 @@ def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockRnd):

# Check loaded data
assert data.name == "Sample Project"
assert data.title == "Sample Project"
assert data.author == "Jay Doh" # Only last author is preserved
assert data.saveCount == 5
assert data.autoCount == 10
Expand Down
2 changes: 0 additions & 2 deletions tests/test_gui/test_gui_guimain.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
assert len(SHARED.project.tree._roots) == 0
assert SHARED.project.tree.trashRoot is None
assert SHARED.project.data.name == ""
assert SHARED.project.data.title == ""
assert SHARED.project.data.author == ""
assert SHARED.project.data.spellCheck is False

Expand All @@ -220,7 +219,6 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
assert len(SHARED.project.tree._roots) == 4
assert SHARED.project.tree.trashRoot is None
assert SHARED.project.data.name == "New Project"
assert SHARED.project.data.title == "New Novel"
assert SHARED.project.data.author == "Jane Doe"
assert SHARED.project.data.spellCheck is False

Expand Down
Loading

0 comments on commit ed3e513

Please sign in to comment.