Skip to content

Instantly share code, notes, and snippets.

@awjrichards-zz
Created July 16, 2012 23:12
Show Gist options
  • Save awjrichards-zz/3125706 to your computer and use it in GitHub Desktop.
Save awjrichards-zz/3125706 to your computer and use it in GitHub Desktop.
Still broken photo desc template
diff --git a/assets/www/index.html b/assets/www/index.html
index 924be98..6974e56 100644
--- a/assets/www/index.html
+++ b/assets/www/index.html
@@ -80,6 +80,31 @@
</div>
</script>
+ <script type="text/html" id="upload-photo-description">
+ =={{int:filedesc}}==
+ {{Information
+ |description={{<%= descData.description %>}}
+ <%= descData.idField %>
+ |date=<%= descData.date %>
+ |source={{own}}
+ |author=[[User:<%= descData.username %>]]
+ |permission=
+ |other_versions=
+ |other_fields=
+ }}
+
+ =={{int:license-header}}==
+ {{self|<%= descData.license %>}}
+
+ <% if ( descData.autoWikiText.length ) { %>
+ <%= descData.autoWikiText %>
+ <% } %>
+
+ <% ._each( descData.cats, function( cat ) { %>
+ [[Category:<%= cat %>]]
+ <% }); %>
+ </script>
+
<div class="page" id="welcome-page">
<header class='actionbar'>
<img src="images/wlm-logo-cropped.png" />
diff --git a/assets/www/js/app.js b/assets/www/js/app.js
index 6a31980..c8594d1 100644
--- a/assets/www/js/app.js
+++ b/assets/www/js/app.js
@@ -377,6 +377,55 @@ require( [ 'jquery', 'l10n', 'geo', 'api', 'templates', 'monuments', 'preference
});
}
+ function dateYMD() {
+ var now = new Date(),
+ year = now.getUTCFullYear(),
+ month = now.getUTCMonth() + 1, // 0-based
+ day = now.getUTCDate(),
+ out = '';
+
+ out += year;
+
+ out += '-';
+
+ if (month < 10) {
+ out += '0';
+ }
+ out += month;
+
+ out += '-';
+
+ if (day < 10) {
+ out += '0';
+ }
+ out += day;
+
+ return out;
+ }
+
+ function formatUploadDescription( monument, campaignConfig, username ) {
+ console.log( 'formatuploaddesc' );
+ var ourCategories = [
+ 'Mobile upload',
+ 'Uploaded with Android WLM App',
+ 'UA: ' + navigator.userAgent.match( /Android (.*?)(?=\))/g )
+ ],
+ descData = {
+ idField: campaignConfig.idField.replace( '$1', monument.id ),
+ license: campaignConfig.defaultOwnWorkLicence, // note the typo in the API field
+ username: username,
+ autoWikiText: campaignConfig.autoWikiText,
+ cats: campaignConfig.defaultCategories.
+ concat( campaignConfig.autoCategories ).
+ concat( ourCategories ),
+ date: dateYMD()
+ };
+ console.log( 'formatuploaddesc-pretemp' );
+ var template = templates.getTemplate( 'upload-photo-description')( { descData: descData } );
+ console.log( template );
+ return template;
+ }
+
function init() {
var timeout, name, countryCode;
var countriesListTemplate = templates.getTemplate('country-list-template');
diff --git a/assets/www/js/upload.js b/assets/www/js/upload.js
index 5074a0a..d0297b2 100644
--- a/assets/www/js/upload.js
+++ b/assets/www/js/upload.js
@@ -1,6 +1,5 @@
// Tools for formatting description for uploads
-
function getCampaignInfo(campaign, callback) {
$.ajax({
url: 'https://commons.wikimedia.org/w/api.php',
@@ -19,77 +18,3 @@ function getCampaignInfo(campaign, callback) {
}
});
}
-
-function dateYMD() {
- var now = new Date(),
- year = now.getUTCFullYear(),
- month = now.getUTCMonth() + 1, // 0-based
- day = now.getUTCDate(),
- out = '';
-
- out += year;
-
- out += '-';
-
- if (month < 10) {
- out += '0';
- }
- out += month;
-
- out += '-';
-
- if (day < 10) {
- out += '0';
- }
- out += day;
-
- return out;
-}
-
-function formatUploadDescription( monument, campaignConfig, username ) {
- var idTemplate = campaignConfig.idField,
- idField = idTemplate.replace( '$1', monument.id ),
- license = campaignConfig.defaultOwnWorkLicence, // note the typo in the API field
- ourCategories = [
- 'Mobile upload',
- 'Uploaded with Android WLM App',
- 'UA: ' + navigator.userAgent.match( /Android (.*?)(?=\))/g )
- ],
- cats = campaignConfig.defaultCategories.
- concat( campaignConfig.autoCategories ).
- concat( ourCategories ),
- autoWikiText = campaignConfig.autoWikiText;
-
- var desc = '';
- desc += '=={{int:filedesc}}==\n';
- desc += '{{Information\n';
- desc += '|description=';
-
- desc += '{{' + monument.lang + '|1=' + monument.name + '}}\n';
- desc += idField + '\n';
-
- desc += '|date=' + dateYMD() + '\n';
- desc += '|source={{own}}\n';
- desc += '|author=[[User:' + username + ']]\n';
- desc += '|permission=\n';
- desc += '|other_versions=\n';
- desc += '|other_fields=\n';
- desc += '}}\n';
-
- desc += '\n';
-
- desc += '=={{int:license-header}}==\n';
- desc += '{{self|' + license + '}}\n';
-
- desc += '\n';
-
- if ( autoWikiText.length ) {
- desc += autoWikiText + '\n';
- }
-
- cats.forEach( function( cat ) {
- desc += '[[Category:' + cat + ']]\n';
- });
-
- return desc;
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment