Skip to content

Commit 9485905

Browse files
committed
Figured out how to add in boilerplate view and url.
1 parent dd12465 commit 9485905

File tree

8 files changed

+513
-346
lines changed

8 files changed

+513
-346
lines changed

BootstrapStudioToDjango.wpu

Lines changed: 334 additions & 308 deletions
Large diffs are not rendered by default.

bss_to_django.exe.config.json

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"version": "auto-py-to-exe-configuration_v1",
3+
"pyinstallerOptions": [
4+
{
5+
"optionDest": "noconfirm",
6+
"value": true
7+
},
8+
{
9+
"optionDest": "filenames",
10+
"value": "C:/Users/fruit/OneDrive/Desktop/WebDev/BootstrapStudioToDjango/bss_to_django.py"
11+
},
12+
{
13+
"optionDest": "onefile",
14+
"value": true
15+
},
16+
{
17+
"optionDest": "console",
18+
"value": false
19+
},
20+
{
21+
"optionDest": "icon_file",
22+
"value": "C:/Users/fruit/OneDrive/Desktop/WebDev/BootstrapStudioToDjango/img/django.ico"
23+
},
24+
{
25+
"optionDest": "ascii",
26+
"value": false
27+
},
28+
{
29+
"optionDest": "clean_build",
30+
"value": false
31+
},
32+
{
33+
"optionDest": "strip",
34+
"value": false
35+
},
36+
{
37+
"optionDest": "noupx",
38+
"value": false
39+
},
40+
{
41+
"optionDest": "disable_windowed_traceback",
42+
"value": false
43+
},
44+
{
45+
"optionDest": "embed_manifest",
46+
"value": true
47+
},
48+
{
49+
"optionDest": "uac_admin",
50+
"value": false
51+
},
52+
{
53+
"optionDest": "uac_uiaccess",
54+
"value": false
55+
},
56+
{
57+
"optionDest": "win_private_assemblies",
58+
"value": false
59+
},
60+
{
61+
"optionDest": "win_no_prefer_redirects",
62+
"value": false
63+
},
64+
{
65+
"optionDest": "bootloader_ignore_signals",
66+
"value": false
67+
},
68+
{
69+
"optionDest": "argv_emulation",
70+
"value": false
71+
}
72+
],
73+
"nonPyinstallerOptions": {
74+
"increaseRecursionLimit": true,
75+
"manualArguments": ""
76+
}
77+
}

core/tag_converter.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class TagConverter:
1111
#Define different type of tag behavior
1212
ENCLOSED_TAG = ["for", "if", "block"]
1313
OPEN_TAG = ["load"]
14-
TAG_LINK = ["script", "img", "link", "iframe"]
14+
TAG_LINK = ["a", "script", "img", "link", "iframe"]
1515

1616
def __init__(self, filename:str, export_mapper:ExportMapperWidget, thread:core.exporter_thread.ExporterThread):
1717
self._filename = filename
@@ -41,7 +41,7 @@ def convert(self):
4141
self.extend_tag(tag, before=True)
4242

4343
for tag in self.TAG_LINK:
44-
self.replace_static_links(tag)
44+
self.replace_links(tag)
4545

4646
content = self.replace_background_img(self.beautiful_soup.prettify())
4747

@@ -87,14 +87,14 @@ def convert_bss_link(self, file_link):
8787
django_link = self.export_mapper.django_template_url(file_link)
8888
return django_link
8989

90-
def replace_static_links(self, tag_name):
90+
def replace_links(self, tag_name):
9191
"""
9292
Replace tag who will use django static files.
9393
9494
e.g. img, script etc.
9595
"""
9696
link_allowed_attributes = ["href", "src"]
97-
97+
9898
def find_ressource_attribute(element_attributes):
9999
"""
100100
Find which attribute is used to point to a ressource.
@@ -117,11 +117,18 @@ def find_ressource_attribute(element_attributes):
117117
if link.startswith("http"):
118118
continue
119119
elif self.is_local_link(link):
120-
element.attrs[attribute] = url_template.format(link)
120+
if link != '/':
121+
converted_link = self.convert_bss_link(link)
122+
element.attrs[attribute] = url_template.format(converted_link)
123+
else:
124+
element.attrs[attribute] = link
121125
else:
122126
self._loadStatic = True
123-
converted_link = self.convert_bss_link(link)
124-
element.attrs[attribute] = static_template.format(converted_link)
127+
if link != '/':
128+
converted_link = self.convert_bss_link(link)
129+
element.attrs[attribute] = static_template.format(converted_link)
130+
else:
131+
element.attrs[attribute] = link
125132

126133
def replace_ref(self):
127134
"""
@@ -155,4 +162,6 @@ def url_convert(match):
155162
return re.sub("url\((.*?)\)", url_convert, raw_file)
156163

157164
def is_local_link(self, link:str):
165+
if link == '/':
166+
return True
158167
return link.endswith('.html') and self.export_mapper.bss_input_file_exists(rel_filename=link)

dialog/main_window.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ def __getstate__(self):
3535

3636
def finish_setup(self):
3737
self.tabs.insertTab(1, self._exportMapper, "Export Mapping")
38-
self._exportMapper.file_added.connect(self.prompt_user_about_new_file)
38+
self.export_mapper.file_added.connect(self.prompt_user_about_new_file)
39+
self.export_mapper.status_message_signal.connect(lambda msg: self.log_status_message(msg, 5000))
3940

4041
if self.export_mapper.bss_design_root is None:
4142
if len(sys.argv) < 2:
42-
self.log_status_message('This app called without a command line argument. See the Getting Started tab.', 50000)
43+
self.log_status_message('This app called without a command line argument. See the Getting Started tab.', 5000)
4344
self.tabs.setCurrentWidget(self.gettingStartedTab)
4445
else:
4546
if not os.path.exists(sys.argv[1]):
@@ -50,7 +51,6 @@ def finish_setup(self):
5051
self.export_mapper.set_bss_root(bss_root)
5152
self.log_status_message(f'This app called with argument {os.path.relpath(bss_root)}.', 5000, 'color:blue')
5253
self.tabs.setCurrentWidget(self._exportMapper)
53-
#self._exportMapper.load_any_new_bss_files()
5454
else:
5555
self.log_status_message(f"{sys.argv[1]} is not a directory.", 10000, 'color:red')
5656

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
beautifulsoup4==4.9.1
22
soupsieve==2.0.1
3+
stringcase

ui/export_mapper_widget.ui

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858
<string>Relative to your BSS export's root folder.</string>
5959
</property>
6060
</column>
61+
<column>
62+
<property name="text">
63+
<string>File Changes</string>
64+
</property>
65+
</column>
6166
<column>
6267
<property name="text">
6368
<string>Process Option</string>
@@ -73,15 +78,18 @@
7378
</column>
7479
<column>
7580
<property name="text">
76-
<string>File Changes</string>
81+
<string>Django URL</string>
82+
</property>
83+
<property name="toolTip">
84+
<string>The URL to access this resource in a Django template.</string>
7785
</property>
7886
</column>
7987
<column>
8088
<property name="text">
81-
<string>Django URL</string>
89+
<string>Django View</string>
8290
</property>
8391
<property name="toolTip">
84-
<string>The URL to access this resource in a Django template.</string>
92+
<string>Name of the Django view function that loads this resource.</string>
8593
</property>
8694
</column>
8795
</widget>

ui/ui_export_mapper_widget.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ def retranslateUi(self, ExportMapperWidget):
5757
self.exportMappingTree.setSortingEnabled(True)
5858
self.exportMappingTree.headerItem().setText(0, _translate("ExportMapperWidget", "Input File"))
5959
self.exportMappingTree.headerItem().setToolTip(0, _translate("ExportMapperWidget", "Relative to your BSS export\'s root folder."))
60-
self.exportMappingTree.headerItem().setText(1, _translate("ExportMapperWidget", "Process Option"))
61-
self.exportMappingTree.headerItem().setText(2, _translate("ExportMapperWidget", "Output File"))
62-
self.exportMappingTree.headerItem().setToolTip(2, _translate("ExportMapperWidget", "Relative to your Django project\'s root."))
63-
self.exportMappingTree.headerItem().setText(3, _translate("ExportMapperWidget", "File Changes"))
60+
self.exportMappingTree.headerItem().setText(1, _translate("ExportMapperWidget", "File Changes"))
61+
self.exportMappingTree.headerItem().setText(2, _translate("ExportMapperWidget", "Process Option"))
62+
self.exportMappingTree.headerItem().setText(3, _translate("ExportMapperWidget", "Output File"))
63+
self.exportMappingTree.headerItem().setToolTip(3, _translate("ExportMapperWidget", "Relative to your Django project\'s root."))
6464
self.exportMappingTree.headerItem().setText(4, _translate("ExportMapperWidget", "Django URL"))
6565
self.exportMappingTree.headerItem().setToolTip(4, _translate("ExportMapperWidget", "The URL to access this resource in a Django template."))
66+
self.exportMappingTree.headerItem().setText(5, _translate("ExportMapperWidget", "Django View"))
67+
self.exportMappingTree.headerItem().setToolTip(5, _translate("ExportMapperWidget", "Name of the Django view function that loads this resource."))
6668
self.openBSSFolderButton.setText(_translate("ExportMapperWidget", "BSS Folder in Explorer..."))
6769
self.checkForBSSChangesButton.setText(_translate("ExportMapperWidget", "Check for BSS Changes"))
6870
self.expandWholeTreeButton.setText(_translate("ExportMapperWidget", "Expand Whole Tree"))

0 commit comments

Comments
 (0)