From 3d6038103f3837a783c4a9cbd073318d8f52b5ca Mon Sep 17 00:00:00 2001
From: kasperlegarth
Date: Fri, 19 Jul 2019 09:34:26 +0200
Subject: [PATCH 01/14] Started implementing user feeds
---
.vscode/iisexpress.json | 6 ++++++
demo/demo.js | 2 +-
hashtaghistory.js | 33 ++++++++++++++++++++++++++++-----
3 files changed, 35 insertions(+), 6 deletions(-)
create mode 100644 .vscode/iisexpress.json
diff --git a/.vscode/iisexpress.json b/.vscode/iisexpress.json
new file mode 100644
index 0000000..9df36bb
--- /dev/null
+++ b/.vscode/iisexpress.json
@@ -0,0 +1,6 @@
+{
+ "port": 30707,
+ "path": "c:\\Users\\kaspe\\Google Drev\\Egne Projekter\\hashtaghistory.js",
+ "clr": "v4.0",
+ "protocol": "http"
+}
diff --git a/demo/demo.js b/demo/demo.js
index 8ffb713..4471d19 100644
--- a/demo/demo.js
+++ b/demo/demo.js
@@ -24,7 +24,7 @@ $(document).ready(function() {
$(this).html(highlight($(this).html()));
});
- $('#demo1').hashtaghistory('coding');
+ $('#demo1').hashtaghistory('');
let playgroundOptions = {
hashtag: 'summer',
diff --git a/hashtaghistory.js b/hashtaghistory.js
index f2f4162..859617c 100644
--- a/hashtaghistory.js
+++ b/hashtaghistory.js
@@ -2,20 +2,41 @@
$.fn.hashtaghistory = function(userSettings) {
let $container = this;
let settings = $.extend({
- hashtag : "",
+ get : "",
+ type : "",
imageSize : 150,
limit : 6,
link : true
}, userSettings);
- if($.type(userSettings) == "string") {
- settings.hashtag = userSettings;
+ if(typeof userSettings == "string") {
+ settings.get = userSettings;
}
- if(settings.hashtag == "") {
+ if(settings.get == "") {
+ console.group("Instastory.js log");
+ console.warn("You failed to specify what you want");
+ console.log("For more info on how to use the plugin, please see: https://github.com/kasperlegarth/hashtaghistory.js");
+ console.groupEnd();
+
return false;
}
+ determineType(settings.get);
+
+ const determineType = function(searchString) {
+ if(searchString.indexOf("@") > -1) {
+ settings.type = "user";
+ settings.get = searchString.substring(searchString.indexOf('@') + 1);
+ } else if(searchString.indexOf("#") > -1) {
+ settings.type = "hashtag";
+ settings.get = searchString.substring(searchString.indexOf('#') + 1);
+ } else {
+ settings.type = "hashtag";
+ settings.get = searchString;
+ }
+ }
+
const getImageSize = function(wantedImageSize) {
switch(wantedImageSize) {
case 150:
@@ -54,8 +75,10 @@
return html;
};
+
+
$.ajax({
- url: "https://www.instagram.com/explore/tags/" + settings.hashtag + "/?__a=1",
+ url: "https://www.instagram.com/combine_dk/?__a=1",
success: function(data) {
let posts = data.graphql.hashtag.edge_hashtag_to_media.edges;
From 3a7980682ee1b1567278bee78af133e95f66ae6d Mon Sep 17 00:00:00 2001
From: kasperlegarth
Date: Fri, 19 Jul 2019 09:43:51 +0200
Subject: [PATCH 02/14] Some structure changes
---
.gitignore | 1 +
.vscode/iisexpress.json | 2 +-
demo/demo.js | 2 +-
hashtaghistory.js | 21 +++++++++++++++++++--
index.html | 4 ++--
5 files changed, 24 insertions(+), 6 deletions(-)
create mode 100644 .gitignore
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..75ec3f0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.vscode/*
\ No newline at end of file
diff --git a/.vscode/iisexpress.json b/.vscode/iisexpress.json
index 9df36bb..0d5fdd4 100644
--- a/.vscode/iisexpress.json
+++ b/.vscode/iisexpress.json
@@ -1,5 +1,5 @@
{
- "port": 30707,
+ "port": 36822,
"path": "c:\\Users\\kaspe\\Google Drev\\Egne Projekter\\hashtaghistory.js",
"clr": "v4.0",
"protocol": "http"
diff --git a/demo/demo.js b/demo/demo.js
index 4471d19..8ffb713 100644
--- a/demo/demo.js
+++ b/demo/demo.js
@@ -24,7 +24,7 @@ $(document).ready(function() {
$(this).html(highlight($(this).html()));
});
- $('#demo1').hashtaghistory('');
+ $('#demo1').hashtaghistory('coding');
let playgroundOptions = {
hashtag: 'summer',
diff --git a/hashtaghistory.js b/hashtaghistory.js
index 859617c..98f51e8 100644
--- a/hashtaghistory.js
+++ b/hashtaghistory.js
@@ -1,6 +1,7 @@
(function($) {
$.fn.hashtaghistory = function(userSettings) {
let $container = this;
+ let searchUrl = "";
let settings = $.extend({
get : "",
type : "",
@@ -8,6 +9,7 @@
limit : 6,
link : true
}, userSettings);
+
if(typeof userSettings == "string") {
settings.get = userSettings;
@@ -57,6 +59,17 @@
const generateHtml = function(postsObject) {
let html = "";
+ console.log(postsObject);
+
+ switch (settings.type) {
+ case user:
+
+ break;
+
+ default:
+ break;
+ }
+
for(var i = 0; i < settings.limit; i++) {
if(postsObject[i] !== undefined) {
@@ -75,10 +88,14 @@
return html;
};
-
+ if(settings.type == "user") {
+ searchUrl = "https://www.instagram.com/" + settings.get + "/?__a=1"
+ } else {
+ searchUrl = "https://www.instagram.com/explore/tags/" + settings.get + "/?__a=1";
+ }
$.ajax({
- url: "https://www.instagram.com/combine_dk/?__a=1",
+ url: searchUrl,
success: function(data) {
let posts = data.graphql.hashtag.edge_hashtag_to_media.edges;
diff --git a/index.html b/index.html
index b789dc4..af9079b 100644
--- a/index.html
+++ b/index.html
@@ -29,8 +29,8 @@ Introdoctuon
Getting startet
It is really simple to use the plugin all you need to to is include jQuery and the hashtaghistory.js file where you include your other scrips in the project.
-
-
+ <script src="jquery.min.js"></script>
+<script src="path/to/script/hashtaghistory.js"></script>
Then you just need to call the plugin on a DOM element that you want to be a container for the images. $("#demo1").hashtaghistory("coding");
There are only one required parmeter, and that is the hashtag you want to show the feed from.
This will give you the following output:
From d2a9f6986cae866694ff25bb37c34c65f44a321f Mon Sep 17 00:00:00 2001
From: kasperlegarth
Date: Fri, 19 Jul 2019 10:50:26 +0200
Subject: [PATCH 03/14] Renamed plugin and implemented user feeds
---
demo/demo.js | 14 ++---
index.html | 8 +--
hashtaghistory.js => instastory.js | 84 +++++++++++++++++-------------
3 files changed, 58 insertions(+), 48 deletions(-)
rename hashtaghistory.js => instastory.js (50%)
diff --git a/demo/demo.js b/demo/demo.js
index 8ffb713..43c6c2c 100644
--- a/demo/demo.js
+++ b/demo/demo.js
@@ -24,29 +24,29 @@ $(document).ready(function() {
$(this).html(highlight($(this).html()));
});
- $('#demo1').hashtaghistory('coding');
+ $('#demo1').instastory('#coding');
let playgroundOptions = {
- hashtag: 'summer',
+ get: '@instagram',
imageSize: 240,
limit: 9,
link: true
};
- $('#playground-result').hashtaghistory(playgroundOptions);
+ $('#playground-result').instastory(playgroundOptions);
$('#new-feed').click(function() {
- let newHashtag = $('#hashtag-input').val();
+ let newSource = $('#hashtag-input').val();
let newLimit = $('#limit-input').val();
- if(newHashtag !== '') {
- playgroundOptions.hashtag = newHashtag;
+ if(newSource !== '') {
+ playgroundOptions.get = newSource;
}
if(newLimit !== '') {
playgroundOptions.limit = newLimit;
}
- $('#playground-result').hashtaghistory(playgroundOptions);
+ $('#playground-result').instastory(playgroundOptions);
});
});
diff --git a/index.html b/index.html
index af9079b..4cdb4a8 100644
--- a/index.html
+++ b/index.html
@@ -15,8 +15,8 @@
hashtaghistory.js
The simple instagram feed
@@ -30,7 +30,7 @@ Introdoctuon
It is really simple to use the plugin all you need to to is include jQuery and the hashtaghistory.js file where you include your other scrips in the project.
<script src="jquery.min.js"></script>
-<script src="path/to/script/hashtaghistory.js"></script>
+<script src="path/to/script/instastory.js"></script>
Then you just need to call the plugin on a DOM element that you want to be a container for the images. $("#demo1").hashtaghistory("coding");
There are only one required parmeter, and that is the hashtag you want to show the feed from.
This will give you the following output:
@@ -53,7 +53,7 @@ How many items do you want?
-
+