From d1e9738a1ec1bc937799f8365346f8597c96f9d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nedeljko=20Ru=C5=BEi=C4=87?= <33520721+NenoR96@users.noreply.github.com> Date: Mon, 17 Jul 2023 21:57:04 +0200 Subject: [PATCH 1/3] add ai seeder --- src/control/content/index.html | 93 +++++++++++++++++++++------------- src/widget/widget.js | 19 +------ 2 files changed, 60 insertions(+), 52 deletions(-) diff --git a/src/control/content/index.html b/src/control/content/index.html index 37cd540..e1c35ea 100644 --- a/src/control/content/index.html +++ b/src/control/content/index.html @@ -1,5 +1,6 @@  + @@ -16,13 +17,14 @@ - + + -
+
-
+
Text @@ -65,6 +67,47 @@ } }; + $scope.showContent = false; + + var showAISeeder = function() { + let seeder = new buildfire.components.aiStateSeeder({ + generateOptions: { + userMessage: 'Write a blog post for me about the [topic]', + systemMessage: 'Blog post is an HTML string that can be inserted into a div tag, utilize images, figures, statistics. Use dummyimages.com to generate image URLs.', + jsonTemplate: { + content: { + carouselImages: [], + text: "" + } + }, + }, + importOptions: { + jsonTemplate: { + content: { + carouselImages: [], + text: "" + } + }, + sampleCsv: `https://source.unsplash.com/featured/?sunny,

Some heading

Some Text

`, + systemMessage: `For blog post images use dummyimages.com. For carousel images, generate small array of image urls based on topic, use source.unsplash.com for image URLs.`, + } + }).smartShowEmptyState({ selector: this.selector, }, (err, result) => { + if (!result) + buildfire.dialog.toast({ message: "Something went wrong" }); + $scope.$apply(function () { + $scope.showContent = true; + $scope.data.content = { + carouselImages: result.data.content.carouselImages.map(el => { return { iconUrl: el, action: "noAction", title: "image" } }), + text: result.data.content.text + } + editor.loadItems($scope.data.content.carouselImages); + console.log($scope) + seeder.requestResult.complete(); + }) + }); + $scope.showContent = true; + } + // create a new instance of the buildfire carousel editor var editor = new buildfire.components.carousel.editor("#carousel"); @@ -79,40 +122,16 @@ console.error("Error: ", err); return; } - - if (result && result.data && !angular.equals({}, result.data) && result.id) { - if(!result.data.design) result.data.design = $scope.data.design; + if (Object.keys(result.data).length && result.data.content.carouselImages.length > 0 && result.data.content.text && result.data.design) { + if (!result.data.design) result.data.design = $scope.data.design; $scope.data = result.data; $scope.id = result.id; - if($scope.data.content && $scope.data.content.carouselImages) + if ($scope.data.content && $scope.data.content.carouselImages) editor.loadItems($scope.data.content.carouselImages); if (tmrDelay) clearTimeout(tmrDelay); - } else{ - $scope.data = { content :{ - text : - '

The WYSIWYG (which stands for What You See Is What You Get) allows you to do some really cool stuff. You can add images like this

\ -

\ -

You can even create links like these:
Link to web content like this
Link to a phone number like this 8005551234
Link to an email like this noreply@google.com

\ -

Want to add some super cool videos about this item? You can do that too!

\ -

\ -

You can create bulleted and numbered lists like this:

\ -
    \ -
  • This is an item in a list
  • \ -
  • This is another item in a list
  • \ -
  • This is a last item in a list
  • \ -
\ -

Want more info? Check out our tutorial by clicking the help button at the top of this page.

', - - carouselImages : - [{"action":"noAction","iconUrl":"http://imageserver.prod.s3.amazonaws.com/b55ee984-a8e8-11e5-88d3-124798dea82d/5db61d30-0854-11e6-8963-f5d737bc276b.jpg","title":"image 1"},{"action":"noAction","iconUrl":"http://imageserver.prod.s3.amazonaws.com/b55ee984-a8e8-11e5-88d3-124798dea82d/31c88a00-0854-11e6-8963-f5d737bc276b.jpeg","title":"image 2"}] - }, - design: { - backgroundImage: null, - backgroundBlur: 0, - selectedLayout: 1 - } - }; - editor.loadItems($scope.data.content.carouselImages); + $scope.showContent = true; + } else { + showAISeeder(); } /* @@ -143,9 +162,13 @@ return; } - if(!newObj.content || !newObj.design) + if (!newObj.content || !newObj.design) return; + if(!newObj.content.carouselImages.length && !newObj.content.text) { + showAISeeder(); + } + buildfire.datastore.save(newObj, function (err, result) { if (err || !result) { console.error('Error saving the widget details: ', err); @@ -177,4 +200,4 @@ }]); - + \ No newline at end of file diff --git a/src/widget/widget.js b/src/widget/widget.js index da91d57..282bfd7 100644 --- a/src/widget/widget.js +++ b/src/widget/widget.js @@ -7,23 +7,8 @@ const Layouts = { const defaultData = { content: { - text : - '

The WYSIWYG (which stands for What You See Is What You Get) allows you to do some really cool stuff. You can add images like this

\ -

\ -

You can even create links like these:
Link to web content like this
Link to a phone number like this 8005551234
Link to an email like this noreply@google.com

\ -

Want to add some super cool videos about this item? You can do that too!

\ -

\ -

You can create bulleted and numbered lists like this:

\ -
    \ -
  • This is an item in a list
  • \ -
  • This is another item in a list
  • \ -
  • This is a last item in a list
  • \ -
\ -

Want more info? Check out our tutorial by clicking the help button at the top of this page.

', - - carouselImages : [ - {"action":"noAction","iconUrl":"http://imageserver.prod.s3.amazonaws.com/b55ee984-a8e8-11e5-88d3-124798dea82d/5db61d30-0854-11e6-8963-f5d737bc276b.jpg","title":"image 1"},{"action":"noAction","iconUrl":"http://imageserver.prod.s3.amazonaws.com/b55ee984-a8e8-11e5-88d3-124798dea82d/31c88a00-0854-11e6-8963-f5d737bc276b.jpeg","title":"image 2"} - ] + text: "", + carouselImages : [] }, design: { backgroundImage: null, From 3a528996100c6cabd6d5061451867cacf8251275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nedeljko=20Ru=C5=BEi=C4=87?= <33520721+NenoR96@users.noreply.github.com> Date: Tue, 18 Jul 2023 16:54:30 +0200 Subject: [PATCH 2/3] add real data to ai import --- src/control/content/index.html | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/control/content/index.html b/src/control/content/index.html index e1c35ea..a1c5be2 100644 --- a/src/control/content/index.html +++ b/src/control/content/index.html @@ -88,7 +88,7 @@ text: "" } }, - sampleCsv: `https://source.unsplash.com/featured/?sunny,

Some heading

Some Text

`, + sampleCsv: `https://source.unsplash.com/featured/?music,

The Magic of Music

Music Image

Music is a universal language that touches the hearts and souls of people all around the world. It has the power to evoke emotions, bring back memories, and create a sense of connection among individuals. Whether you're listening to your favorite tunes, playing an instrument, or attending a live concert, music has a way of transporting you to a different world.

Music can be found in various genres, each with its own unique style and characteristics. From classical masterpieces to upbeat pop songs, from soulful jazz melodies to energetic rock anthems, there's something for everyone's taste. It's incredible how a simple arrangement of notes and lyrics can stir up feelings of joy, sadness, excitement, or nostalgia.

Moreover, music has the ability to bring people together. It serves as a common ground where individuals from different cultures and backgrounds can find commonality and share their love for melodies and rhythms. Whether you're jamming with friends, joining a choir, or attending a music festival, music fosters a sense of community and unity.

So, let the power of music surround you. Explore new artists, discover different genres, and let the melodies guide your emotions. Whether you're seeking solace, motivation, or simply a form of entertainment, music will always be there to accompany you on your journey.

`, systemMessage: `For blog post images use dummyimages.com. For carousel images, generate small array of image urls based on topic, use source.unsplash.com for image URLs.`, } }).smartShowEmptyState({ selector: this.selector, }, (err, result) => { @@ -122,7 +122,7 @@ console.error("Error: ", err); return; } - if (Object.keys(result.data).length && result.data.content.carouselImages.length > 0 && result.data.content.text && result.data.design) { + if (Object.keys(result.data).length && result.data.content.carouselImages.length > 0 && result.data.content.text) { if (!result.data.design) result.data.design = $scope.data.design; $scope.data = result.data; $scope.id = result.id; @@ -165,10 +165,6 @@ if (!newObj.content || !newObj.design) return; - if(!newObj.content.carouselImages.length && !newObj.content.text) { - showAISeeder(); - } - buildfire.datastore.save(newObj, function (err, result) { if (err || !result) { console.error('Error saving the widget details: ', err); From d08acf873a994f5de2ef75b05cb4a49279e82cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nedeljko=20Ru=C5=BEi=C4=87?= <33520721+NenoR96@users.noreply.github.com> Date: Wed, 19 Jul 2023 17:24:24 +0200 Subject: [PATCH 3/3] code feedback --- src/control/content/index.html | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/control/content/index.html b/src/control/content/index.html index a1c5be2..462c623 100644 --- a/src/control/content/index.html +++ b/src/control/content/index.html @@ -72,8 +72,8 @@ var showAISeeder = function() { let seeder = new buildfire.components.aiStateSeeder({ generateOptions: { - userMessage: 'Write a blog post for me about the [topic]', - systemMessage: 'Blog post is an HTML string that can be inserted into a div tag, utilize images, figures, statistics. Use dummyimages.com to generate image URLs.', + userMessage: 'Write a sample article about the [topic]', + systemMessage: 'Article should utilize images, figures, statistics. Article length should be less then 400 characters. For carousel images use source.unsplash.com', jsonTemplate: { content: { carouselImages: [], @@ -91,19 +91,24 @@ sampleCsv: `https://source.unsplash.com/featured/?music,

The Magic of Music

Music Image

Music is a universal language that touches the hearts and souls of people all around the world. It has the power to evoke emotions, bring back memories, and create a sense of connection among individuals. Whether you're listening to your favorite tunes, playing an instrument, or attending a live concert, music has a way of transporting you to a different world.

Music can be found in various genres, each with its own unique style and characteristics. From classical masterpieces to upbeat pop songs, from soulful jazz melodies to energetic rock anthems, there's something for everyone's taste. It's incredible how a simple arrangement of notes and lyrics can stir up feelings of joy, sadness, excitement, or nostalgia.

Moreover, music has the ability to bring people together. It serves as a common ground where individuals from different cultures and backgrounds can find commonality and share their love for melodies and rhythms. Whether you're jamming with friends, joining a choir, or attending a music festival, music fosters a sense of community and unity.

So, let the power of music surround you. Explore new artists, discover different genres, and let the melodies guide your emotions. Whether you're seeking solace, motivation, or simply a form of entertainment, music will always be there to accompany you on your journey.

`, systemMessage: `For blog post images use dummyimages.com. For carousel images, generate small array of image urls based on topic, use source.unsplash.com for image URLs.`, } - }).smartShowEmptyState({ selector: this.selector, }, (err, result) => { - if (!result) - buildfire.dialog.toast({ message: "Something went wrong" }); + }).smartShowEmptyState(null, (err, result) => { $scope.$apply(function () { $scope.showContent = true; - $scope.data.content = { - carouselImages: result.data.content.carouselImages.map(el => { return { iconUrl: el, action: "noAction", title: "image" } }), - text: result.data.content.text + if (seeder.requestType === 'generate') { + $scope.data.content = { + carouselImages: result.data.content.carouselImages.map(el => { return { iconUrl: el, action: "noAction", title: "image" } }), + text: result.data.content.text + } + } else { + $scope.data.content = { + carouselImages: $scope.data.content.carouselImages.concat(result.data.content.carouselImages.map(el => { return { iconUrl: el, action: "noAction", title: "image" } })), + text: $scope.data.content.text + result.data.content.text + } } + editor.loadItems($scope.data.content.carouselImages); - console.log($scope) seeder.requestResult.complete(); - }) + }); }); $scope.showContent = true; }