I’ve made an app in which I’m showing articles from my blog now i want to give an option of sharing
I’m using Custom Webview Extension to show my blog articles
When someone click on Share i want to share the article (either as a text or image but not as a url)
I’ve tried ComponentToImage extension (to convert my custom webview component to image) it’s good but problem is the height and width of the vertical arrangment is not adjusted to the article size and because of this i get blurry image & even if add height and width of vertical arrangment manually still i get some articles blurred because some articles are lengthy
Second thing I’ve tried is using WEB component in which i set url to my blog url after that I’ve added device utility to get text from my blog article, now if i add title> text /title> then I’ll get my article title
But i couldn’t get the description (post) and image from the article
It would be great help if someone help regarding this
P.s. I’ve searched the community there are topics but none of them works properly
Use this as Evaluate Javascript
It Will return the Text Paragraph
and when you got the text then use share component to share it
(function() {
var post = new Object();
data = document.getElementsByTagName("p");
for(var i = 2; i < data.length; i++) {
post[i] = data[i].innerText; }
return JSON.stringify(post);
})();
Use this to get Post Title
document.getElementsByClassName("post-title entry-title")[0].innerText;
Use this to get image from the post
document.getElementsByTagName("img")[0].src;
(function() {
var data = new Object();
var content = new Object();
data.title = document.getElementsByClassName("post-title entry-title")[0].innerText;
data.image = document.getElementsByTagName("img")[0].src;
para = document.getElementsByTagName("p");
for(var i = 2; i < para.length; i++) {
content[i] = para[i].innerText; }
var allData = new Object();
allData = {data, content};
return JSON.stringify(allData);
})();
Try this
Output
{
"data": {
"title": "બનાસકાંઠામાં જળ સંકટ ઘેરું બનતાં ખેડૂત આંદોલનના એંધાણ",
"image": "https://static.gujaratsamachar.com/content_image/content_image_619f6541-fd2e-4b5f-a0cd-217cb0d9a30c.gif"
},
"content": {
"2": "પાલનપુર, તા.27",
"3": "બનાસકાંઠા જિલ્લામાં ઘેરા બની રહેલા જળસંકટને નિવારવા જન આંદોલનના મંડાણ થયા છે. જેમાં પાલનપુર તાલુકાના કોટડા ગામે પચાસ ગામના ખેડૂતોની બેઠક મળી હતી. જેમાં જળ સંકટ મામેલ આગામી સમયમા ઉગ્ર આંદોલન કરવાની રણનીતિ ઘડવામાં આવી હતી.",
"4": "પાલનપુર તાલુકાના મલાણા ગામ સહિત આજુબાજુ પચાસ જેટલા ગામમો ભૂગર્ભ જળ સ્તર ઉડા જઇ રહ્યા હોય સિંચાઇ અને પીવાના પાણીની વિકટ સમસ્યા સર્જાય છે.ત્યારે આ પંથકમાં પાણીની સમસ્યાના ઉકેલ માટે મલાણા ગામના તળાવમાં પાણી નાખવાની માંગમાં છેલ્લા ૩૦ વર્ષથી રાજકીય નેતાઓ લોલીપોપ આપી રહ્યા હોય આ પંથકમાં જળ સંકટ ઘેરું બનું રહ્યું હોય જળ સંકટની સમસ્યાના કાયમી નિરાકરણ માટે રવિવારે ૫૦ ગામના આગેવાનોએ બેઠક યોજી હતી.જેમાં આગામી તા.૭ માર્ચે ના રોજ એક સો ટ્રેક્ટરોમાં પાંચ હજાર લોકો જોડાઈ પાલનપુર શહેરમાં રેલી યોજી સરકારને જગાડવાનો પ્રયાસ કરશે અને જો સરકાર ખેડૂતોના પાણીના પ્રશ્નનો ઉકેલ લાવવામાં નહીં સાંભળે તો મલાણા પંથકના પચાસ ગામના ખેડૂતો આગામી સમયમાં યોજાનાર વિધાનસભાની ચૂંટણીનો બહિષ્કાર કરવાની રણનીતિ ઘડવામાં આવી હતી.",
"5": "વિધાનસભા ચૂંટણીનો બહિષ્કાર કરવાની ચીમકી",
"6": "ભારતીય કિસાન સંધના પ્રમુખ માવજીભાઈ પટેલે જણાવ્યું હતું કે, મલાણા વિસ્તારના જળ સંકટના કાયમી ઉકેલ માટે આગામી તા.૭ માર્ચે પાંચ હજાર ખેડૂતો સો ટેક્ટર સાથે પાલનપુરમાં રેલી યોજશે.તેમ છતાં તેમની માંગણી નહિ સંતોષાય તો આગામી વિધાનસભા ચૂંટણીનો બહિષ્કાર કરવાનો ચીમકી ઉચ્ચારમાં આવી હતી.",
"7": "\\n",
"8": "\\n"
}
}