My favorites
|
Sign in
gdata-samples
Google Data API Samples
Project Home
Downloads
Wiki
Issues
Source
Checkout
|
Browse
|
Changes
|
‹r105
r198
Source path:
svn
/
trunk
/
gadgets
/
blogger
/
blogger_gadget.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Blogger Gadget"
author="Eric Bidelman api.eric"
height="385">
<Require feature="opensocial-0.8" />
<OAuth>
<Service name="google">
<Access url="https://www.google.com/accounts/OAuthGetAccessToken" method="GET" />
<Request url="https://www.google.com/accounts/OAuthGetRequestToken?scope=http://www.blogger.com/feeds/" method="GET" />
<Authorization url="https://www.google.com/accounts/OAuthAuthorizeToken?oauth_callback=http://oauth.gmodules.com/gadgets/oauthcallback" />
</Service>
</OAuth>
</ModulePrefs>
<Content type="html">
<![CDATA[
<html>
<head>
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://jquery.com/src/jquery-latest.js"></script>
<!--<script type="text/javascript" src="http://gdata-samples.googlecode.com/svn/trunk/gadgets/blogger/tinymce/tiny_mce.js"></script>-->
<script type="text/javascript" src="http://gdata-samples.googlecode.com/svn/trunk/gadgets/blogger/popup.js"></script>
<link href="http://gdata-samples.googlecode.com/svn/trunk/gadgets/blogger/blogger_gadget.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<div id="errors" style="display: none"></div>
<div id="main" style="display:none">
<form id="postForm" name="postForm" onsubmit="savePost(this); return false;">
<div id="messages" style="display: none"></div>
<div class="selectFeed">Publish to: <select id="postFeedUri" name="postFeedUri" disabled="disabled"><option>loading blog list...</option></select></div>
<h4 style="clear:both">Title</h4>
<input type="text" id="title" name="title"/>
<h4>Content</h4>
<textarea id="content" name="content" style="width:100%;height:200px;"></textarea>
<h4 style="float:left;">Labels (comma separated)</h4><img src="http://gdata-samples.googlecode.com/svn/trunk/gadgets/blogger/blogger.png" style="float:right"/>
<input type="text" id="categories" name="categories"/>
<p><input type="submit" id="submitButton" value="Save"/> <input type="checkbox" id="draft" name="draft" checked="checked"/> <label for="draft">Draft?</label></p>
</form>
</div>
<div id="loading">
<h3>Loading...</h3>
<p><img src="http://gdata-samples.googlecode.com/svn/trunk/gadgets/blogger/ajax-loader.gif"></p>
</div>
<div id="approval" style="display: none">
<a href="#" id="personalize">Sign in to Blogger</a>
</div>
<div id="waiting" style="display: none">
<a href="#" id="approvalLink">I've approved access</a>
</div>
<script type="text/javascript">
var blogger = null;
function initGadget() {
/*tinyMCE.init({
mode : 'textareas',
theme : 'simple'
});*/
google.load('gdata', '1.x', {packages: ['blogger']});
google.setOnLoadCallback(function () {
blogger = new google.gdata.blogger.BloggerService('google-BloggerGadget-v1.0');
blogger.useOAuth('google');
fetchData();
});
}
function showOnly(id) {
var sections = ['main', 'approval', 'waiting', 'loading', 'errors'];
for (var i = 0, section; section = sections[i]; ++i) {
jQuery('#' + section).get(0).style.display = section === id ? 'block' : 'none';
}
}
function fetchData() {
jQuery('#errors').hide();
var callback = function(response) {
if (response.oauthApprovalUrl) {
var popup = shindig.oauth.popup({
destination: response.oauthApprovalUrl,
windowOptions: 'height=600,width=800',
onOpen: function() {
showOnly('waiting');
},
onClose: function() {
showOnly('loading');
fetchData();
}
});
jQuery('#personalize').get(0).onclick = popup.createOpenerOnClick();
jQuery('#approvalLink').get(0).onclick = popup.createApprovedOnClick();
showOnly('approval');
} else if (response.feed) {
showResults(response);
showOnly('main');
} else {
jQuery('#errors').html('Something went wrong').fadeIn();
showOnly('errors');
}
};
blogger.getBlogFeed('http://www.blogger.com/feeds/default/blogs', callback, callback);
}
function showResults(feedRoot) {
var blogs = feedRoot.feed.getEntries();
// Has the user created any blogs?
if(!blogs.length) {
jQuery('#main').html('First <a href="http://www.blogger.com" target="newblog">create a blog</a>.');
return;
}
var html = [];
for (var i = 0, blog; blog = blogs[i]; ++i) {
var title = blog.getTitle().getText();
var feedUri = blog.getEntryPostLink().getHref();
html.push('<option value="' + feedUri + '">' + title + '</option>');
}
jQuery('#postFeedUri').html(html.join('')).removeAttr('disabled');
}
function savePost(form) {
jQuery('#messages').fadeOut();
jQuery('#submitButton').val('Publishing...').attr('disabled', 'disabled');
var input = form.categories.value;
var categories = jQuery.trim(input) != '' ? input.split(',') : [];
jQuery.each(categories, function(i, value) {
var label = jQuery.trim(value);
categories[i] = {
scheme: 'http://www.blogger.com/atom/ns#',
term: label
};
});
// update 'content' textarea with rich text editors innerHTML
//tinyMCE.triggerSave();
var newEntry = new google.gdata.blogger.BlogPostEntry({
title: {
type: 'text',
text: form.title.value
},
content: {
type: 'text',
text: form.content.value
},
categories: categories
});
// publish as draft?
var isDraft = form.draft.checked;
if (isDraft) {
newEntry.setControl({draft: {value: google.gdata.Draft.VALUE_YES}});
}
var handleInsert = function(entryRoot) {
var entry = entryRoot.entry;
var str = isDraft ? '(as draft)' : '<a href="' + entry.getHtmlLink().getHref() + '" target="_blankt">View it</a>';
jQuery('#messages').html('Post published! ' + str).fadeIn();
jQuery('#submitButton').val('Save').removeAttr('disabled');
};
var handleError = function(e) {
var msg = e.cause ? e.cause.statusText + ': ' : '';
msg += e.message;
alert('Error: ' + msg);
};
blogger.insertEntry(form.postFeedUri.value, newEntry, handleInsert, handleError);
}
gadgets.util.registerOnLoadHandler(initGadget);
</script>
</body>
</html>
]]>
</Content>
</Module>
Show details
Hide details
Change log
r180
by api.e...@google.com on Jun 08, 2009
Diff
Removing email addresses
Go to:
...ets/base/jobFinder/jobFinder.xml
...dgets/blogger/blogger_gadget.xml
...nk/gadgets/blogger/grey-grad.gif
/trunk/hybrid/common.inc.php
/trunk/hybrid/index.php
.../oauth_playground/common.inc.php
/trunk/oauth_playground/index.php
/trunk/oauth_playground/js/main.js
.../oauth_playground/playground.php
Sign in
to write a code review
Older revisions
r105
by api.e...@google.com on Oct 08, 2008
Diff
[No log message]
r104
by api.e...@google.com on Oct 08, 2008
Diff
[No log message]
r102
by api.e...@google.com on Oct 02, 2008
Diff
[No log message]
All revisions of this file
File info
Size: 8092 bytes, 188 lines
View raw file
File properties
svn:mime-type
text/xml
svn:executable
*