ColdFusion Get List of Docs in a Folder - Collection - google-docs-api

If I follow the examples I have seen to get the doc items in a collection, I end up with the below. It does bring back one entry but its not the items in the folder its just the folder entry itself.
<cfhttp url="https://docs.google.com/feeds/documents/private/full/folder%3A0B_xSYw8SWKixSxxx/contents" method="get" result="result" charset="utf-8">
<cfhttpparam type="header" name="Authorization" value="GoogleLogin auth=#getAuth(variables.docservice)#">
If I send in
https://docs.google.com/feeds/documents/private/full?showfolders=true
I get all my docs and a listing of folders.
Am I missing something?

If I'm reading this correctly then you need to use a different tag.
<cfdirectory
directory = "directory name"
action = "list"
name = "query_name"
sort = "asc"
type = "all">
<cfdump var="#query_name#"/>

Related

Order of HTML element bindings in Svelte

New to Svelte here and playing with the reactivity concept. This first example works, the file input field correctly shows the selected file.
<script>
let files = []
</script>
<input type='file' bind:files />
This second example (only swapped the input attributes) does not. As can be easily tested in the REPL.
<script>
let files = []
</script>
<input bind:files type='file' />
It complains with "Value being assigned to HTMLInputElement.files does not implement interface FileList." and I don't understand why... do the bindings always have to go last in Svelte?
As #RichHarris explains above... this is a bug in Svelte. For now simply add the bindings to the end of the input element until it has been fixed.
See the Github issue for more info.
UPDATE: This has been fixed in November 2019 (see pull request #3849).

Convert Nokogiri XML Document into Array of Strings?

I'm creating a Ruby on Rails application and using Nokogiri to parse an XML file. I'm trying to parse the XML file into mutable strings which I can manipulate to create other content.
Here's a sample XML I'm using
<feed xmlns="http://www.w3.org/2005/Atom">
<entry>
<title type="html">
<![CDATA[ First Post! ]]>
</title>
<content type="html">
<![CDATA[
<p>I’m very excited to have finally got my site up and running along with this blog!</p>]]>
</content>
</entry>
</feed>
This is what I've done so far relating to my problem
In my controller -
def index
#blog_title, #blog_post = parse_xml
end
private
def parse_xml
#xml_doc = Nokogiri::XML(open("atom.xml"))
titles = #xml_doc.css("entry title")
post = #xml_doc.css("content")
return titles, post
end
In my view -
<% for i in 1..#blog_title.length %>
<li><%= #blog_title[i-1] %></li>
<li><%= #blog_post[i-1] %></li>
<% end %>
A sample output from the view (it returns a Nokogiri Element) -
<title type="html"><![CDATA[First Post!]]></title>
So ideally, I'd like to make all the Nokogiri::Element inside the Nokogiri::Document a string or make the entire array a String array.
I've tried iterating through each element and calling .to_s but it doesn't seem to work.
I've also tried calling Ruby::String methods such as slice and that doesn't work (for obvious reasons).
The end result I'm trying to get at (using the sample output on my view) is to return only the following and none of the rest.
First Post!
Can anyone help me? If I'm not clear enough or if someone needs to see more work, please feel free to ask!
For your case you should simply use .text to extract the content of tags. Something like titles.text would work.
You're dealing with RSS/Atom feeds which can contain multiple title tags. You need to iterate over all title nodes and extract their content separately, in a way that lets you keep track of their order and what article they're attached to:
require 'nokogiri'
doc = Nokogiri::XML(<<EOT)
<feed xmlns="http://www.w3.org/2005/Atom">
<entry>
<title type="html">
<![CDATA[ First Post! ]]>
</title>
<content type="html">
<![CDATA[
<p>I’m very excited to have finally got my site up and running along with this blog!</p>]]>
</content>
</entry>
</feed>
EOT
doc.search('title').map(&:text)
# => ["\n First Post! \n "]
This returns an array of the text inside the title nodes. From there you can easily clean up each string, manipulate them, reuse them, whatever.
doc.search('title').map{ |s| s.text.strip }
# => ["First Post!"]
search returns a NodeSet, which is akin to an array of title nodes found in the document. If you don't iterate over them you'll get a concatenated string containing all their text, which is usually NOT what you want:
require 'nokogiri'
doc = Nokogiri::XML(<<EOT)
<foo>
<title>this</title>
<title>is</title>
<title>what</title>
<title>you'd</title>
<title>get</title>
</foo>
EOT
doc.search('title').text
# => "thisiswhatyou'dget"
versus:
doc.search('title').map(&:text)
# => ["this", "is", "what", "you'd", "get"]
Trying to tear apart the first result is impossible unless you have prior knowledge of the document's structure which is usually not true. Iterating over the returned NodeSet will yield very usable results.
To maintain consistency with the various title tags in a feed, you need to loop over the entries, then extract the embedded titles which is a bit different than what your sample XML and code shows:
require 'nokogiri'
doc = Nokogiri::XML(<<EOT)
<feed xmlns="http://www.w3.org/2005/Atom">
<entry>
<title type="html">
<![CDATA[ First Post! ]]>
</title>
<content type="html">
<![CDATA[
<p>I’m very excited to have finally got my site up and running along with this blog!</p>]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Second Post! ]]>
</title>
<content type="html">
<![CDATA[
<p>blah</p>]]>
</content>
</entry>
</feed>
EOT
titles = doc.search('entry').map { |entry|
entry.at('title').text.strip
}
titles # => ["First Post!", "Second Post!"]
Or perhaps more usable:
titles_and_content = doc.search('entry').map { |entry|
[
entry.at('title').text.strip,
entry.at('content').text.strip
]
}
titles_and_content
# => [["First Post!",
# "<p>I’m very excited to have finally got my site up and running along with this blog!</p>"],
# ["Second Post!", "<p>blah</p>"]]
which returns the title and the content for each entry. From this you can easily build up code to extract the links to the articles, date of publishing, refresh-rates, original site, everything you'd want to know about an individual article and its source, then store it in a database for later regurgitation when requested.
There are gems and scripts available for processing RDF, RSS and Atom feeds, however, years ago, when I had to write a huge aggregator for feeds, nothing was available that met my needs and I wrote one from scratch. I'd recommend trying to find one rather than reinvent that wheel, otherwise look through their source and learn from their experience. There are a number of things to do in code to be a good network-citizen that doesn't swamp the servers and get you banned.
See "How to avoid joining all text from Nodes when scraping" also.

How do I query (via url) the solr.admin.LukeRequestHandler to get collection index data

I want to use the luke handler as suggested in Solr schema, how to get dynamic fields in a collection, which is http://solr:8983/solr/admin/luke?numTerms=0
but the 4.10.3 solrconfig.xml has the following entry which indicates luke has been rolled into /admin/ and I should be able to use the http://localhost:8983/solr/admin path, which give me a 404 error.
<requestHandler name="/admin/"
class="solr.admin.AdminHandlers" />
<!-- This single handler is equivalent to the following... -->
<!--
<requestHandler name="/admin/luke" class="solr.admin.LukeRequestHandler" />
<requestHandler name="/admin/system" class="solr.admin.SystemInfoHandler" />
<requestHandler name="/admin/plugins" class="solr.admin.PluginInfoHandler" />
<requestHandler name="/admin/threads" class="solr.admin.ThreadDumpHandler" />
<requestHandler name="/admin/properties" class="solr.admin.PropertiesRequestHandler" />
<requestHandler name="/admin/file" class="solr.admin.ShowFileRequestHandler" >
-->
When I look for LukeRequestHandler documentation I find http://lucene.apache.org/solr/4_4_0/solr-core/org/apache/solr/handler/admin/LukeRequestHandler.html which expects I am building a java app, which I am not.
I attempt to use several methods found there in a url, all of which 404.
In addition to "how do I query the luke handler to get index data",
"is this the correct documentation for what I am trying to figure out?".
Any help in understanding how (these) java docs relate to me trying to understand how Solr works from url would be greatly appreciated.
I spent some days scratching my head with the same issue. Apparently, you need to include the name of your core into every request.
Testing with the "gettingstarted" core:
http://localhost:8983/solr/admin/luke/ gives 404.
http://localhost:8983/solr/gettingstarted/admin/luke/ gives an XML with the information of the index.
Check if this solves your problem.

additional parameters in magento's customer.xml layout file

i'm trying to add some explanatory text to the top customer links (my account, my cart etc) via the customer.xml file from the blank theme (this is in Magento 1.4.1.1)
i think that magento has the capability out of the box by issuing afterText or beforeText parameters, but when i use them it only seems to shove things before the link (not after, which is what I'm after).
here's an extract from customer.xml that includes the additional < afterText > parameter:
<default>
<!-- Mage_Customer -->
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>Your Account</label><url helper="customer/getAccountUrl"/><title>Your Account</title><prepare/><urlParams/><position>10</position><null /><aParams>rel="nofollow"</aParams><afterText>click to login</afterText></action>
</reference>
</default>
has anyone had any luck with this before? does it need some additional arguments for liParams?
thanks in advance!
EDIT: here's the final code that seems to be working for me. Note the addition of the extra fields as suggested by
thanks for this, it helped a lot. both you and #Zyava answer below helped me sort it out.
There's one field missing from your suggestion above (the innerText field). I've put the full code below that looks to be working for me. hope it helps someone else!
<action method="addLink" translate="label title" module="customer">
<label>Your Account</label>
<url helper="customer/getAccountUrl"/>
<title>Your Account</title>
<prepare/>
<urlParams/>
<liParams/>
<aParams>rel="nofollow"</aParams>
<innerText/>
<beforeText>yourbeforetext</beforeText>
<afterText>youraftertext</afterText></action>
big thank you to #clockworkgeek and #zyava - both of your answers helped me get through this.
Unfortunately the XML tag names don't relate to the variable parameters, it is the number of parameters that matters. You need to specify all parameters up to afterText including beforeText.
<action method="addLink" translate="label title" module="customer">
<label>Your Account</label>
<url helper="customer/getAccountUrl"/>
<title>Your Account</title>
<prepare/>
<urlParams/>
<position>10</position>
<liParams/>
<aParams>rel="nofollow"</aParams>
<beforeText/>
<afterText>click to login</afterText>
</action>
Block 'top.links' has type Mage_Page_Block_Template_Links. Look at Mage_Page_Block_Template_Links::addLink() method:
public function addLink($label, $url='', $title='', $prepare=false, $urlParams=array(),
$position=null, $liParams=null, $aParams=null, $beforeText='', $afterText='')
{
As we can see, $afterText parameter exists here. Now go to your theme's page/template/links.phtml, in my case it is \app\design\frontend\base\default\template\page\template\links.phtml and check that something like <?php echo $_link->getAfterText() ?> is present there.

Parsing atom/rss feed containing multiple <link> tags with Haml on RoR

So, firstly, here's an Atom feed snippet which I am trying to parse:
// http://somelink.com/atom
<feed xmlns="http://www.w3.org/2005/Atom">
<entry>
<title>Title Here</title>
<link href="http://somelink.com/link1&amp;ref=rss" rel="alternate" />
<link href="http://somelink.com/link2&amp;ref=rss" rel="tag:somelink.com/apply_url"/>
...
</entry>
I pull the Atom feed like so,
// In controller index method
#rss = SimpleRSS.parse open('http://somelink.com/atom')
Then I output the response in the view, which I am writing using Haml, as follows:
- #rss.entries.each do |item|
.title-div
= item.title
.title-link
= item.link //outputs the first link
I could run a second loop for the links but is there a way to get the second link without it? Like reading the "rel" attribute and outputting the correct link? How do I do this in Haml/Rails?
EDIT: The gem i am using: http://simple-rss.rubyforge.org/
I'm not familiar with that gem, but have you tried item.links to see if each item provides a collection of links?
I have never used SimpleRSS but maybe you could give Nokogiri or Hpricot a try? You can than run an XPath query to only select the link with the right attribute. An example with Nokogiri:
atom_doc = Nokogiri::XML(open("http://www.example.com/atom.xml"))
atom_doc.xpath("/xmlns:feed/xmlns:entry/xmlns:link[#rel='tag:somelink.com/apply_url']")
Don't forget the namespaces if you are parsing an Atom feed.

Resources