From f8f1a00dbf06de121450d4ad4414612cce62cea3 Mon Sep 17 00:00:00 2001 From: dblythy Date: Mon, 12 Jun 2023 14:31:44 +1000 Subject: [PATCH 1/4] feat: build links dynamically --- _includes/footer.html | 1 + index.html | 452 ------------------------------------------ js/links.js | 201 +++++++++++++++++++ js/main.js | 93 ++------- 4 files changed, 222 insertions(+), 525 deletions(-) create mode 100644 js/links.js diff --git a/_includes/footer.html b/_includes/footer.html index 99bba09..6ab9190 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -19,4 +19,5 @@
Stay Connected
+ diff --git a/index.html b/index.html index 6666fa7..97d0a20 100755 --- a/index.html +++ b/index.html @@ -80,458 +80,6 @@

SDKs and Libraries

The open source versions of our SDKs with relevant links to learn more.
-
-
- -

Objective-C

-

- - - - - - - - -

-
- - - - - - - - - -
-
-
- -

Android

-

- - - - - - - - -

-
- - - - - - - - - - - -
- -
-
- - - -
-
- - - -
-
- - -
-
- -

Cloud Code

-
- - - -
-
-
-
-
- -

REST API

-
- - - -
-
-
- -

GraphQL API

-
- - - -
diff --git a/js/links.js b/js/links.js new file mode 100644 index 0000000..ce0ba37 --- /dev/null +++ b/js/links.js @@ -0,0 +1,201 @@ +const links = { + "parse-server": { + image: "https://parseplatform.org/img/cloudcode.svg", + }, + "Parse-SDK-iOS-OSX": { + name: "Objective-C", + image: "https://parseplatform.org/img/ios.svg", + guides: [ + { + name: "iOS Guide", + link: "https://docs.parseplatform.org/ios/guide/", + }, + { + name: "macOS Guide", + link: "https://docs.parseplatform.org/macos/guide/", + }, + ], + modules: [{ name: "Live Query", link: "https://github.com/parse-community/ParseLiveQuery-iOS-OSX" }], + }, + "Parse-SDK-Android": { + image: "https://parseplatform.org/img/android.svg", + name: "Android", + guide: "https://docs.parseplatform.org/android/guide/", + modules: [ + { name: "Parse UI", link: "https://github.com/parse-community/ParseUI-Android" }, + { name: "Live Query", link: "https://github.com/parse-community/ParseLiveQuery-Android" }, + ], + }, + "Parse-SDK-JS": { + image: "https://parseplatform.org/img/javascript.svg", + guide: "https://docs.parseplatform.org/js/guide/", + name: "JavaScript", + }, + "Parse-Swift": { + image: "https://parseplatform.org/img/swiftColour.svg", + guide: "https://github.com/parse-community/Parse-Swift#usage-guide", + name: "Swift", + }, + "Parse-SDK-Flutter": [ + { + image: "https://parseplatform.org/img/flutter.svg", + guide: "https://docs.parseplatform.org/flutter/guide/", + api: "https://parseplatform.org/Parse-SDK-Flutter/flutter/flutter_parse_sdk_flutter/flutter_parse_sdk_flutter-library.html", + name: "Flutter", + }, + { + image: "https://parseplatform.org/img/dart.svg", + guide: "https://docs.parseplatform.org/dart/guide/", + api: "https://parseplatform.org/Parse-SDK-Flutter/flutter/flutter_parse_sdk_flutter/flutter_parse_sdk_flutter-library.html", + name: "Dart", + }, + ], + "parse-php-sdk": { + image: "https://parseplatform.org/img/php.svg", + guide: "https://docs.parseplatform.org/php/guide/", + api: "https://parseplatform.org/parse-php-sdk/", + name: "PHP", + }, + "Parse-SDK-dotNET": [ + { + image: "https://parseplatform.org/img/net.svg", + guide: "https://docs.parseplatform.org/dotnet/guide/", + name: ".NET + Xaramin", + }, + { + image: "https://parseplatform.org/img/unity.svg", + guide: "https://docs.parseplatform.org/unity/guide/", + name: "Unity", + }, + ], + "Parse-SDK-Arduino": { + image: "https://parseplatform.org/img/arduino.svg", + guide: "https://docs.parseplatform.org/arduino/guide/", + name: "Arduino", + }, + "parse-embedded-sdks": { + image: "https://parseplatform.org/img/c.svg", + guide: "https://docs.parseplatform.org/embedded_c/guide/", + name: "Embedded C", + }, +}; +const additionalMeta = [ + { + name: "Cloud Code", + image: "https://parseplatform.org/img/cloudcode.svg", + guide: "https://docs.parseplatform.org/cloudcode/guide/", + }, + { + name: "REST API", + image: "https://parseplatform.org/img/rest.svg", + guide: "https://docs.parseplatform.org/rest/guide/", + }, + { + name: "GraphQL API", + image: "https://parseplatform.org/img/graphql.svg", + guide: "https://docs.parseplatform.org/graphql/guide/", + }, +]; + +$(document).ready(function () { + if (!gitJson) { + return; + } + gitJson = gitJson.sort((a, b) => b.stargazers_count - a.stargazers_count); + const formatNumber = new Intl.NumberFormat().format; + for (const git of gitJson) { + const title = git.name; + const stars = parseInt(git.stargazers_count); + const forks = parseInt(git.forks_count); + const meta = links[title]; + if (meta) { + for (const metaData of Array.isArray(meta) ? meta : [meta]) { + const formattedTitle = title + .split("-") + .map((string) => string.charAt(0).toUpperCase() + string.slice(1)) + .join(" "); + const guideLink = metaData.guides + ? ` + ` + : ` + + + `; + const modules = metaData.modules + ? ` + ` + : ``; + const text = ` +
+
+ +

${metaData.name || formattedTitle}

+

+ + + ${formatNumber(stars)} + + + + ${formatNumber(forks)} + +

+
+ ${guideLink} + + + + + + + ${modules} + +
`; + $(".repoRow").append(text); + } + } + } + + for (const row of additionalMeta) { + const text = ` +
+
+ +

${row.name}

+
+ + + +
`; + $(".repoRow").append(text); + } + + $(".expandableRepoLink").click(function(){ + console.log("CLICKED"); + const clicked = $(this); + $(".expandableRepoLink").not(clicked).removeClass("expanded"); + clicked.toggleClass("expanded"); + }); +}); diff --git a/js/main.js b/js/main.js index 8203091..eeff660 100755 --- a/js/main.js +++ b/js/main.js @@ -9,9 +9,9 @@ $(document).ready(function(){ // Use Jekyll Metadata to list the repos // (except for community repos) //====================================// - var totalStars = 0, - totalForks = 0, - totalRepos = 0; + let totalStars = 0; + let totalForks = 0; + let totalRepos = 0; //render repo to page function addToSection(sectionTitle, url, title, description, forks, stars, language){ @@ -22,22 +22,19 @@ $(document).ready(function(){ sectionTitle.append("

" + title + "

" + description + "

"); } + if (typeof gitJson !== 'undefined'){ - // Sort the gitJson by popularity - gitJson = gitJson.sort(function (a, b) { - return parseInt(a.stargazers_count) < parseInt(b.stargazers_count); - }); - for (var j = 0; j < gitJson.length; j++) { - var title = gitJson[j].name, - sortTitle = title.toLowerCase(), - url = gitJson[j].html_url, - hasIssues = gitJson[j].has_issues, - archived = gitJson[j].archived, - description = gitJson[j].description, - stars = parseInt(gitJson[j].stargazers_count), - forks = parseInt(gitJson[j].forks_count), - language = gitJson[j].language, - sortDescription = ""; + for (const git of gitJson) { + const title = git.name; + const sortTitle = title.toLowerCase(); + const url = git.html_url; + const hasIssues = git.has_issues; + const archived = git.archived; + const description = git.description; + const stars = parseInt(git.stargazers_count); + const forks = parseInt(git.forks_count); + let language = git.language; + let sortDescription = ""; // sortable description if (description !== null && description !== ""){ @@ -65,49 +62,7 @@ $(document).ready(function(){ //Sort SDK Repos //if title contains sdk hide it (since we hardcode them) - if (sortTitle.indexOf("sdk") >= 0 || sortTitle.indexOf("cli") >= 0 || sortTitle.indexOf("parse-swift") >= 0) { - //if title matches hardcoded repo title then use these forks/stars - if (sortTitle.includes("ios") === true){ - //ios stars/forks - $(".iosRepo .sdkRepoStar").text(stars); - $(".iosRepo .sdkRepoFork").text(forks); - } else if (sortTitle.includes("android") === true){ - $(".androidRepo .sdkRepoStar").text(stars); - $(".androidRepo .sdkRepoFork").text(forks); - } else if (sortTitle.includes("javascript") === true || sortTitle.includes("js") === true){ - $(".javascriptRepo .sdkRepoStar").text(stars); - $(".javascriptRepo .sdkRepoFork").text(forks); - } else if (sortTitle.includes("php") === true){ - $(".phpRepo .sdkRepoStar").text(stars); - $(".phpRepo .sdkRepoFork").text(forks); - } else if (sortTitle.includes("net") === true){ - //xamarin and dot net - $(".xamarinRepo .sdkRepoStar").text(stars); - $(".xamarinRepo .sdkRepoFork").text(forks); - - //Unity - $(".unityRepo .sdkRepoStar").text(stars); - $(".unityRepo .sdkRepoFork").text(forks); - } else if (sortTitle.includes("arduino") === true){ - $(".arduinoRepo .sdkRepoStar").text(stars); - $(".arduinoRepo .sdkRepoFork").text(forks); - } else if (sortTitle.includes("embedded") === true){ - $(".embeddedRepo .sdkRepoStar").text(stars); - $(".embeddedRepo .sdkRepoFork").text(forks); - } else if (sortTitle.includes("cli") === true){ - $(".cloudCodeRepo .sdkRepoStar").text(stars); - $(".cloudCodeRepo .sdkRepoFork").text(forks); - } else if (sortTitle.includes("swift") === true){ - $(".swiftRepo .sdkRepoStar").text(stars); - $(".swiftRepo .sdkRepoFork").text(forks); - } else if (sortTitle.includes("flutter") === true){ - $(".flutterRepo .sdkRepoStar").text(stars); - $(".flutterRepo .sdkRepoFork").text(forks); - $(".dartRepo .sdkRepoStar").text(stars); - $(".dartRepo .sdkRepoFork").text(forks); - } - continue; - } + //ignore repos with issues turned off if (hasIssues === false || archived === true || title === '.github' || title === 'Governance' || title === 'parse-community-peril' || title === 'parse-community.github.io' || title === 'blog' || title === 'relay-examples' || title === 'docs'|| title === 'parse-facebook-user-session'){ @@ -136,18 +91,10 @@ $(document).ready(function(){ } //write total forks, stars and repos into the page - $(".heroText .repoCount").text(totalRepos); - $(".heroText .starCount").text(totalStars); - $(".heroText .forkCount").text(totalForks); - - //====================================// - // expand/contract - //====================================// - $(".expandableRepoLink").click(function(){ - var clicked = $(this); - $(".expandableRepoLink").not(clicked).removeClass("expanded"); - clicked.toggleClass("expanded"); - }); + const formatNumber = new Intl.NumberFormat().format + $(".heroText .repoCount").text(formatNumber(totalRepos)); + $(".heroText .starCount").text(formatNumber(totalStars)); + $(".heroText .forkCount").text(formatNumber(totalForks)); //====================================// // Header animation From c6437da323b99898cac85f86553b1e2810d4e116 Mon Sep 17 00:00:00 2001 From: dblythy Date: Mon, 12 Jun 2023 14:33:30 +1000 Subject: [PATCH 2/4] Update links.js --- js/links.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/links.js b/js/links.js index ce0ba37..2681591 100644 --- a/js/links.js +++ b/js/links.js @@ -193,7 +193,6 @@ $(document).ready(function () { } $(".expandableRepoLink").click(function(){ - console.log("CLICKED"); const clicked = $(this); $(".expandableRepoLink").not(clicked).removeClass("expanded"); clicked.toggleClass("expanded"); From 99e816192bedefc6b100ffbf8cf84c372d13e863 Mon Sep 17 00:00:00 2001 From: dblythy Date: Mon, 12 Jun 2023 19:10:41 +1000 Subject: [PATCH 3/4] Update links.js --- js/links.js | 200 +++++++++++++++++++++++++++++----------------------- 1 file changed, 113 insertions(+), 87 deletions(-) diff --git a/js/links.js b/js/links.js index 2681591..cfafa19 100644 --- a/js/links.js +++ b/js/links.js @@ -1,103 +1,110 @@ const links = { - "parse-server": { - image: "https://parseplatform.org/img/cloudcode.svg", + 'parse-server': { + image: 'https://parseplatform.org/img/cloudcode.svg', }, - "Parse-SDK-iOS-OSX": { - name: "Objective-C", - image: "https://parseplatform.org/img/ios.svg", + 'Parse-SDK-iOS-OSX': { + name: 'Objective-C', + image: 'https://parseplatform.org/img/ios.svg', guides: [ { - name: "iOS Guide", - link: "https://docs.parseplatform.org/ios/guide/", + name: 'iOS Guide', + link: 'https://docs.parseplatform.org/ios/guide/', }, { - name: "macOS Guide", - link: "https://docs.parseplatform.org/macos/guide/", + name: 'macOS Guide', + link: 'https://docs.parseplatform.org/macos/guide/', }, ], - modules: [{ name: "Live Query", link: "https://github.com/parse-community/ParseLiveQuery-iOS-OSX" }], + modules: [ + { name: 'Live Query', link: 'https://github.com/parse-community/ParseLiveQuery-iOS-OSX' }, + ], }, - "Parse-SDK-Android": { - image: "https://parseplatform.org/img/android.svg", - name: "Android", - guide: "https://docs.parseplatform.org/android/guide/", + 'Parse-SDK-Android': { + image: 'https://parseplatform.org/img/android.svg', + name: 'Android', + guide: 'https://docs.parseplatform.org/android/guide/', modules: [ - { name: "Parse UI", link: "https://github.com/parse-community/ParseUI-Android" }, - { name: "Live Query", link: "https://github.com/parse-community/ParseLiveQuery-Android" }, + { name: 'Parse UI', link: 'https://github.com/parse-community/ParseUI-Android' }, + { name: 'Live Query', link: 'https://github.com/parse-community/ParseLiveQuery-Android' }, ], }, - "Parse-SDK-JS": { - image: "https://parseplatform.org/img/javascript.svg", - guide: "https://docs.parseplatform.org/js/guide/", - name: "JavaScript", + 'Parse-SDK-JS': { + image: 'https://parseplatform.org/img/javascript.svg', + guide: 'https://docs.parseplatform.org/js/guide/', + name: 'JavaScript', }, - "Parse-Swift": { - image: "https://parseplatform.org/img/swiftColour.svg", - guide: "https://github.com/parse-community/Parse-Swift#usage-guide", - name: "Swift", + 'Parse-Swift': { + image: 'https://parseplatform.org/img/swiftColour.svg', + guide: 'https://github.com/parse-community/Parse-Swift#usage-guide', + name: 'Swift', }, - "Parse-SDK-Flutter": [ + 'Parse-SDK-Flutter': [ { - image: "https://parseplatform.org/img/flutter.svg", - guide: "https://docs.parseplatform.org/flutter/guide/", - api: "https://parseplatform.org/Parse-SDK-Flutter/flutter/flutter_parse_sdk_flutter/flutter_parse_sdk_flutter-library.html", - name: "Flutter", + image: 'https://parseplatform.org/img/flutter.svg', + guide: 'https://docs.parseplatform.org/flutter/guide/', + api: + 'https://parseplatform.org/Parse-SDK-Flutter/flutter/flutter_parse_sdk_flutter/flutter_parse_sdk_flutter-library.html', + name: 'Flutter', }, { - image: "https://parseplatform.org/img/dart.svg", - guide: "https://docs.parseplatform.org/dart/guide/", - api: "https://parseplatform.org/Parse-SDK-Flutter/flutter/flutter_parse_sdk_flutter/flutter_parse_sdk_flutter-library.html", - name: "Dart", + image: 'https://parseplatform.org/img/dart.svg', + guide: 'https://docs.parseplatform.org/dart/guide/', + api: + 'https://parseplatform.org/Parse-SDK-Flutter/flutter/flutter_parse_sdk_flutter/flutter_parse_sdk_flutter-library.html', + name: 'Dart', }, ], - "parse-php-sdk": { - image: "https://parseplatform.org/img/php.svg", - guide: "https://docs.parseplatform.org/php/guide/", - api: "https://parseplatform.org/parse-php-sdk/", - name: "PHP", + 'parse-php-sdk': { + image: 'https://parseplatform.org/img/php.svg', + guide: 'https://docs.parseplatform.org/php/guide/', + api: 'https://parseplatform.org/parse-php-sdk/', + name: 'PHP', }, - "Parse-SDK-dotNET": [ + 'Parse-SDK-dotNET': [ { - image: "https://parseplatform.org/img/net.svg", - guide: "https://docs.parseplatform.org/dotnet/guide/", - name: ".NET + Xaramin", + image: 'https://parseplatform.org/img/net.svg', + guide: 'https://docs.parseplatform.org/dotnet/guide/', + name: '.NET + Xaramin', }, { - image: "https://parseplatform.org/img/unity.svg", - guide: "https://docs.parseplatform.org/unity/guide/", - name: "Unity", + image: 'https://parseplatform.org/img/unity.svg', + guide: 'https://docs.parseplatform.org/unity/guide/', + name: 'Unity', }, ], - "Parse-SDK-Arduino": { - image: "https://parseplatform.org/img/arduino.svg", - guide: "https://docs.parseplatform.org/arduino/guide/", - name: "Arduino", + 'Parse-SDK-Arduino': { + image: 'https://parseplatform.org/img/arduino.svg', + guide: 'https://docs.parseplatform.org/arduino/guide/', + name: 'Arduino', }, - "parse-embedded-sdks": { - image: "https://parseplatform.org/img/c.svg", - guide: "https://docs.parseplatform.org/embedded_c/guide/", - name: "Embedded C", + 'parse-embedded-sdks': { + image: 'https://parseplatform.org/img/c.svg', + guide: 'https://docs.parseplatform.org/embedded_c/guide/', + name: 'Embedded C', }, }; const additionalMeta = [ { - name: "Cloud Code", - image: "https://parseplatform.org/img/cloudcode.svg", - guide: "https://docs.parseplatform.org/cloudcode/guide/", + name: 'Cloud Code', + image: 'https://parseplatform.org/img/cloudcode.svg', + guide: 'https://docs.parseplatform.org/cloudcode/guide/', + other: [ + { title: 'Defined Schemas', link: 'https://docs.parseplatform.org/defined-schema/guide/' }, + ], }, { - name: "REST API", - image: "https://parseplatform.org/img/rest.svg", - guide: "https://docs.parseplatform.org/rest/guide/", + name: 'REST API', + image: 'https://parseplatform.org/img/rest.svg', + guide: 'https://docs.parseplatform.org/rest/guide/', }, { - name: "GraphQL API", - image: "https://parseplatform.org/img/graphql.svg", - guide: "https://docs.parseplatform.org/graphql/guide/", + name: 'GraphQL API', + image: 'https://parseplatform.org/img/graphql.svg', + guide: 'https://docs.parseplatform.org/graphql/guide/', }, ]; -$(document).ready(function () { +jQuery(function ($) { if (!gitJson) { return; } @@ -108,36 +115,44 @@ $(document).ready(function () { const stars = parseInt(git.stargazers_count); const forks = parseInt(git.forks_count); const meta = links[title]; - if (meta) { - for (const metaData of Array.isArray(meta) ? meta : [meta]) { - const formattedTitle = title - .split("-") - .map((string) => string.charAt(0).toUpperCase() + string.slice(1)) - .join(" "); - const guideLink = metaData.guides - ? ` + if (!meta) { + continue; + } + for (const metaData of Array.isArray(meta) ? meta : [meta]) { + const formattedTitle = title + .split('-') + .map(string => string.charAt(0).toUpperCase() + string.slice(1)) + .join(' '); + const guideLink = metaData.guides + ? `
` - : ` - + : ` + `; - const modules = metaData.modules - ? ` + const modules = metaData.modules + ? ` ` - : ``; - const text = ` + : ``; + const text = `
@@ -171,12 +186,20 @@ $(document).ready(function () {
`; - $(".repoRow").append(text); - } + $('.repoRow').append(text); } } for (const row of additionalMeta) { + const additonal = (row.other || []) + .map( + other => ` + + ` + ) + .join(''); const text = `
@@ -188,13 +211,16 @@ $(document).ready(function () {

Guide

+ ${additonal} +
+
`; - $(".repoRow").append(text); + $('.repoRow').append(text); } - $(".expandableRepoLink").click(function(){ - const clicked = $(this); - $(".expandableRepoLink").not(clicked).removeClass("expanded"); - clicked.toggleClass("expanded"); - }); + $('.expandableRepoLink').on('click', function () { + const clicked = $(this); + $('.expandableRepoLink').not(clicked).removeClass('expanded'); + clicked.toggleClass('expanded'); + }); }); From 2b55fd08038d6f3ef3f043a1f58dac7b1ce0aecc Mon Sep 17 00:00:00 2001 From: dblythy Date: Mon, 12 Jun 2023 23:02:07 +1000 Subject: [PATCH 4/4] Update links.js --- js/links.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/js/links.js b/js/links.js index cfafa19..9e94293 100644 --- a/js/links.js +++ b/js/links.js @@ -104,12 +104,13 @@ const additionalMeta = [ }, ]; -jQuery(function ($) { +document.addEventListener("DOMContentLoaded", () => { if (!gitJson) { return; } gitJson = gitJson.sort((a, b) => b.stargazers_count - a.stargazers_count); const formatNumber = new Intl.NumberFormat().format; + const repoRow = document.querySelector('.repoRow'); for (const git of gitJson) { const title = git.name; const stars = parseInt(git.stargazers_count); @@ -186,7 +187,7 @@ jQuery(function ($) { `; - $('.repoRow').append(text); + repoRow.insertAdjacentHTML('beforeend', text); } } @@ -214,13 +215,11 @@ jQuery(function ($) { ${additonal}
-`; - $('.repoRow').append(text); + `; + repoRow.insertAdjacentHTML('beforeend', text); + } + const expandButtons = document.querySelectorAll('.expandableRepoLink') + for (const button of expandButtons) { + button.addEventListener('click', () => button.classList.toggle('expanded')); } - - $('.expandableRepoLink').on('click', function () { - const clicked = $(this); - $('.expandableRepoLink').not(clicked).removeClass('expanded'); - clicked.toggleClass('expanded'); - }); });