Skip to content

Commit a27d71b

Browse files
committed
fixes to the citation
1 parent f787012 commit a27d71b

File tree

9 files changed

+2077
-15
lines changed

9 files changed

+2077
-15
lines changed

src/soca/commands/portal/metadata.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pygments.formatters import HtmlFormatter
1111
import mistune
1212
import os
13+
#from cffconvert.cli import cli as cff2bibcli
1314

1415
class metadata(object):
1516

@@ -177,19 +178,26 @@ def html_repo_icons(self):
177178
citations = self.citations()
178179
if citations:
179180
formatter = HtmlFormatter(linenos=False, full=True, style='friendly')
180-
for citation in citations.values():
181-
if isinstance(citation, list):
182-
citation = citation[0]
183-
html += self.icon_wrapper(
184-
icon_html = f"""<img src="{self.base}repo_icons/citation.png"
185-
class="repo-icon"
186-
{self.add_tooltip('bottom',f"Citation")}>""",
187-
188-
modal_html = self.modal(
189-
title = 'Citation',
190-
body = f'<div style="font-family: monospace;">{highlight(citation, ScdocLexer(), formatter)}</div>',
191-
markdown_translation=False,
192-
extra_html=
181+
#TODO once fixed turn to if, elif, else so that it prioritises CFF (converted to bibtex format)
182+
if 'cff' in citations:
183+
#TODO
184+
pass
185+
if 'bibtex' in citations:
186+
citation = citations['bibtex']
187+
else:
188+
try:
189+
citation = citations['citation'][0]
190+
except Exception as e:
191+
print(str(e))
192+
html += self.icon_wrapper(
193+
icon_html = f"""<img src="{self.base}repo_icons/citation.png"
194+
class="repo-icon"
195+
{self.add_tooltip('bottom',f"Citation")}>""",
196+
modal_html = self.modal(
197+
title = 'Citation',
198+
body = f'<div style="font-family: monospace;">{highlight(citation, ScdocLexer(), formatter)}</div>',
199+
markdown_translation=False,
200+
extra_html=
193201
f"""
194202
<button
195203
class="copy-citation-btn"
@@ -582,7 +590,7 @@ def citations(self):
582590
case _:
583591
continue
584592
return citations if len(citations) > 0 else None
585-
#TODO ask dani about this paper function. \
593+
586594
# Originally citations Took the ver8 somef "regular expression" output and would create a list of excerpts
587595

588596
def paper(self):

src/soca/commands/single_card.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from soca.commands.portal import card
2-
from somef.cli import cli_get_data
2+
from somef.somef_cli import cli_get_data
33
from soca import HiddenPrints
44
import traceback
55
import os

tests/repos-metadata/KnowledgeCaptureAndDiscovery_somef.json

Lines changed: 1384 additions & 0 deletions
Large diffs are not rendered by default.

tests/repos-metadata/Str3am786_soca_Miguel_Arroyo_TFG.json

Lines changed: 388 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
{
2+
"somef_provenance": {
3+
"somef_version": "0.9.3",
4+
"somef_schema_version": "1.0.0",
5+
"date": "2023-03-29 17:42:29"
6+
},
7+
"code_repository": [
8+
{
9+
"result": {
10+
"value": "https://github.com/Str3am786/somefTester",
11+
"type": "Url"
12+
},
13+
"confidence": 1,
14+
"technique": "GitHub_API"
15+
}
16+
],
17+
"owner": [
18+
{
19+
"result": {
20+
"value": "Str3am786",
21+
"type": "User"
22+
},
23+
"confidence": 1,
24+
"technique": "GitHub_API"
25+
}
26+
],
27+
"date_created": [
28+
{
29+
"result": {
30+
"value": "2023-03-03T13:17:39Z",
31+
"type": "Date"
32+
},
33+
"confidence": 1,
34+
"technique": "GitHub_API"
35+
}
36+
],
37+
"date_updated": [
38+
{
39+
"result": {
40+
"value": "2023-03-03T13:17:39Z",
41+
"type": "Date"
42+
},
43+
"confidence": 1,
44+
"technique": "GitHub_API"
45+
}
46+
],
47+
"license": [
48+
{
49+
"result": {
50+
"value": "https://api.github.com/licenses/mit",
51+
"type": "License",
52+
"name": "MIT License",
53+
"url": "https://api.github.com/licenses/mit",
54+
"spdx_id": "MIT"
55+
},
56+
"confidence": 1,
57+
"technique": "GitHub_API"
58+
},
59+
{
60+
"result": {
61+
"value": "MIT License\n\nCopyright (c) 2023 Str3am786\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
62+
"type": "File_dump"
63+
},
64+
"confidence": 1,
65+
"technique": "file_exploration",
66+
"source": "https://raw.githubusercontent.com/Str3am786/somefTester/main/LICENSE"
67+
}
68+
],
69+
"description": [
70+
{
71+
"result": {
72+
"value": "This Repo is to Test SOCA and SOMEF",
73+
"type": "String"
74+
},
75+
"confidence": 1,
76+
"technique": "GitHub_API"
77+
}
78+
],
79+
"name": [
80+
{
81+
"result": {
82+
"value": "somefTester",
83+
"type": "String"
84+
},
85+
"confidence": 1,
86+
"technique": "GitHub_API"
87+
}
88+
],
89+
"full_name": [
90+
{
91+
"result": {
92+
"value": "Str3am786/somefTester",
93+
"type": "String"
94+
},
95+
"confidence": 1,
96+
"technique": "GitHub_API"
97+
}
98+
],
99+
"issue_tracker": [
100+
{
101+
"result": {
102+
"value": "https://api.github.com/repos/Str3am786/somefTester/issues",
103+
"type": "Url"
104+
},
105+
"confidence": 1,
106+
"technique": "GitHub_API"
107+
}
108+
],
109+
"forks_url": [
110+
{
111+
"result": {
112+
"value": "https://api.github.com/repos/Str3am786/somefTester/forks",
113+
"type": "Url"
114+
},
115+
"confidence": 1,
116+
"technique": "GitHub_API"
117+
}
118+
],
119+
"stargazers_count": [
120+
{
121+
"result": {
122+
"value": 0,
123+
"type": "Number"
124+
},
125+
"confidence": 1,
126+
"technique": "GitHub_API"
127+
}
128+
],
129+
"keywords": [
130+
{
131+
"result": {
132+
"value": "",
133+
"type": "String"
134+
},
135+
"confidence": 1,
136+
"technique": "GitHub_API"
137+
}
138+
],
139+
"forks_count": [
140+
{
141+
"result": {
142+
"value": 0,
143+
"type": "Number"
144+
},
145+
"confidence": 1,
146+
"technique": "GitHub_API"
147+
}
148+
],
149+
"download_url": [
150+
{
151+
"result": {
152+
"value": "https://github.com/Str3am786/somefTester/releases",
153+
"type": "Url"
154+
},
155+
"confidence": 1,
156+
"technique": "GitHub_API"
157+
}
158+
],
159+
"readme_url": [
160+
{
161+
"result": {
162+
"value": "https://raw.githubusercontent.com/Str3am786/somefTester/main/README.md",
163+
"type": "Url"
164+
},
165+
"confidence": 1,
166+
"technique": "file_exploration"
167+
}
168+
],
169+
"faq": [
170+
{
171+
"result": {
172+
"value": "This is a simulation of Frequently asked Questions\nGoing to ask a question like this?\nSure",
173+
"type": "Text_excerpt",
174+
"original_header": "FAQ"
175+
},
176+
"confidence": 1,
177+
"technique": "header_analysis",
178+
"source": "https://raw.githubusercontent.com/Str3am786/somefTester/main/README.md"
179+
},
180+
{
181+
"result": {
182+
"value": "Good spawn\n",
183+
"type": "Text_excerpt",
184+
"original_header": "Test Question 1?",
185+
"parent_header": [
186+
"FAQ",
187+
"General Questions"
188+
]
189+
},
190+
"confidence": 1,
191+
"technique": "header_analysis",
192+
"source": "https://raw.githubusercontent.com/Str3am786/somefTester/main/README.md"
193+
},
194+
{
195+
"result": {
196+
"value": "Why not? docs.python.org\n",
197+
"type": "Text_excerpt",
198+
"original_header": "Question2?",
199+
"parent_header": [
200+
"FAQ",
201+
"General Questions"
202+
]
203+
},
204+
"confidence": 1,
205+
"technique": "header_analysis",
206+
"source": "https://raw.githubusercontent.com/Str3am786/somefTester/main/README.md"
207+
}
208+
],
209+
"documentation": [
210+
{
211+
"result": {
212+
"value": "It can be found in test.docs.org\n",
213+
"type": "Text_excerpt",
214+
"original_header": "Documentation?",
215+
"parent_header": [
216+
"FAQ",
217+
"General Questions"
218+
]
219+
},
220+
"confidence": 1,
221+
"technique": "header_analysis",
222+
"source": "https://raw.githubusercontent.com/Str3am786/somefTester/main/README.md"
223+
}
224+
],
225+
"support": [
226+
{
227+
"result": {
228+
"value": "More information can be found: https://github.com/Str3am786/somefTester/\n\n\n",
229+
"type": "Text_excerpt",
230+
"original_header": "Support",
231+
"parent_header": [
232+
"FAQ"
233+
]
234+
},
235+
"confidence": 1,
236+
"technique": "header_analysis",
237+
"source": "https://raw.githubusercontent.com/Str3am786/somefTester/main/README.md"
238+
}
239+
]
240+
}
1.5 KB
Binary file not shown.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Str3am786
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SOMEF tester
2+
3+
# FAQ
4+
This is a simulation of Frequently asked Questions
5+
Going to ask a question like this?
6+
Sure
7+
## General Questions
8+
### Test Question 1?
9+
Good spawn
10+
11+
### Question2?
12+
Why not? docs.python.org
13+
14+
### Documentation?
15+
It can be found in test.docs.org
16+
17+
## Support
18+
More information can be found: https://github.com/Str3am786/somefTester/
19+
20+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a support file that will support you in your support needs

0 commit comments

Comments
 (0)