{"id":1452,"date":"2020-09-11T02:31:34","date_gmt":"2020-09-11T02:31:34","guid":{"rendered":"http:\/\/sdi.thoughtstorms.info\/?p=1452"},"modified":"2020-09-11T02:31:34","modified_gmt":"2020-09-11T02:31:34","slug":"fixing-the-lower-case-mistake","status":"publish","type":"post","link":"https:\/\/sdi.thoughtstorms.info\/?p=1452","title":{"rendered":"Fixing the Lower-Case Mistake"},"content":{"rendered":"\n<p>After writing <em><a href=\"http:\/\/sdi.thoughtstorms.info\/?p=1450\">The Lower-Case Mistake <\/a><\/em>this morning, that basically convinced me that I had to move back to having CamelCase file-names for Cardigan Bay.<br \/>So &#8230; a burst of activity this afternoon, and the automatic lower-casing of file-names is gone.<br \/>If you create a page called HelloWorld, it will be in a file called HelloWorld.md<br \/>The GitHub \/ GitLab repos are now updated and this is now the official behaviour of Cardigan Bay.<br \/>Obviously it&#8217;s a breaking change. Because if you were using it yesterday and your HelloWorld page was in file called helloworld.md the new version of the code can&#8217;t see it.<br \/>The default Bedrock Wiki pages that come with Cardigan Bay have now been fixed. But I&#8217;m afraid you&#8217;ll have to change any other page names yourself.<br \/>I wrote a simple script to help me convert the ThoughtStorms page-base (of over 5000 pages)<br \/>It wasn&#8217;t perfect, but it did enough of them that I&#8217;m happy to commit to making the change. (I&#8217;ll clean up the problem cases by hand)<br \/>Here&#8217;s the code to fix the names. It basically searches all the links in pages to find CamelCase names. Then prints a list of &#8220;git mv&#8221; commands that would turn the lower-cased version of those named files back into CamelCased ones. You just have to pipe that output to a shell script file and run it and it will do the changes.<br \/>Like I say, not perfect, but took a couple of minutes to write, and does the bulk of the job.<br \/><\/p>\n\n\n<p>[cc lang=&#8221;python&#8221; lines=&#8221;-1&#8243; width=&#8221;90%&#8221;]<\/p>\n<p>from fsquery import FSQuery<br \/>\nimport re<\/p>\n<p>fsq = FSQuery(&#8220;pages\/&#8221;).Ext(&#8220;md&#8221;).NoFollow(&#8220;.work&#8221;).FileOnly()<br \/>\nd = {}<\/p>\n<p>def grepFiles() :<br \/>\n    for f in fsq :<br \/>\n        for l in f.open_file() :<br \/>\n            l =l.strip()<br \/>\n            sqrwiki = re.compile(&#8220;(\\[\\[(\\S+?)\\]\\])&#8221;)<br \/>\n            allnames = [x[1] for x in sqrwiki.findall(l)]<\/p>\n<p>            for n in allnames :<br \/>\n                if &#8220;:&#8221; in n : continue<br \/>\n                if &#8220;&gt;&#8221; in n : continue<br \/>\n                #if not n.islower() : continue<br \/>\n                d[n.lower()] = n<br \/>\n                for k,v in d.items() :<br \/>\n                    print(&#8220;git mv &#8216;%s.md&#8217; &#8216;%s.md'&#8221; % (k,v))<\/p>\n<p>grepFiles()<\/p>\n<p>[\/cc]<\/p>\n\n\n\n<p>You&#8217;ll have to fiddle with it a bit, and make sure you have <a href=\"https:\/\/github.com\/interstar\/FSQuery\">https:\/\/github.com\/interstar\/FSQuery<\/a> installed. But like I say, it does the bulk of the work.<br \/>If you have problems (eg. a big investment in Cardigan Bay data but can&#8217;t do this migration yourself), leave me a message and I&#8217;ll see what I can do to help.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>After writing The Lower-Case Mistake this morning, that basically convinced me that I had to move back to having CamelCase file-names for Cardigan Bay.So &#8230; a burst of activity this afternoon, and the automatic lower-casing of file-names is gone.If you create a page called HelloWorld, it will be in a file called HelloWorld.mdThe GitHub \/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[57],"class_list":["post-1452","post","type-post","status-publish","format-standard","hentry","category-me","tag-cardigan-bay"],"_links":{"self":[{"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/posts\/1452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1452"}],"version-history":[{"count":0,"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/posts\/1452\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}