make journals in roam date format be recognized by journals page
This commit is contained in:
parent
6e45be9b73
commit
71f0a3c4e4
2 changed files with 19 additions and 2 deletions
|
@ -187,7 +187,7 @@ def all_nodes(include_journals=True):
|
||||||
|
|
||||||
# remove journals if so desired.
|
# remove journals if so desired.
|
||||||
if not include_journals:
|
if not include_journals:
|
||||||
nodes = [node for node in nodes if not re.match('[0-9]+?-[0-9]+?-[0-9]+?', node.wikilink)]
|
nodes = [node for node in nodes if not util.is_journal(node.wikilink)]
|
||||||
|
|
||||||
# TODO: experiment with other ranking.
|
# TODO: experiment with other ranking.
|
||||||
# return sorted(nodes, key=lambda x: -x.size())
|
# return sorted(nodes, key=lambda x: -x.size())
|
||||||
|
@ -201,7 +201,7 @@ def all_users():
|
||||||
def all_journals():
|
def all_journals():
|
||||||
# hack hack.
|
# hack hack.
|
||||||
nodes = all_nodes()
|
nodes = all_nodes()
|
||||||
nodes = [node for node in nodes if re.match('[0-9]+?-[0-9]+?-[0-9]+?', node.wikilink)]
|
nodes = [node for node in nodes if util.is_journal(node.wikilink)]
|
||||||
return sorted(nodes, key=attrgetter('wikilink'), reverse=True)
|
return sorted(nodes, key=attrgetter('wikilink'), reverse=True)
|
||||||
|
|
||||||
def nodes_by_wikilink(wikilink):
|
def nodes_by_wikilink(wikilink):
|
||||||
|
|
17
app/util.py
17
app/util.py
|
@ -11,6 +11,7 @@
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
import re
|
||||||
|
|
||||||
def canonical_wikilink(wikilink):
|
def canonical_wikilink(wikilink):
|
||||||
# hack hack
|
# hack hack
|
||||||
|
@ -22,3 +23,19 @@ def canonical_wikilink(wikilink):
|
||||||
.replace('/', '-')
|
.replace('/', '-')
|
||||||
)
|
)
|
||||||
return wikilink
|
return wikilink
|
||||||
|
|
||||||
|
|
||||||
|
def is_journal(wikilink):
|
||||||
|
date_regexes = [
|
||||||
|
# iso format
|
||||||
|
'[0-9]{4}-[0-9]{2}-[0-9]{2}',
|
||||||
|
# roam format (what a monstrosity!)
|
||||||
|
'(January|February|March|April|May|June|July|August|September|October|November|December) [0-9]{1,2}(st|nd|th), [0-9]{4}',
|
||||||
|
# roam format (sanitzed for filenames)
|
||||||
|
'(january|february|march|april|may|june|july|august|september|october|november|december)-[0-9]{1,2}(st|nd|th)-[0-9]{4}',
|
||||||
|
]
|
||||||
|
|
||||||
|
# combine all the date regexes into one super regex
|
||||||
|
combined_date_regex = re.compile(f'^({"|".join(date_regexes)})$')
|
||||||
|
|
||||||
|
return combined_date_regex.match(wikilink)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue