0
下面的ruby代码会自动在VoodooPad中创建页面,并为每个页面添加元标记。Applescript(通过appscript)在循环中停止处理
vp = app("VoodooPad.app")
doc = vp.open vpdoc
page_names = [@name]
if self.class.to_s.match('Stake::Stack')
# Create the release notes page. Only run on parent stack
notes = "#{@name} Release Notes"
page_names.push notes
doc.remove :with_name => notes
doc.create :new => :page, :with_name => notes, :with_content => self.release_notes
end
# Create the settings page
settings = "#{@name} Settings"
page_names.push settings
doc.remove :with_name => settings
doc.create :new => :page, :with_name => settings, :with_content => self.to_md
page_names.each do |page_name|
# Add the meta tags to the product page
page = doc.pages[page_name]
puts page_name
page.remove_meta_record :with_key => "description"
page.remove_meta_record :with_key => "url"
page.remove_meta_record :with_key => "name"
page.remove_meta_record :with_key => "image"
page.remove_meta_record :with_key => "version"
page.remove_meta_record :with_key => "stacks_version"
page.add_meta_record :with_value => {'version' => @version_str}
page.add_meta_record :with_value => {'stacks_version' => @stacks_version}
page.add_meta_record :with_value => {'subtitle' => @subtitle}
page.add_meta_record :with_value => {'url' => @info_url}
page.add_meta_record :with_value => {'image' => @basename + '@128.png'}
page.add_meta_record :with_value => {'name' => @name}
end
在每个块中,相同的元标记被添加到3个页面。但是,标签只能添加到3页中的2页。如果我们以“徽章”的名称为例,以下是我的网页名称。
Badges
Badges Release Notes
Badges Settings
无论数组的顺序,“徽章”页面始终得到正确的标记。但是,对于另外两页,其中有史以来第一件作品。另一个没有。
我想也许它是页面名称中的空格。但是,这并不重要。我得到了同样的行为。如果您注意到代码也可以正确地动态创建这两个页面。
我也尝试添加一个睡眠,认为它可能是一个时间的事情。不。
我被卡住了。帮帮我。