咖啡脚本替换

时间:2015-02-03 21:40:44

标签: javascript coffeescript geektool

发现这个名为Ubersicht的新应用。它在Mac上似乎是一个不错的GeekTool桌面替代品,小部件使用咖啡脚本。

我发现了一个很棒的剧本: https://github.com/bgartenmann/uebersicht-only-this-widget

该脚本没有说明。它引用了桌面上名为today.txt的文本文件。我们的想法是将当天的任务放入其中,并在小部件中显示。

 todayfile = '~/Desktop/today.txt'

 command: "cat #{today file}"

 refreshFrequency: 5000

 style: (a long list of css went here, did not think it was relevant)

 render: (output) -> 
 placeholder = "_____________"
 outputArray = output.split "*"
 goal = outputArray[0] || placeholder
 step1 = outputArray[1] || placeholder
 step2 = outputArray[2] || placeholder
 step3 = outputArray[3] || placeholder

    <p>If nothing else, today I am going to <span class="fillout">#{goal}</span>.<br />
     I am going to do this by <span class="fillout">#{step1}</span> then <span class="fillout">#{step2}</span> then <span class="fillout">#{step3}</span>.<br />
     <span class="motivation">If I do this and only this,<br /> today will be a <strong>good</strong> day.</span>"

我无法弄清楚如何格式化.txt文件中的条目,以便条目最终位于窗口小部件的正确位置。我尝试了多种方法来引用step1,其中一个例子是..

step1 =&#34;此步骤&#34;

每当我插入文本时,它们总是在第一行结束。我怎么能做到这样的&#34;任务&#34;在.txt中输入最终在小工具上的预期显示位置?

1 个答案:

答案 0 :(得分:1)

首先,感谢您传播关于Übersichtthis widget的消息!他们太棒了!

~/Desktop/today.txt文件中的项目分隔符是星号*字符。

以下是我的~/Desktop/today.txt的样子:

answer a beyonddynamic’s question on stackoverflow
*
reading widget’s source code
*
taking a screenshot
*
posting an answer on stackoverfow

如果您愿意,可以在一行写句子。新行是可选的。

screenhot

相关问题