diff --git a/crawling__iitd/crawling__iitd/config.py b/crawling__iitd/crawling__iitd/config.py deleted file mode 100644 index b1cf590..0000000 --- a/crawling__iitd/crawling__iitd/config.py +++ /dev/null @@ -1,18 +0,0 @@ -"""#dotenv not working properly.... need to be resolved.# """ - - -import os -#from dotenv import load_dotenv -import crawling__iitd.mongo_creator as utils - -#load_dotenv() - -MONGODB_URI = "mongodb://localhost:27170" - -if MONGODB_URI is None: - raise Exception('MONGODB_URI not set') - -MONGO_DBNAME = 'haystack' -MONGO_COLLNAME = 'crawl_info' - -mongo_collection = utils.getMongoCollection() \ No newline at end of file diff --git a/crawling__iitd/crawling__iitd/elastic_exporter.py b/crawling__iitd/crawling__iitd/elastic_exporter.py deleted file mode 100644 index 10aa43b..0000000 --- a/crawling__iitd/crawling__iitd/elastic_exporter.py +++ /dev/null @@ -1,86 +0,0 @@ -from logging import warn -from typing import overload -from scrapy.exporters import BaseItemExporter -from elasticsearch import helpers, Elasticsearch -from elasticsearch.helpers import streaming_bulk,bulk -from multiprocessing import Queue, Process, log_to_stderr -from datetime import datetime -import warnings -import logging - -#from crawler.config import ELASTIC_URI, ELASTIC_INDEX_NAME, mongo_collection -from crawling__iitd.mongo_creator import getMongoCollection -from pymongo.mongo_client import MongoClient -from pymongo.collection import Collection - - -ELASTIC_URI ="localhost:9200" -ELASTIC_INDEX_NAME = "iitd_sites" -class ElasticExporter(BaseItemExporter): - - def __init__(self, _, **kwargs) -> None: - super().__init__(dont_fail=True, **kwargs) - - - def start_exporting(self): - self.client = Elasticsearch([ELASTIC_URI]) - self.mongo_collection: Collection = getMongoCollection() - if not self.client.indices.exists(ELASTIC_INDEX_NAME): - self.client.indices.create(ELASTIC_INDEX_NAME) - - #for bulk export to ES - self.list=[] - - def finish_exporting(self): - bulk(self.client,self.list) - print("exporting process ended") - - - def export_item(self, item): - response_url = item["url"] - response_title=item["title"] - response_body=item["body"] - #IDEAL FIELDS FOR SEARCH RESULTS # self.list.append({"_index":"iitd_sites","_type":'_doc', "url":response_url,"title":response_title,"body":response_body})#{'link':response_url,'title':response_title, "body":response_body}}) - - #for bulk export - if not self.client.exists(index=ELASTIC_INDEX_NAME, id=response_url): - #print("****************************|| CONDITION PASSED ||***********************************") - self.list.append({"_index":"iitd_sites", - "_type":"_doc", - "_id":response_url, - "url":response_url, - "title":response_title, - "body":response_body, - "meta_data":item["meta_data"], - "links_text":item["links_text"], - "links_url":item["links_url"], - "linked_img":item["image_urls"], - "visits":0 - }) - - print("list lenth changed to ",len(self.list)) - if (len(self.list)>=5): - bulk( self.client , self.list ) - #self.client.indices.refresh("iitd_sites") - for data in self.list: - if self.client.exists(index="iitd_sites", id=data["url"]): - self.mongo_collection.update_one({"url": data["url"]}, - {"$set": {"indexed":True}}, - upsert=True, - ) - self.list.clear() - - - #condition to be added - #self.client.index(index='iit',doc_type='_doc',body={'url':response_url,'title':response_title, "body":response_body}) - - - # self.mongo_collection.update_one( - # {"url": response_url}, - # { - # "$set": {"indexed":True} - # }, - # upsert=True, - # ) - - \ No newline at end of file diff --git a/crawling__iitd/crawling__iitd/items.py b/crawling__iitd/crawling__iitd/items.py index 2f9c0a4..5844388 100644 --- a/crawling__iitd/crawling__iitd/items.py +++ b/crawling__iitd/crawling__iitd/items.py @@ -1,12 +1,94 @@ # Define here the models for your scraped items -# # See documentation in: # https://docs.scrapy.org/en/latest/topics/items.html - +import sys +import os +import itemloaders import scrapy +from elasticsearch import helpers, Elasticsearch +from elasticsearch.helpers import bulk +#from elasticsearch_dsl.connections import connections +from scrapy.loader.processors import MapCompose, TakeFirst, Join + +from scrapy.loader import ItemLoader #Import the ItemLoader class and load the items container class to fill the data +#import ItemLoader.processors.TakeFirst + +class CrawlingIitdItemLoader(ItemLoader): #Custom Loader inherits ItemLoader class, call this class on the crawler page to fill the data to Item class + default_output_processor = itemloaders.processors.TakeFirst() #The ItemLoader class is used by default to load the items container class to fill the data. It is a list type. You can get the contents of the list through the TakeFirst () method +def tianjia(value): #Custom data preprocessing function + return value #Return the processed data to the Item. Currently the data processing is being done in spidey.py file so nothing special to write here, just returning the values here. + +bulk_lst=[] #for bulk indexing in ES using a list of documnets(i.e. list of Item with some extra fields) +host='localhost:9200' +ELASTIC_INDEX_NAME="iitd_sites" class CrawlingIitdItem(scrapy.Item): # define the fields for your item here like: - # name = scrapy.Field() - pass + title = scrapy.Field (#Receive title information obtained by the crawler + input_processor = itemloaders.processors.MapCompose(tianjia), #Demo of data processing application in fields of Item.Pass the data preprocessing function name into the MapCompose method for processing. The formal parameter value of the data preprocessing function will automatically receive the field title + ) + url = scrapy.Field () + body = scrapy.Field () + linked_urls = scrapy.Field () + linked_images = scrapy.Field () + meta_tags = scrapy.Field () + + def save_to_es (self,item): #function for saving the data stored in Item of every crawled webpage to ES + + #if-else coditions are required as some of the crawled urls(webpages) don't have some of the fields in their Item. + response_url = item["url"] + if "title" in item.keys(): + response_title=item["title"] + else: + response_title=item["body"][:10] + + response_body=item["body"] + + if "linked_images" in item.keys(): + response_images=item["linked_images"] + else: + response_images={"img":[]} + + if "linked_urls" in item.keys(): + response_links=item["linked_urls"] + else: + response_links={} + + if "meta_tags" in item.keys(): + response_meta=item["meta_tags"] + else: + response_meta="" + #print(item) + + es_client=Elasticsearch(host) + if not es_client.indices.exists(ELASTIC_INDEX_NAME): + es_client.indices.create(ELASTIC_INDEX_NAME)#initialise index with index_name=elastic_index_name + + es_client.indices.refresh(ELASTIC_INDEX_NAME) #to get the count of documents indexed in "iitd-sites" on ES, refreshing is required. + es_len=es_client.cat.count(ELASTIC_INDEX_NAME, params={"format": "json"}) + + if int(es_len[0]['count'])>100: #you can define total number of documents you want to index in ES + print("100 DOCUMENTS INDEXED--------------","\n") + os._exit(0) + + if not es_client.exists(index=ELASTIC_INDEX_NAME, id=response_url): + bulk_lst.append({"_index":"iitd_sites", + "_type":"_doc", + "_id":response_url, + "url":response_url, + "title":response_title, + "body":response_body, + "links":response_links, + "linked_images":response_images, + "meta_data":response_meta, + "visits":0 + }) + + if len(bulk_lst)>=10: + bulk(es_client,bulk_lst) + bulk_lst.clear() + return + else: + pass + \ No newline at end of file diff --git a/crawling__iitd/crawling__iitd/main.py b/crawling__iitd/crawling__iitd/main.py new file mode 100644 index 0000000..be11b46 --- /dev/null +++ b/crawling__iitd/crawling__iitd/main.py @@ -0,0 +1,7 @@ +import sys +import os +from scrapy.cmdline import execute #Import and execute scrapy command method + +sys.path.append (os.path.join (os.getcwd())) #Add a new path to the Python interpreter, add the directory where the main.py file is located to the Python interpreter +execute (['scrapy', 'crawl', 'IITD','--nolog']) #execute the scrapy command + diff --git a/crawling__iitd/crawling__iitd/mongo_creator.py b/crawling__iitd/crawling__iitd/mongo_creator.py deleted file mode 100644 index ef1c775..0000000 --- a/crawling__iitd/crawling__iitd/mongo_creator.py +++ /dev/null @@ -1,34 +0,0 @@ - -"""#dotenv not working properly therfore defined variables explicitly and removed import from config.py file.#""" - -from pymongo.mongo_client import MongoClient -from pymongo.collection import Collection -#import crawler.config as config - -MONGODB_URI="mongodb://localhost:27017" -#MONGODB_URI = os.getenv('MONGODB_URI') -if MONGODB_URI is None: - raise Exception('MONGODB_URI not set') - -#MONGO_DBNAME = os.getenv('MONGO_DBNAME', 'haystack') -#MONGO_COLLNAME = os.getenv('MONGO_COLLNAME', 'crawl_info') -MONGO_DBNAME='new_haystack' -MONGO_COLLNAME='crawl_info' - - -def getMongoCollection():# -> Collection: - client = MongoClient(host=MONGODB_URI) - db = client[MONGO_DBNAME] - collection = db[MONGO_COLLNAME] - return collection - -#ELASTIC_URI = os.getenv('ELASTIC_URI') -ELASTIC_URI ="localhost:9200" -if ELASTIC_URI is None: - raise Exception('ELASTIC_URI not set') -#ELASTIC_INDEX_NAME = os.getenv('ELASTIC_INDEX_NAME', 'iitd_sites') -ELASTIC_INDEX_NAME = "iit" - -mongo_collection=getMongoCollection() - - diff --git a/crawling__iitd/crawling__iitd/pipelines.py b/crawling__iitd/crawling__iitd/pipelines.py index 9c5bc62..a85107c 100644 --- a/crawling__iitd/crawling__iitd/pipelines.py +++ b/crawling__iitd/crawling__iitd/pipelines.py @@ -1,5 +1,4 @@ # Define your item pipelines here -# # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html @@ -8,6 +7,8 @@ from itemadapter import ItemAdapter -class CrawlingIitdPipeline: +class CrawlingIitdPipeline(object): def process_item(self, item, spider): + item.save_to_es(item) #Execute the save_to_es method of the items.py file to write data to the elasticsearch search engine return item + diff --git a/crawling__iitd/crawling__iitd/seeder.py b/crawling__iitd/crawling__iitd/seeder.py deleted file mode 100644 index d5dca76..0000000 --- a/crawling__iitd/crawling__iitd/seeder.py +++ /dev/null @@ -1,20 +0,0 @@ -from multiprocessing import Process, Queue, log_to_stderr -import signal -import logging -from crawling__iitd.config import MONGODB_URI, MONGO_DBNAME, MONGO_COLLNAME -from pymongo.mongo_client import MongoClient - -class Seeder(): - def __init__(self, mongo_collection, query=None) -> None: - if query is None: - query = { - "scraped": { - "$eq": False, - } - } - self.query = query - self.mongo_collection = mongo_collection - - def seed(self) -> None: - for doc in self.mongo_collection.find(self.query): - yield doc \ No newline at end of file diff --git a/crawling__iitd/crawling__iitd/settings.py b/crawling__iitd/crawling__iitd/settings.py index 00520ff..ea89f8d 100644 --- a/crawling__iitd/crawling__iitd/settings.py +++ b/crawling__iitd/crawling__iitd/settings.py @@ -19,16 +19,13 @@ # Obey robots.txt rules ROBOTSTXT_OBEY = True -#ITEM_PIPELINES={'scrapy.pipelines.images.ImagesPipeline':1} -#IMAGES_STORE='local_folder' - # Configure maximum concurrent requests performed by Scrapy (default: 16) #CONCURRENT_REQUESTS = 32 # Configure a delay for requests for the same website (default: 0) # See https://docs.scrapy.org/en/latest/topics/settings.html#download-delay # See also autothrottle settings and docs -#DOWNLOAD_DELAY = 3 +DOWNLOAD_DELAY = 4 # The download delay setting will honor only one of: #CONCURRENT_REQUESTS_PER_DOMAIN = 16 #CONCURRENT_REQUESTS_PER_IP = 16 @@ -65,22 +62,22 @@ # Configure item pipelines # See https://docs.scrapy.org/en/latest/topics/item-pipeline.html -#ITEM_PIPELINES = { -# 'crawling__iitd.pipelines.CrawlingIitdPipeline': 300, -#} +ITEM_PIPELINES = { + 'crawling__iitd.pipelines.CrawlingIitdPipeline': 300, +} # Enable and configure the AutoThrottle extension (disabled by default) # See https://docs.scrapy.org/en/latest/topics/autothrottle.html -#AUTOTHROTTLE_ENABLED = True +AUTOTHROTTLE_ENABLED = True # The initial download delay -#AUTOTHROTTLE_START_DELAY = 5 +AUTOTHROTTLE_START_DELAY = 5 # The maximum download delay to be set in case of high latencies -#AUTOTHROTTLE_MAX_DELAY = 60 +AUTOTHROTTLE_MAX_DELAY = 60 # The average number of requests Scrapy should be sending in parallel to # each remote server -#AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0 +AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0 # Enable showing throttling stats for every response received: -#AUTOTHROTTLE_DEBUG = False +AUTOTHROTTLE_DEBUG = True # Enable and configure HTTP caching (disabled by default) # See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings @@ -89,18 +86,3 @@ #HTTPCACHE_DIR = 'httpcache' #HTTPCACHE_IGNORE_HTTP_CODES = [] #HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage' -FEEDS={ - 'elastic':{ - 'format':'elastic' - - } -} -FEED_EXPORTERS = { - 'elastic': 'crawling__iitd.elastic_exporter.ElasticExporter' -} - -#for crawling in BFO -DEPTH_PRIORITY = 1 -SCHEDULER_DISK_QUEUE = 'scrapy.squeues.PickleFifoDiskQueue' -SCHEDULER_MEMORY_QUEUE = 'scrapy.squeues.FifoMemoryQueue' -SCHEDULER_PRIORITY_QUEUE='scrapy.pqueues.ScrapyPriorityQueue' diff --git a/crawling__iitd/crawling__iitd/spiders/spidey.py b/crawling__iitd/crawling__iitd/spiders/spidey.py index eae3d1a..9e01734 100644 --- a/crawling__iitd/crawling__iitd/spiders/spidey.py +++ b/crawling__iitd/crawling__iitd/spiders/spidey.py @@ -1,116 +1,160 @@ -import datetime -from scrapy import signals -from scrapy.http import Request, Response -from scrapy.spiders import CrawlSpider, Rule +#-*-coding: utf-8-*- +import scrapy +import sys +import re +import textract +from itertools import chain +from tempfile import NamedTemporaryFile +#sys.path.insert(0,'/Documents/haystack/new/crawling__iitd/elastic_eporter.py') from scrapy.linkextractors import LinkExtractor -from pymongo.collection import Collection, ReturnDocument -from crawling__iitd.seeder import Seeder -from crawling__iitd.mongo_creator import getMongoCollection +from scrapy.spiders import CrawlSpider, Rule +from crawling__iitd.items import CrawlingIitdItem, CrawlingIitdItemLoader +import time + +LST=[".pdf",".doc",".docx"] #the list can be extended to make crawler crawl links with another extensions +class CustomLinkExtractor(LinkExtractor): + def __init__(self,*args, **kwargs): + super(CustomLinkExtractor,self).__init__(*args,**kwargs) + self.deny_extensions=[ext for ext in self.deny_extensions if ext not in LST] #print self.deny_extensions to get the list of extension that cannot be crawled. -class IITDSpider(CrawlSpider): - name = "iitd" +class IITDSpider (CrawlSpider): + name = 'IITD' # crawler name allowed_domains = [ 'iitd.ac.in', 'iitd.ernet.in' ] - - rules = [ - Rule(LinkExtractor(), follow=True, callback="parse_item",process_request="process_request") - ] - - start_urls = [ - 'https://home.iitd.ac.in', - ] - - #start_request generates request for all links - def start_requests(self): - self.mongo_collection: Collection = getMongoCollection() - for url in self.start_urls: - doc = self.mongo_collection.find_one_and_update({"url": url}, {"$setOnInsert": { - "crawl_details": {}, - "scraped": False, - "indexed":False} - }, upsert=True, return_document=ReturnDocument.AFTER) - - #seeder returns the crawl_info collection...so that Request could be yielded for priviosly crawled links(doc). - #initially crawl_info does not contain any data ... - for doc in Seeder(self.mongo_collection).seed(): - url = doc['url'] - self.logger.info(f"Got {url} from seeder") - yield Request(url, meta={"mongo_doc": doc}) - - - def process_request(self, request: Request, response: Response): - self.logger.debug('Processing request') - print("--------------------------------------------","\n") - #newly visited links would not have mongo_doc in request.meta....so saving them in crawl_info ...once saved ...Request would be created for them and hence mongo_doc will then be present in request.meta - if "mongo_doc" not in request.meta: - request.meta["mongo_doc"] = self.mongo_collection.find_one_and_update({"url": request.url},{"$setOnInsert": { - "crawl_details": {}, - "scraped": False, - "indexed":False} - },upsert=True,return_document=ReturnDocument.AFTER) - - #Drop this request if it has already been crawled - # if len(request.meta["mongo_doc"]["crawl_details"]) != 0: - if request.meta["mongo_doc"]["scraped"]!=False: - return None - - return request - - # def parse_item(self, response): - # self.logger.info('Hello World Checking this function') - # item = { - # "request": response.request, - # "elastic_doc": { - # 'url': response.url, - # 'status': response.status, - # 'title': response.xpath("//title").get(), - # 'body': response.xpath("//body").get(), - # 'link_text': response.meta['link_text'], - # }, - # } - - # return item - - def parse_item(self,response) : - if response.status==200: - self.logger.info(f'Scraping Page with url {response.url}') + start_urls = ['https://home.iitd.ac.in/'] + + rules = ( + #Configure the crawl list page rule + Rule (CustomLinkExtractor(), callback="parse_job",follow = True), + + #Configure rules for crawling content pages + Rule (CustomLinkExtractor(), callback ="parse_job", follow = True),) + + def parse_job (self, response): + if hasattr(response, "text"): + + # The response is text - we assume html. + #atime = time.localtime (time.time ()) #Get the current system time + # dqatime = "{0}-{1}-{2} {3}: {4}: {5}". format ( + # atime.tm_year, + # atime.tm_mon, + # atime.tm_mday, + # atime.tm_hour, + # atime.tm_min, + # atime.tm_sec + # ) # The formatted date and time are taken out separately and stitched into a complete date + linked_images=response.css('img ::attr(src)').getall() + links_url=response.css('a::attr(href)').extract() + links_text=response.css('a::text').extract() + link_dict=self.extract_links(response,links_url,links_text) body=self.extract_body(response) - - link_img=response.css('img ::attr(src)').getall() - clean_link_img=[] - links=response.css('a') - links_url=links.css('::attr(href)').extract() - links_text=links.css('::text').extract() - remove='\n \t \f \r \b' - for text in links_text: - text=text.lstrip(remove) - text=text.rstrip(remove) - - for img in link_img: - clean_link_img.append(response.urljoin(img)) + clean_link_img={"img":[]} + for img in linked_images: + clean_link_img["img"].append(response.urljoin(img)) + whole_body='' + for i in body: + whole_body+=i + + url = response.url + print("-----------------------------------------","\n") + print(url) + print("-----------------------------------------",'\n') + item_loader = CrawlingIitdItemLoader(CrawlingIitdItem(), response = response) # Fill the data into the CrawlingIitdItem of the items.py file + item_loader.add_xpath('title', '/ html / head / title / text ()') + item_loader.add_value('url', url) + item_loader.add_value('body',whole_body) + item_loader.add_value('linked_urls', link_dict) + item_loader.add_value('linked_images',clean_link_img) + item_loader.add_css('meta_tags','meta') + #item_loader.add_value('riqi', dqatime) + article_item = item_loader.load_item () + + yield article_item + else: + + # We assume the response is binary data + control_chars = ''.join(map(chr, chain(range(0, 9), range(11, 32), range(127, 160)))) + CONTROL_CHAR_RE = re.compile('[%s]' % re.escape(control_chars)) + # One-liner for testing if "response.url" ends with any of TEXTRACT_EXTENSIONS + extension = list(filter(lambda x: response.url.lower().endswith(x), LST))[0] + if extension: + # This is a pdf or something else that Textract can process + # Create a temporary file with the correct extension. + tempfile = NamedTemporaryFile(suffix=extension) + tempfile.write(response.body) + tempfile.flush() + extracted_data = textract.process(tempfile.name) + extracted_data = extracted_data.decode('utf-8') + extracted_data = CONTROL_CHAR_RE.sub('', extracted_data) + tempfile.close() + + #for checking whether the pdf data is being stored or not. + # with open("scraped_content.txt", "a") as f: + # f.write(response.url.upper()) + # f.write("\n") + # f.write(extracted_data) + # f.write("\n\n") + + doc_link_dict={} + doc_clean_link_img={"img":[]} + doc_item_loader = CrawlingIitdItemLoader(CrawlingIitdItem()) # Fill the data into the CrawlingIitdItem of the items.py file + doc_item_loader.add_value('title', "PDF-"+extracted_data[0:8]) + doc_item_loader.add_value('linked_urls', doc_link_dict) + doc_item_loader.add_value('linked_images',doc_clean_link_img) + doc_item_loader.add_value('url', response.url) + doc_item_loader.add_value('body',extracted_data) - item = { - "url":response.url, - "status":response.status, - "title":response.css('title::text').get(), - "meta_data":response.css('meta').extract(), - "body":body, - "image_urls":clean_link_img, - "crawled_on":datetime.datetime.now(), - "links_url":links_url, - "links_text":links_text, + #item_loader.add_value('riqi', dqatime) + doc_article_item = doc_item_loader.load_item () + + yield doc_article_item + + def extract_links(self,response,links_url,links_text): + links={ + "pdf":[], + "ppt":[], + "text":[], + "spreadsheet":[], + "programs":[], + "webpages":[] } - # doc = self.mongo_collection.find_one_and_update({"url": response.url},{"$setOnInsert": {"crawl_details": item,"crawled_on": datetime.datetime.now()}},upsert=True,return_document=ReturnDocument.AFTER) - myquery = { 'url': response.url } - newvalues = { "$set": {'scraped':True } } - self.mongo_collection.update_one(myquery, newvalues) + + keys=["pdf","ppt","text","spreadsheet","programs"] + + formats=[ + [".pdf"], + [".pptx",".ppt",".pptm",".potx",".pot",".potm",".pps",".ppsm",".ppsx"], + [".docx",".txt",".doc",".docm"], + [".csv",".xla",".xls",".xlsm",".xlsx",".xlt","xltx","xltm"], + [".c",".cpp",".java",".py"] + ] + + for (text,link) in zip(links_text,links_url): + link=link.rstrip(' ') + link=link.lstrip(" ./") + if not link.startswith("http"): + link=response.url+"/"+link + found=False + index=0 + for x1 in formats: + key=keys[index] + index+=1 + for x2 in x1: + found=False + if link.endswith(x2): + found=True + links[key].append({"text":text,"link":link}) + break + if found: + break - yield item - else: - yield None + if not found: + links["webpages"].append({"text":text,"link":link}) + return links + def extract_body(self,response): body=[] @@ -170,4 +214,4 @@ def check_string(self,str): if(count<4): return -1 else: - return count + return count \ No newline at end of file diff --git a/crawling__iitd/elastic b/crawling__iitd/elastic deleted file mode 100644 index e69de29..0000000 diff --git a/node_modules/.yarn-integrity b/node_modules/.yarn-integrity new file mode 100644 index 0000000..51bb6a4 --- /dev/null +++ b/node_modules/.yarn-integrity @@ -0,0 +1,30 @@ +{ + "systemParams": "linux-x64-64", + "modulesFolders": [ + "node_modules" + ], + "flags": [], + "linkedModules": [], + "topLevelPatterns": [ + "html-react-parser@^1.2.7" + ], + "lockfileEntries": { + "dom-serializer@^1.0.1": "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-1.3.2.tgz#6206437d32ceefaec7161803230c7a20bc1b4d91", + "domelementtype@^2.0.1": "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.2.0.tgz#9a0b6c2782ed6a1c7323d42267183df9bd8b1d57", + "domelementtype@^2.2.0": "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.2.0.tgz#9a0b6c2782ed6a1c7323d42267183df9bd8b1d57", + "domhandler@4.2.0": "https://registry.yarnpkg.com/domhandler/-/domhandler-4.2.0.tgz#f9768a5f034be60a89a27c2e4d0f74eba0d8b059", + "domhandler@^4.0.0": "https://registry.yarnpkg.com/domhandler/-/domhandler-4.2.0.tgz#f9768a5f034be60a89a27c2e4d0f74eba0d8b059", + "domhandler@^4.2.0": "https://registry.yarnpkg.com/domhandler/-/domhandler-4.2.0.tgz#f9768a5f034be60a89a27c2e4d0f74eba0d8b059", + "domutils@^2.5.2": "https://registry.yarnpkg.com/domutils/-/domutils-2.7.0.tgz#8ebaf0c41ebafcf55b0b72ec31c56323712c5442", + "entities@^2.0.0": "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55", + "html-dom-parser@1.0.1": "https://registry.yarnpkg.com/html-dom-parser/-/html-dom-parser-1.0.1.tgz#5d147fed6656c12918edbcea4a423eefe8d0e715", + "html-react-parser@^1.2.7": "https://registry.yarnpkg.com/html-react-parser/-/html-react-parser-1.2.7.tgz#1674ed4b96b3440ad922962a3ff000e7f3325293", + "htmlparser2@6.1.0": "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-6.1.0.tgz#c4d762b6c3371a05dbe65e94ae43a9f845fb8fb7", + "inline-style-parser@0.1.1": "https://registry.yarnpkg.com/inline-style-parser/-/inline-style-parser-0.1.1.tgz#ec8a3b429274e9c0a1f1c4ffa9453a7fef72cea1", + "react-property@1.0.1": "https://registry.yarnpkg.com/react-property/-/react-property-1.0.1.tgz#4ae4211557d0a0ae050a71aa8ad288c074bea4e6", + "style-to-js@1.1.0": "https://registry.yarnpkg.com/style-to-js/-/style-to-js-1.1.0.tgz#631cbb20fce204019b3aa1fcb5b69d951ceac4ac", + "style-to-object@0.3.0": "https://registry.yarnpkg.com/style-to-object/-/style-to-object-0.3.0.tgz#b1b790d205991cc783801967214979ee19a76e46" + }, + "files": [], + "artifacts": {} +} \ No newline at end of file diff --git a/node_modules/dom-serializer/LICENSE b/node_modules/dom-serializer/LICENSE new file mode 100644 index 0000000..3d241a8 --- /dev/null +++ b/node_modules/dom-serializer/LICENSE @@ -0,0 +1,11 @@ +License + +(The MIT License) + +Copyright (c) 2014 The cheeriojs contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/dom-serializer/README.md b/node_modules/dom-serializer/README.md new file mode 100644 index 0000000..9ef0eec --- /dev/null +++ b/node_modules/dom-serializer/README.md @@ -0,0 +1,97 @@ +# dom-serializer [![Build Status](https://travis-ci.com/cheeriojs/dom-serializer.svg?branch=master)](https://travis-ci.com/cheeriojs/dom-serializer) + +Renders a [domhandler](https://github.com/fb55/domhandler) DOM node or an array of domhandler DOM nodes to a string. + +```js +import render from "dom-serializer"; + +// OR + +const render = require("dom-serializer").default; +``` + +# API + +## `render` + +▸ **render**(`node`: Node \| Node[], `options?`: [_Options_](#Options)): _string_ + +Renders a DOM node or an array of DOM nodes to a string. + +Can be thought of as the equivalent of the `outerHTML` of the passed node(s). + +#### Parameters: + +| Name | Type | Default value | Description | +| :-------- | :--------------------------------- | :------------ | :----------------------------- | +| `node` | Node \| Node[] | - | Node to be rendered. | +| `options` | [_DomSerializerOptions_](#Options) | {} | Changes serialization behavior | + +**Returns:** _string_ + +## Options + +### `decodeEntities` + +• `Optional` **decodeEntities**: _boolean_ + +Encode characters that are either reserved in HTML or XML, or are outside of the ASCII range. + +**`default`** true + +--- + +### `emptyAttrs` + +• `Optional` **emptyAttrs**: _boolean_ + +Print an empty attribute's value. + +**`default`** xmlMode + +**`example`** With emptyAttrs: false: <input checked> + +**`example`** With emptyAttrs: true: <input checked=""> + +--- + +### `selfClosingTags` + +• `Optional` **selfClosingTags**: _boolean_ + +Print self-closing tags for tags without contents. + +**`default`** xmlMode + +**`example`** With selfClosingTags: false: <foo></foo> + +**`example`** With selfClosingTags: true: <foo /> + +--- + +### `xmlMode` + +• `Optional` **xmlMode**: _boolean_ \| _"foreign"_ + +Treat the input as an XML document; enables the `emptyAttrs` and `selfClosingTags` options. + +If the value is `"foreign"`, it will try to correct mixed-case attribute names. + +**`default`** false + +--- + +## Ecosystem + +| Name | Description | +| ------------------------------------------------------------- | ------------------------------------------------------- | +| [htmlparser2](https://github.com/fb55/htmlparser2) | Fast & forgiving HTML/XML parser | +| [domhandler](https://github.com/fb55/domhandler) | Handler for htmlparser2 that turns documents into a DOM | +| [domutils](https://github.com/fb55/domutils) | Utilities for working with domhandler's DOM | +| [css-select](https://github.com/fb55/css-select) | CSS selector engine, compatible with domhandler's DOM | +| [cheerio](https://github.com/cheeriojs/cheerio) | The jQuery API for domhandler's DOM | +| [dom-serializer](https://github.com/cheeriojs/dom-serializer) | Serializer for domhandler's DOM | + +--- + +LICENSE: MIT diff --git a/node_modules/dom-serializer/package.json b/node_modules/dom-serializer/package.json new file mode 100644 index 0000000..942931e --- /dev/null +++ b/node_modules/dom-serializer/package.json @@ -0,0 +1,55 @@ +{ + "name": "dom-serializer", + "version": "1.3.2", + "description": "render domhandler DOM nodes to a string", + "author": "Felix Boehm ", + "sideEffects": false, + "keywords": [ + "html", + "xml", + "render" + ], + "repository": { + "type": "git", + "url": "git://github.com/cheeriojs/dom-renderer.git" + }, + "main": "lib/index.js", + "types": "lib/index.d.ts", + "files": [ + "lib/**/*" + ], + "dependencies": { + "domelementtype": "^2.0.1", + "domhandler": "^4.2.0", + "entities": "^2.0.0" + }, + "devDependencies": { + "@types/jest": "^26.0.23", + "@types/node": "^15.3.0", + "@typescript-eslint/eslint-plugin": "^4.23.0", + "@typescript-eslint/parser": "^4.23.0", + "cheerio": "^1.0.0-rc.9", + "coveralls": "^3.0.5", + "eslint": "^7.26.0", + "eslint-config-prettier": "^8.3.0", + "htmlparser2": "^6.1.0", + "jest": "^26.0.1", + "prettier": "^2.3.0", + "ts-jest": "^26.5.6", + "typescript": "^4.0.2" + }, + "scripts": { + "test": "jest --coverage && npm run lint", + "coverage": "cat coverage/lcov.info | coveralls", + "lint": "eslint src", + "format": "prettier --write '**/*.{ts,md,json}'", + "build": "tsc", + "prepare": "npm run build" + }, + "jest": { + "preset": "ts-jest", + "testEnvironment": "node" + }, + "funding": "https://github.com/cheeriojs/dom-serializer?sponsor=1", + "license": "MIT" +} diff --git a/node_modules/domelementtype/LICENSE b/node_modules/domelementtype/LICENSE new file mode 100644 index 0000000..c464f86 --- /dev/null +++ b/node_modules/domelementtype/LICENSE @@ -0,0 +1,11 @@ +Copyright (c) Felix Böhm +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/domelementtype/package.json b/node_modules/domelementtype/package.json new file mode 100644 index 0000000..eb62c29 --- /dev/null +++ b/node_modules/domelementtype/package.json @@ -0,0 +1,45 @@ +{ + "name": "domelementtype", + "version": "2.2.0", + "description": "all the types of nodes in htmlparser2's dom", + "author": "Felix Boehm ", + "license": "BSD-2-Clause", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "sideEffects": false, + "main": "lib/index.js", + "types": "lib/index.d.ts", + "files": [ + "lib/**/*" + ], + "repository": { + "type": "git", + "url": "git://github.com/fb55/domelementtype.git" + }, + "keywords": [ + "dom", + "htmlparser2" + ], + "scripts": { + "test": "npm run lint && prettier --check **/*.{ts,json,md}", + "lint": "eslint src", + "format": "prettier --write **/*.{ts,json,md}", + "build": "tsc", + "prepare": "npm run build" + }, + "prettier": { + "tabWidth": 4 + }, + "devDependencies": { + "@typescript-eslint/eslint-plugin": "^4.1.0", + "@typescript-eslint/parser": "^4.1.0", + "eslint": "^7.9.0", + "eslint-config-prettier": "^6.0.0", + "prettier": "^2.1.1", + "typescript": "^4.0.2" + } +} diff --git a/node_modules/domelementtype/readme.md b/node_modules/domelementtype/readme.md new file mode 100644 index 0000000..4eadc07 --- /dev/null +++ b/node_modules/domelementtype/readme.md @@ -0,0 +1 @@ +All the types of nodes in htmlparser2's DOM. diff --git a/node_modules/domhandler/LICENSE b/node_modules/domhandler/LICENSE new file mode 100644 index 0000000..c464f86 --- /dev/null +++ b/node_modules/domhandler/LICENSE @@ -0,0 +1,11 @@ +Copyright (c) Felix Böhm +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/domhandler/package.json b/node_modules/domhandler/package.json new file mode 100644 index 0000000..0ecf57b --- /dev/null +++ b/node_modules/domhandler/package.json @@ -0,0 +1,59 @@ +{ + "name": "domhandler", + "version": "4.2.0", + "description": "Handler for htmlparser2 that turns pages into a dom", + "author": "Felix Boehm ", + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + }, + "license": "BSD-2-Clause", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "sideEffects": false, + "files": [ + "lib" + ], + "scripts": { + "test": "jest --coverage && npm run lint", + "coverage": "cat coverage/lcov.info | coveralls", + "lint": "eslint src", + "format": "prettier --write '**/*.{ts,md,json}'", + "build": "tsc", + "prepare": "npm run build" + }, + "repository": { + "type": "git", + "url": "git://github.com/fb55/domhandler.git" + }, + "keywords": [ + "dom", + "htmlparser2" + ], + "engines": { + "node": ">= 4" + }, + "dependencies": { + "domelementtype": "^2.2.0" + }, + "devDependencies": { + "@types/jest": "^26.0.0", + "@types/node": "^14.0.9", + "@typescript-eslint/eslint-plugin": "^4.1.0", + "@typescript-eslint/parser": "^4.1.0", + "coveralls": "^3.0.5", + "eslint": "^7.9.0", + "eslint-config-prettier": "^8.1.0", + "htmlparser2": "^6.0.0", + "jest": "^26.0.1", + "prettier": "^2.0.5", + "ts-jest": "^26.1.0", + "typescript": "^4.0.2" + }, + "jest": { + "preset": "ts-jest", + "testEnvironment": "node" + }, + "prettier": { + "tabWidth": 4 + } +} diff --git a/node_modules/domhandler/readme.md b/node_modules/domhandler/readme.md new file mode 100644 index 0000000..781eb38 --- /dev/null +++ b/node_modules/domhandler/readme.md @@ -0,0 +1,163 @@ +# domhandler [![Build Status](https://travis-ci.com/fb55/domhandler.svg?branch=master)](https://travis-ci.com/fb55/domhandler) + +The DOM handler creates a tree containing all nodes of a page. +The tree can be manipulated using the [domutils](https://github.com/fb55/domutils) +or [cheerio](https://github.com/cheeriojs/cheerio) libraries and +rendered using [dom-serializer](https://github.com/cheeriojs/dom-serializer) . + +## Usage + +```javascript +const handler = new DomHandler([ callback(err, dom), ] [ options ]); +// const parser = new Parser(handler[, options]); +``` + +Available options are described below. + +## Example + +```javascript +const { Parser } = require("htmlparser2"); +const { DomHandler } = require("domhandler"); +const rawHtml = + "Xyz "; +const handler = new DomHandler((error, dom) => { + if (error) { + // Handle error + } else { + // Parsing completed, do something + console.log(dom); + } +}); +const parser = new Parser(handler); +parser.write(rawHtml); +parser.end(); +``` + +Output: + +```javascript +[ + { + data: "Xyz ", + type: "text", + }, + { + type: "script", + name: "script", + attribs: { + language: "javascript", + }, + children: [ + { + data: "var foo = '';<", + type: "text", + }, + ], + }, + { + data: " + + + +``` + +## Usage + +Import or require the module: + +```js +// ES Modules +import parse from 'html-react-parser'; + +// CommonJS +const parse = require('html-react-parser'); +``` + +Parse single element: + +```js +parse('

single

'); +``` + +Parse multiple elements: + +```js +parse('
  • Item 1
  • Item 2
  • '); +``` + +Make sure to render parsed adjacent elements under a parent element: + +```jsx +
      + {parse(` +
    • Item 1
    • +
    • Item 2
    • + `)} +
    +``` + +Parse nested elements: + +```js +parse('

    Lorem ipsum

    '); +``` + +Parse element with attributes: + +```js +parse( + '
    ' +); +``` + +### replace + +The `replace` option allows you to replace an element with another element. + +The `replace` callback's first argument is [domhandler](https://github.com/fb55/domhandler#example)'s node: + +```js +parse('
    ', { + replace: domNode => { + console.dir(domNode, { depth: null }); + } +}); +``` + +Console output: + +```js +Element { + type: 'tag', + parent: null, + prev: null, + next: null, + startIndex: null, + endIndex: null, + children: [], + name: 'br', + attribs: {} +} +``` + +The element is replaced if a **valid** React element is returned: + +```jsx +parse('

    text

    ', { + replace: domNode => { + if (domNode.attribs && domNode.attribs.id === 'replace') { + return replaced; + } + } +}); +``` + +#### replace with TypeScript + +For TypeScript projects, you may need to check that `domNode` is an instance of domhandler's `Element`: + +```tsx +import { HTMLReactParserOptions } from 'html-react-parser'; +import { Element } from 'domhandler/lib/node'; + +const options: HTMLReactParserOptions = { + replace: domNode => { + if (domNode instanceof Element && domNode.attribs) { + // ... + } + } +}; +``` + +If you're having issues with `domNode instanceof Element`, try this [alternative solution](https://github.com/remarkablemark/html-react-parser/issues/221#issuecomment-771600574). + +#### replace element and children + +Replace the element and its children (see [demo](https://repl.it/@remarkablemark/html-react-parser-replace-example)): + +```jsx +import parse, { domToReact } from 'html-react-parser'; + +const html = ` +

    + + keep me and make me pretty! + +

    +`; + +const options = { + replace: ({ attribs, children }) => { + if (!attribs) { + return; + } + + if (attribs.id === 'main') { + return

    {domToReact(children, options)}

    ; + } + + if (attribs.class === 'prettify') { + return ( + + {domToReact(children, options)} + + ); + } + } +}; + +parse(html, options); +``` + +HTML output: + + + +```html +

    + + keep me and make me pretty! + +

    +``` + + + +#### replace element attributes + +Convert DOM attributes to React props with `attributesToProps`: + +```jsx +import parse, { attributesToProps } from 'html-react-parser'; + +const html = ` +
    +`; + +const options = { + replace: domNode => { + if (domNode.attribs && domNode.name === 'main') { + const props = attributesToProps(domNode.attribs); + return
    ; + } + } +}; + +parse(html, options); +``` + +HTML output: + +```html +
    +``` + +#### replace and remove element + +[Exclude](https://repl.it/@remarkablemark/html-react-parser-56) an element from rendering by replacing it with ``: + +```jsx +parse('


    ', { + replace: ({ attribs }) => attribs && attribs.id === 'remove' && <> +}); +``` + +HTML output: + +```html +

    +``` + +### library + +The `library` option specifies the UI library. The default library is **React**. + +To use Preact: + +```js +parse('
    ', { + library: require('preact') +}); +``` + +Or a custom library: + +```js +parse('
    ', { + library: { + cloneElement: () => { + /* ... */ + }, + createElement: () => { + /* ... */ + }, + isValidElement: () => { + /* ... */ + } + } +}); +``` + +### htmlparser2 + +> `htmlparser2` options **do not work on the client-side** (browser) and **only works on the server-side** (Node.js). By overriding `htmlparser2` options, universal rendering can break. + +Default [htmlparser2 options](https://github.com/fb55/htmlparser2/wiki/Parser-options#option-xmlmode) can be overridden in >=[0.12.0](https://github.com/remarkablemark/html-react-parser/tree/v0.12.0). + +To enable [`xmlMode`](https://github.com/fb55/htmlparser2/wiki/Parser-options#option-xmlmode): + +```js +parse('

    ', { + htmlparser2: { + xmlMode: true + } +}); +``` + +### trim + +By default, whitespace is preserved: + +```js +parse('
    \n'); // [React.createElement('br'), '\n'] +``` + +To remove whitespace, enable the `trim` option: + +```js +parse('
    \n', { trim: true }); // React.createElement('br') +``` + +This fixes the warning: + +``` +Warning: validateDOMNesting(...): Whitespace text nodes cannot appear as a child of . Make sure you don't have any extra whitespace between tags on each line of your source code. +``` + +However, intentional whitespace may be stripped out: + +```js +parse('

    ', { trim: true }); // React.createElement('p') +``` + +## Migration + +### v1.0.0 + +TypeScript projects will need to update the types in [v1.0.0](https://github.com/remarkablemark/html-react-parser/releases/tag/v1.0.0). + +For the `replace` option, you may need to do the following: + +```tsx +import { Element } from 'domhandler/lib/node'; + +parse('
    ', { + replace: domNode => { + if (domNode instanceof Element && domNode.attribs.class === 'remove') { + return <>; + } + } +}); +``` + +Since [v1.1.1](https://github.com/remarkablemark/html-react-parser/releases/tag/v1.1.1), Internet Explorer 9 (IE9) is no longer supported. + +## FAQ + +### Is this XSS safe? + +No, this library is _**not**_ [XSS (cross-site scripting)](https://wikipedia.org/wiki/Cross-site_scripting) safe. See [#94](https://github.com/remarkablemark/html-react-parser/issues/94). + +### Does invalid HTML get sanitized? + +No, this library does _**not**_ sanitize HTML. See [#124](https://github.com/remarkablemark/html-react-parser/issues/124), [#125](https://github.com/remarkablemark/html-react-parser/issues/125), and [#141](https://github.com/remarkablemark/html-react-parser/issues/141). + +### Are ` + +``` + +## Usage + +Import the module: + +```js +// CommonJS +const parse = require('inline-style-parser'); + +// ES Modules +import parse from 'inline-style-parser'; +``` + +Parse single declaration: + +```js +parse('left: 0'); +``` + +Output: + +```js +[ + { + type: 'declaration', + property: 'left', + value: '0', + position: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 8 }, + source: undefined + } + } +] +``` + +Parse multiple declarations: + +```js +parse('left: 0; right: 100px;'); +``` + +Output: + +```js +[ + { + type: 'declaration', + property: 'left', + value: '0', + position: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 8 }, + source: undefined + } + }, + { + type: 'declaration', + property: 'right', + value: '100px', + position: { + start: { line: 1, column: 10 }, + end: { line: 1, column: 22 }, + source: undefined + } + } +] +``` + +Parse declaration with missing value: + +```js +parse('top:'); +``` + +Output: + +```js +[ + { + type: 'declaration', + property: 'top', + value: '', + position: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 5 }, + source: undefined + } + } +] +``` + +Parse unknown declaration: + +```js +parse('answer: 42;'); +``` + +Output: + +```js +[ + { + type: 'declaration', + property: 'answer', + value: '42', + position: { + start: { line: 1, column: 1 }, + end: { line: 1, column: 11 }, + source: undefined + } + } +] +``` + +Invalid declarations: + +```js +parse(''); // [] +parse(); // throws TypeError +parse(1); // throws TypeError +parse('width'); // throws Error +parse('/*'); // throws Error +``` + +## Testing + +Run tests: + +```sh +$ npm test +``` + +Run tests in watch mode: + +```sh +$ npm run test:watch +``` + +Run tests with coverage: + +```sh +$ npm run test:coverage +``` + +Run tests in CI mode: + +```sh +$ npm run test:ci +``` + +Lint files: + +```sh +$ npm run lint +``` + +Fix lint errors: + +```sh +$ npm run lint:fix +``` + +## Release + +Only collaborators with credentials can release and publish: + +```sh +$ npm run release +$ git push --follow-tags && npm publish +``` + +## License + +MIT. See [license](https://github.com/reworkcss/css/blob/v2.2.4/LICENSE) from original project. diff --git a/node_modules/inline-style-parser/index.js b/node_modules/inline-style-parser/index.js new file mode 100644 index 0000000..a32ca54 --- /dev/null +++ b/node_modules/inline-style-parser/index.js @@ -0,0 +1,261 @@ +// http://www.w3.org/TR/CSS21/grammar.html +// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027 +var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g; + +var NEWLINE_REGEX = /\n/g; +var WHITESPACE_REGEX = /^\s*/; + +// declaration +var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/; +var COLON_REGEX = /^:\s*/; +var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/; +var SEMICOLON_REGEX = /^[;\s]*/; + +// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill +var TRIM_REGEX = /^\s+|\s+$/g; + +// strings +var NEWLINE = '\n'; +var FORWARD_SLASH = '/'; +var ASTERISK = '*'; +var EMPTY_STRING = ''; + +// types +var TYPE_COMMENT = 'comment'; +var TYPE_DECLARATION = 'declaration'; + +/** + * @param {String} style + * @param {Object} [options] + * @return {Object[]} + * @throws {TypeError} + * @throws {Error} + */ +module.exports = function(style, options) { + if (typeof style !== 'string') { + throw new TypeError('First argument must be a string'); + } + + if (!style) return []; + + options = options || {}; + + /** + * Positional. + */ + var lineno = 1; + var column = 1; + + /** + * Update lineno and column based on `str`. + * + * @param {String} str + */ + function updatePosition(str) { + var lines = str.match(NEWLINE_REGEX); + if (lines) lineno += lines.length; + var i = str.lastIndexOf(NEWLINE); + column = ~i ? str.length - i : column + str.length; + } + + /** + * Mark position and patch `node.position`. + * + * @return {Function} + */ + function position() { + var start = { line: lineno, column: column }; + return function(node) { + node.position = new Position(start); + whitespace(); + return node; + }; + } + + /** + * Store position information for a node. + * + * @constructor + * @property {Object} start + * @property {Object} end + * @property {undefined|String} source + */ + function Position(start) { + this.start = start; + this.end = { line: lineno, column: column }; + this.source = options.source; + } + + /** + * Non-enumerable source string. + */ + Position.prototype.content = style; + + var errorsList = []; + + /** + * Error `msg`. + * + * @param {String} msg + * @throws {Error} + */ + function error(msg) { + var err = new Error( + options.source + ':' + lineno + ':' + column + ': ' + msg + ); + err.reason = msg; + err.filename = options.source; + err.line = lineno; + err.column = column; + err.source = style; + + if (options.silent) { + errorsList.push(err); + } else { + throw err; + } + } + + /** + * Match `re` and return captures. + * + * @param {RegExp} re + * @return {undefined|Array} + */ + function match(re) { + var m = re.exec(style); + if (!m) return; + var str = m[0]; + updatePosition(str); + style = style.slice(str.length); + return m; + } + + /** + * Parse whitespace. + */ + function whitespace() { + match(WHITESPACE_REGEX); + } + + /** + * Parse comments. + * + * @param {Object[]} [rules] + * @return {Object[]} + */ + function comments(rules) { + var c; + rules = rules || []; + while ((c = comment())) { + if (c !== false) { + rules.push(c); + } + } + return rules; + } + + /** + * Parse comment. + * + * @return {Object} + * @throws {Error} + */ + function comment() { + var pos = position(); + if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return; + + var i = 2; + while ( + EMPTY_STRING != style.charAt(i) && + (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1)) + ) { + ++i; + } + i += 2; + + if (EMPTY_STRING === style.charAt(i - 1)) { + return error('End of comment missing'); + } + + var str = style.slice(2, i - 2); + column += 2; + updatePosition(str); + style = style.slice(i); + column += 2; + + return pos({ + type: TYPE_COMMENT, + comment: str + }); + } + + /** + * Parse declaration. + * + * @return {Object} + * @throws {Error} + */ + function declaration() { + var pos = position(); + + // prop + var prop = match(PROPERTY_REGEX); + if (!prop) return; + comment(); + + // : + if (!match(COLON_REGEX)) return error("property missing ':'"); + + // val + var val = match(VALUE_REGEX); + + var ret = pos({ + type: TYPE_DECLARATION, + property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)), + value: val + ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING)) + : EMPTY_STRING + }); + + // ; + match(SEMICOLON_REGEX); + + return ret; + } + + /** + * Parse declarations. + * + * @return {Object[]} + */ + function declarations() { + var decls = []; + + comments(decls); + + // declarations + var decl; + while ((decl = declaration())) { + if (decl !== false) { + decls.push(decl); + comments(decls); + } + } + + return decls; + } + + whitespace(); + return declarations(); +}; + +/** + * Trim `str`. + * + * @param {String} str + * @return {String} + */ +function trim(str) { + return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING; +} diff --git a/node_modules/inline-style-parser/package.json b/node_modules/inline-style-parser/package.json new file mode 100644 index 0000000..611101c --- /dev/null +++ b/node_modules/inline-style-parser/package.json @@ -0,0 +1,55 @@ +{ + "name": "inline-style-parser", + "version": "0.1.1", + "description": "An inline style parser.", + "main": "index.js", + "scripts": { + "build": "npm run clean && npm run build:min && npm run build:unmin", + "build:min": "NODE_ENV=production rollup --config --output.file dist/inline-style-parser.min.js --sourcemap", + "build:unmin": "NODE_ENV=development rollup --config --file dist/inline-style-parser.js", + "clean": "rm -rf dist", + "coveralls": "cat coverage/lcov.info | coveralls", + "lint": "eslint --ignore-path .gitignore .", + "lint:fix": "npm run lint -- --fix", + "prepublishOnly": "npm run build", + "release": "standard-version --no-verify", + "test": "jest", + "test:ci": "npm run test:coverage -- --ci", + "test:coverage": "jest --coverage --collectCoverageFrom=index.js", + "test:watch": "jest --watch" + }, + "repository": { + "type": "git", + "url": "https://github.com/remarkablemark/inline-style-parser" + }, + "bugs": { + "url": "https://github.com/remarkablemark/inline-style-parser/issues" + }, + "keywords": [ + "inline-style-parser", + "inline-style", + "style", + "parser", + "css" + ], + "devDependencies": { + "@commitlint/cli": "^8.0.0", + "@commitlint/config-conventional": "^8.0.0", + "coveralls": "^3.0.4", + "css": "2.2.4", + "eslint": "^5.16.0", + "eslint-plugin-prettier": "^3.1.0", + "husky": "^2.4.1", + "jest": "^24.8.0", + "lint-staged": "^8.2.1", + "prettier": "^1.18.2", + "rollup": "^1.15.6", + "rollup-plugin-commonjs": "^10.0.0", + "rollup-plugin-uglify": "^6.0.2", + "standard-version": "^6.0.1" + }, + "files": [ + "/dist" + ], + "license": "MIT" +} diff --git a/node_modules/react-property/CHANGELOG.md b/node_modules/react-property/CHANGELOG.md new file mode 100644 index 0000000..44f4e1e --- /dev/null +++ b/node_modules/react-property/CHANGELOG.md @@ -0,0 +1,54 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [1.0.1](https://github.com/remarkablemark/react-dom-core/compare/react-property@1.0.0...react-property@1.0.1) (2019-07-09) + +**Note:** Version bump only for package react-property + + + + + +# [1.0.0](https://github.com/remarkablemark/react-dom-core/compare/react-property@0.1.0...react-property@1.0.0) (2019-07-09) + + +### Features + +* **react-property:** add script to build injection json ([2de3da9](https://github.com/remarkablemark/react-dom-core/commit/2de3da9)) +* **react-property:** consolidate injection logic to `index.js` ([167887f](https://github.com/remarkablemark/react-dom-core/commit/167887f)) +* **react-property:** export html and svg property configs ([8f8b921](https://github.com/remarkablemark/react-dom-core/commit/8f8b921)) +* **react-property:** rewrite build html script ([a44567a](https://github.com/remarkablemark/react-dom-core/commit/a44567a)) +* **react-property:** rewrite build svg script ([eb7a59b](https://github.com/remarkablemark/react-dom-core/commit/eb7a59b)) + + +### BREAKING CHANGES + +* **react-property:** remove exports `HTMLDOMPropertyConfig` and +`SVGDOMPropertyConfig` and consolidate the properties in +`properties`. + +As a result of this change, `src/` directory is removed since all +the injection logic is handled in `index.js` and the npm script +`copy` is removed as well. + + + + + +# 0.1.0 (2019-07-05) + + +### Features + +* **react-property:** add `index.js` that imports all files in lib ([08d4ba2](https://github.com/remarkablemark/react-dom-core/commit/08d4ba2)) +* **react-property:** add build script for SVG DOM config ([182326a](https://github.com/remarkablemark/react-dom-core/commit/182326a)) +* **react-property:** add module that exports `isCustomAttribute` ([4213cbd](https://github.com/remarkablemark/react-dom-core/commit/4213cbd)) +* **react-property:** add module that exports HTML DOM attribute map ([925db59](https://github.com/remarkablemark/react-dom-core/commit/925db59)) +* **react-property:** add module that exports SVG DOM attribute map ([b6501b3](https://github.com/remarkablemark/react-dom-core/commit/b6501b3)) +* **react-property:** add script that builds HTML attributes (JSON) ([c5349b8](https://github.com/remarkablemark/react-dom-core/commit/c5349b8)) +* **react-property:** build HTML overloaded boolean properties JSON ([ab7e2c2](https://github.com/remarkablemark/react-dom-core/commit/ab7e2c2)) +* **react-property:** build HTML props with boolean values (JSON) ([329593c](https://github.com/remarkablemark/react-dom-core/commit/329593c)) +* **react-property:** throw error if mkdir fails in build scripts ([1566b2f](https://github.com/remarkablemark/react-dom-core/commit/1566b2f)) +* **react-property:** update script to build HTML attr to prop JSON ([f09374d](https://github.com/remarkablemark/react-dom-core/commit/f09374d)) diff --git a/node_modules/react-property/README.md b/node_modules/react-property/README.md new file mode 100644 index 0000000..5ed4875 --- /dev/null +++ b/node_modules/react-property/README.md @@ -0,0 +1,77 @@ +# react-property + +[![NPM](https://nodei.co/npm/react-property.png)](https://nodei.co/npm/react-property/) + +[![NPM version](https://img.shields.io/npm/v/react-property.svg)](https://www.npmjs.com/package/react-property) + +HTML and SVG DOM property configs used by React. + +## Install + +```sh +# with npm +$ npm install react-property --save + +# with yarn +$ yarn add react-property +``` + +## Usage + +Import main module: + +```js +// CommonJS +const reactProperty = require('react-property'); + +// ES Modules +import reactProperty from 'react-property'; +``` + +Main module exports: + +```js +{ + html: { + autofocus: { + attributeName: 'autofocus', + propertyName: 'autoFocus', + mustUseProperty: false, + hasBooleanValue: true, + hasNumericValue: false, + hasPositiveNumericValue: false, + hasOverloadedBooleanValue: false + }, + // ... + }, + svg: { + // ... + }, + properties: { + // ... + }, + isCustomAttribute: [Function: bound test] +} +``` + +You may also import what you need: + +```js +const HTMLDOMPropertyConfig = require('react-property/lib/HTMLDOMPropertyConfig'); +const injection = require('react-property/lib/injection'); +``` + +## Layout + +``` +. +├── index.js +└── lib +    ├── HTMLDOMPropertyConfig.js +    ├── SVGDOMPropertyConfig.js +    └── injection.js +``` + +## License + +MIT. See [license](https://github.com/facebook/react/blob/15-stable/LICENSE) from original project. diff --git a/node_modules/react-property/index.js b/node_modules/react-property/index.js new file mode 100644 index 0000000..86ce4ab --- /dev/null +++ b/node_modules/react-property/index.js @@ -0,0 +1,106 @@ +var HTMLDOMPropertyConfig = require('./lib/HTMLDOMPropertyConfig'); +var SVGDOMPropertyConfig = require('./lib/SVGDOMPropertyConfig'); +var injection = require('./lib/injection'); + +var MUST_USE_PROPERTY = injection.MUST_USE_PROPERTY; +var HAS_BOOLEAN_VALUE = injection.HAS_BOOLEAN_VALUE; +var HAS_NUMERIC_VALUE = injection.HAS_NUMERIC_VALUE; +var HAS_POSITIVE_NUMERIC_VALUE = injection.HAS_POSITIVE_NUMERIC_VALUE; +var HAS_OVERLOADED_BOOLEAN_VALUE = injection.HAS_OVERLOADED_BOOLEAN_VALUE; + +/** + * @see https://github.com/facebook/react/blob/15-stable/src/renderers/dom/shared/DOMProperty.js#L14-L16 + * + * @param {Number} value + * @param {Number} bitmask + * @return {Boolean} + */ +function checkMask(value, bitmask) { + return (value & bitmask) === bitmask; +} + +/** + * @see https://github.com/facebook/react/blob/15-stable/src/renderers/dom/shared/DOMProperty.js#L57 + * + * @param {Object} domPropertyConfig - HTMLDOMPropertyConfig or SVGDOMPropertyConfig + * @param {Object} config - The object to be mutated + * @param {Boolean} isSVG - Whether the injected config is HTML or SVG (it assumes the default is HTML) + */ +function injectDOMPropertyConfig(domPropertyConfig, config, isSVG) { + var Properties = domPropertyConfig.Properties; + var DOMAttributeNames = domPropertyConfig.DOMAttributeNames; + var attributeName; + var propertyName; + var propConfig; + + for (propertyName in Properties) { + attributeName = + DOMAttributeNames[propertyName] || + (isSVG ? propertyName : propertyName.toLowerCase()); + propConfig = Properties[propertyName]; + + config[attributeName] = { + attributeName: attributeName, + propertyName: propertyName, + mustUseProperty: checkMask(propConfig, MUST_USE_PROPERTY), + hasBooleanValue: checkMask(propConfig, HAS_BOOLEAN_VALUE), + hasNumericValue: checkMask(propConfig, HAS_NUMERIC_VALUE), + hasPositiveNumericValue: checkMask( + propConfig, + HAS_POSITIVE_NUMERIC_VALUE + ), + hasOverloadedBooleanValue: checkMask( + propConfig, + HAS_OVERLOADED_BOOLEAN_VALUE + ) + }; + } +} + +/** + * HTML properties config. + * + * @type {Object} + */ +var html = {}; +injectDOMPropertyConfig(HTMLDOMPropertyConfig, html); + +/** + * SVG properties config. + * + * @type {Object} + */ +var svg = {}; +injectDOMPropertyConfig(SVGDOMPropertyConfig, svg, true); + +/** + * HTML and SVG properties config. + * + * @type {Object} + */ +var properties = {}; +injectDOMPropertyConfig(HTMLDOMPropertyConfig, properties); +injectDOMPropertyConfig(SVGDOMPropertyConfig, properties, true); + +var ATTRIBUTE_NAME_START_CHAR = + ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD'; +var ATTRIBUTE_NAME_CHAR = + ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040'; + +module.exports = { + html: html, + svg: svg, + properties: properties, + + /** + * Checks whether a property name is a custom attribute. + * + * @see https://github.com/facebook/react/blob/15-stable/src/renderers/dom/shared/HTMLDOMPropertyConfig.js#L23-L25 + * + * @param {String} + * @return {Boolean} + */ + isCustomAttribute: RegExp.prototype.test.bind( + new RegExp('^(data|aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$') + ) +}; diff --git a/node_modules/react-property/package.json b/node_modules/react-property/package.json new file mode 100644 index 0000000..0fb6e47 --- /dev/null +++ b/node_modules/react-property/package.json @@ -0,0 +1,48 @@ +{ + "name": "react-property", + "version": "1.0.1", + "description": "HTML and SVG DOM property configs used by React.", + "main": "index.js", + "scripts": { + "build": "npm run clean && npm run build:html && npm run build:injection && npm run build:svg", + "build:html": "node scripts/build-html", + "build:injection": "node scripts/build-injection", + "build:svg": "node scripts/build-svg", + "clean": "rm -rf lib", + "lint": "eslint .", + "lint:fix": "eslint . --fix", + "prepublishOnly": "npm run build", + "test": "jest --coverage --ci", + "test:watch": "jest --watch" + }, + "repository": { + "type": "git", + "url": "https://github.com/remarkablemark/react-dom-core" + }, + "bugs": { + "url": "https://github.com/remarkablemark/react-dom-core/issues" + }, + "keywords": [ + "react-property", + "html", + "svg", + "dom", + "property", + "attribute", + "config", + "react", + "react-dom" + ], + "files": [ + "/lib" + ], + "devDependencies": { + "eslint": "^6.0.1", + "eslint-plugin-prettier": "^3.1.0", + "jest": "^24.8.0", + "prettier": "^1.17.1", + "react-dom": "^15" + }, + "license": "MIT", + "gitHead": "46a7edbdf7d10138dd2fd348bd32175e3865392e" +} diff --git a/node_modules/style-to-js/CHANGELOG.md b/node_modules/style-to-js/CHANGELOG.md new file mode 100644 index 0000000..f3d0f8b --- /dev/null +++ b/node_modules/style-to-js/CHANGELOG.md @@ -0,0 +1,27 @@ +# Changelog + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [1.1.0](https://github.com/remarkablemark/style-to-js/compare/v1.0.0...v1.1.0) (2020-11-22) + + +### Features + +* **index:** pass options from `StyleToJS` to `camelCase` ([5dca2ef](https://github.com/remarkablemark/style-to-js/commit/5dca2ef249cb3f803e7dfc79526206ecb1ad85aa)) +* **utilities:** add option `reactCompat` to `camelCase` ([0f60c47](https://github.com/remarkablemark/style-to-js/commit/0f60c472d98c638760ba131455d7b48c360bddc0)) + + +### Bug Fixes + +* **utilities:** add `-khtml-` (Konqueror) to vendor prefix ([39fba30](https://github.com/remarkablemark/style-to-js/commit/39fba303488f526fdec26151e6ffb83e7cf9e34d)) + +## 1.0.0 (2020-11-22) + +### Features + +- **index:** add `StyleToJS` that converts CSS style to JS object ([59d3869](https://github.com/remarkablemark/style-to-js/commit/59d3869d295dfabed39b81360d0efdc545c219a6)) +- **utilities:** add `camelCase` helper ([1e5845f](https://github.com/remarkablemark/style-to-js/commit/1e5845feee446fae0943ae410133a22b31a08aaa)) + +### Bug Fixes + +- **utilities:** camelCase CSS vendor prefix correctly ([6527322](https://github.com/remarkablemark/style-to-js/commit/652732234bc431d4eb7a3c6e21bb85a44b9c76fc)) diff --git a/node_modules/style-to-js/LICENSE b/node_modules/style-to-js/LICENSE new file mode 100644 index 0000000..09562a5 --- /dev/null +++ b/node_modules/style-to-js/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2020 Menglin "Mark" Xu + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/style-to-js/README.md b/node_modules/style-to-js/README.md new file mode 100644 index 0000000..6b29e8d --- /dev/null +++ b/node_modules/style-to-js/README.md @@ -0,0 +1,271 @@ +# style-to-js + +[![NPM](https://nodei.co/npm/style-to-js.png)](https://nodei.co/npm/style-to-js/) + +[![NPM version](https://img.shields.io/npm/v/style-to-js.svg)](https://www.npmjs.com/package/style-to-js) +[![Build Status](https://travis-ci.org/remarkablemark/style-to-js.svg?branch=master)](https://travis-ci.org/remarkablemark/style-to-js) +[![Coverage Status](https://coveralls.io/repos/github/remarkablemark/style-to-js/badge.svg?branch=master)](https://coveralls.io/github/remarkablemark/style-to-js?branch=master) + +Parses CSS inline style to JavaScript object (camelCased): + +``` +StyleToJS(string) +``` + +#### Example + +```js +import parse from 'style-to-js'; + +parse('background-color: #BADA55;'); +``` + +Output: + +```json +{ "backgroundColor": "#BADA55" } +``` + +[Repl.it](https://repl.it/@remarkablemark/style-to-js) | [JSFiddle](https://jsfiddle.net/remarkablemark/04nob1y7/) + +## Install + +[NPM](https://www.npmjs.com/package/style-to-js): + +```sh +$ npm install style-to-js --save +``` + +[Yarn](https://yarnpkg.com/package/style-to-js): + +```sh +$ yarn add style-to-js +``` + +[CDN](https://unpkg.com/style-to-js/): + +```html + + +``` + +## Usage + +### Import + +Import or require module: + +```js +// ES Modules +import parse from 'style-to-js'; + +// CommonJS +const parse = require('style-to-js').default; +``` + +### Parse style + +Parse single declaration: + +```js +parse('line-height: 42'); +``` + +Output: + +```json +{ "lineHeight": "42" } +``` + +> Notice that the CSS property is camelCased. + +Parse multiple declarations: + +```js +parse(` + border-color: #ACE; + z-index: 1337; +`); +``` + +Output: + +```json +{ + "borderColor": "#ACE", + "zIndex": "1337" +} +``` + +### Vendor prefix + +Parse [vendor prefix](https://developer.mozilla.org/en-US/docs/Glossary/Vendor_Prefix): + +```js +parse(` + -webkit-transition: all 4s ease; + -moz-transition: all 4s ease; + -ms-transition: all 4s ease; + -o-transition: all 4s ease; + -khtml-transition: all 4s ease; +`); +``` + +Output: + +```json +{ + "webkitTransition": "all 4s ease", + "mozTransition": "all 4s ease", + "msTransition": "all 4s ease", + "oTransition": "all 4s ease", + "khtmlTransition": "all 4s ease" +} +``` + +### Custom property + +Parse [custom property](https://developer.mozilla.org/en-US/docs/Web/CSS/--*): + +```js +parse('--custom-property: #f00'); +``` + +Output: + +```json +{ "--custom-property": "#f00" } +``` + +### Unknown declaration + +This library does not validate declarations, so unknown declarations can be parsed: + +```js +parse('the-answer: 42;'); +``` + +Output: + +```json +{ "theAnswer": "42" } +``` + +### Invalid declaration + +Declarations with missing value are removed: + +```js +parse(` + margin-top: ; + margin-right: 1em; +`); +``` + +Output: + +```json +{ "marginRight": "1em" } +``` + +Other invalid declarations or arguments: + +```js +parse(); // {} +parse(null); // {} +parse(1); // {} +parse(true); // {} +parse('top:'); // {} +parse(':12px'); // {} +parse(':'); // {} +parse(';'); // {} +``` + +The following values will throw an error: + +```js +parse('top'); // Uncaught Error: property missing ':' +parse('/*'); // Uncaught Error: End of comment missing +``` + +### Options + +#### reactCompat + +When option `reactCompat` is true, the [vendor prefix](https://developer.mozilla.org/en-US/docs/Glossary/Vendor_Prefix) will be capitalized: + +```js +parse( + ` + -webkit-transition: all 4s ease; + -moz-transition: all 4s ease; + -ms-transition: all 4s ease; + -o-transition: all 4s ease; + -khtml-transition: all 4s ease; + `, + { reactCompat: true } +); +``` + +Output: + +```json +{ + "WebkitTransition": "all 4s ease", + "MozTransition": "all 4s ease", + "MsTransition": "all 4s ease", + "OTransition": "all 4s ease", + "KhtmlTransition": "all 4s ease" +} +``` + +This helps resolve the React warning: + +``` +Warning: Unsupported vendor-prefixed style property %s. Did you mean %s?%s", "oTransition", "OTransition" +``` + +## Testing + +Run tests with coverage: + +```sh +$ npm test +``` + +Run tests in watch mode: + +```sh +$ npm run test:watch +``` + +Lint files: + +```sh +$ npm run lint +``` + +Fix lint errors: + +```sh +$ npm run lint:fix +``` + +## Release + +Only collaborators with credentials can release and publish: + +```sh +$ npm run release +$ git push --follow-tags && npm publish +``` + +## Special Thanks + +- [style-to-object](https://github.com/remarkablemark/style-to-object) + +## License + +[MIT](https://github.com/remarkablemark/style-to-js/blob/master/LICENSE) diff --git a/node_modules/style-to-js/cjs/index.d.ts b/node_modules/style-to-js/cjs/index.d.ts new file mode 100644 index 0000000..8741a17 --- /dev/null +++ b/node_modules/style-to-js/cjs/index.d.ts @@ -0,0 +1,6 @@ +import { CamelCaseOptions } from './utilities'; +declare type StyleObject = Record; +interface StyleToJSOptions extends CamelCaseOptions { +} +export default function StyleToJS(style: string, options?: StyleToJSOptions): StyleObject; +export {}; diff --git a/node_modules/style-to-js/cjs/index.js b/node_modules/style-to-js/cjs/index.js new file mode 100644 index 0000000..9f9a49d --- /dev/null +++ b/node_modules/style-to-js/cjs/index.js @@ -0,0 +1,20 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +exports.__esModule = true; +var style_to_object_1 = __importDefault(require("style-to-object")); +var utilities_1 = require("./utilities"); +function StyleToJS(style, options) { + var output = {}; + if (!style || typeof style !== 'string') { + return output; + } + style_to_object_1["default"](style, function (property, value) { + if (property && value) { + output[utilities_1.camelCase(property, options)] = value; + } + }); + return output; +} +exports["default"] = StyleToJS; diff --git a/node_modules/style-to-js/cjs/utilities.d.ts b/node_modules/style-to-js/cjs/utilities.d.ts new file mode 100644 index 0000000..4fcf4d0 --- /dev/null +++ b/node_modules/style-to-js/cjs/utilities.d.ts @@ -0,0 +1,4 @@ +export interface CamelCaseOptions { + reactCompat?: boolean; +} +export declare const camelCase: (property: string, options?: CamelCaseOptions) => string; diff --git a/node_modules/style-to-js/cjs/utilities.js b/node_modules/style-to-js/cjs/utilities.js new file mode 100644 index 0000000..5786b28 --- /dev/null +++ b/node_modules/style-to-js/cjs/utilities.js @@ -0,0 +1,28 @@ +"use strict"; +exports.__esModule = true; +exports.camelCase = void 0; +var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/; +var HYPHEN_REGEX = /-([a-z])/g; +var NO_HYPHEN_REGEX = /^[^-]+$/; +var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/; +var skipCamelCase = function (property) { + return !property || + NO_HYPHEN_REGEX.test(property) || + CUSTOM_PROPERTY_REGEX.test(property); +}; +var capitalize = function (match, character) { + return character.toUpperCase(); +}; +var trimHyphen = function (match, prefix) { return prefix + "-"; }; +var camelCase = function (property, options) { + if (options === void 0) { options = {}; } + if (skipCamelCase(property)) { + return property; + } + property = property.toLowerCase(); + if (!options.reactCompat) { + property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen); + } + return property.replace(HYPHEN_REGEX, capitalize); +}; +exports.camelCase = camelCase; diff --git a/node_modules/style-to-js/package.json b/node_modules/style-to-js/package.json new file mode 100644 index 0000000..d71d056 --- /dev/null +++ b/node_modules/style-to-js/package.json @@ -0,0 +1,66 @@ +{ + "name": "style-to-js", + "version": "1.1.0", + "description": "Parses CSS inline style to JavaScript object (camelCased).", + "author": "Mark ", + "main": "cjs/index.js", + "scripts": { + "build": "npm run build:cjs && npm run build:umd", + "build:cjs": "tsc --declaration --outDir cjs", + "build:umd": "rollup --config", + "clean": "rm -rf cjs umd", + "lint": "npm run lint:js && npm run lint:ts && npm run lint:tsc", + "lint:js": "eslint --ignore-path .gitignore .", + "lint:ts": "npm run lint:js -- --ext .ts", + "lint:tsc": "tsc --noEmit", + "lint:fix": "npm run lint:js -- --fix && npm run lint:ts -- --fix", + "prepublishOnly": "npm run lint && npm test && npm run clean && npm run build", + "release": "standard-version --no-verify", + "test": "jest --coverage", + "test:watch": "jest --watch" + }, + "repository": { + "type": "git", + "url": "https://github.com/remarkablemark/style-to-js" + }, + "bugs": { + "url": "https://github.com/remarkablemark/style-to-js/issues" + }, + "keywords": [ + "style-to-js", + "css", + "style", + "javascript", + "object", + "pojo" + ], + "dependencies": { + "style-to-object": "0.3.0" + }, + "devDependencies": { + "@commitlint/cli": "^11.0.0", + "@commitlint/config-conventional": "^11.0.0", + "@rollup/plugin-commonjs": "^16.0.0", + "@rollup/plugin-node-resolve": "^10.0.0", + "@rollup/plugin-typescript": "^6.1.0", + "@types/jest": "^26.0.15", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-plugin-prettier": "^3.1.4", + "husky": "^4.3.0", + "jest": "^26.6.3", + "lint-staged": "^10.5.1", + "prettier": "^2.2.0", + "rollup": "^2.33.3", + "rollup-plugin-terser": "^7.0.2", + "standard-version": "^9.0.0", + "ts-jest": "^26.4.4", + "typescript": "^4.1.2" + }, + "files": [ + "cjs/", + "umd/" + ], + "license": "MIT" +} diff --git a/node_modules/style-to-js/umd/style-to-js.js b/node_modules/style-to-js/umd/style-to-js.js new file mode 100644 index 0000000..afffe1e --- /dev/null +++ b/node_modules/style-to-js/umd/style-to-js.js @@ -0,0 +1,347 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.StyleToJS = factory()); +}(this, (function () { 'use strict'; + + // http://www.w3.org/TR/CSS21/grammar.html + // https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027 + var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g; + + var NEWLINE_REGEX = /\n/g; + var WHITESPACE_REGEX = /^\s*/; + + // declaration + var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/; + var COLON_REGEX = /^:\s*/; + var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/; + var SEMICOLON_REGEX = /^[;\s]*/; + + // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill + var TRIM_REGEX = /^\s+|\s+$/g; + + // strings + var NEWLINE = '\n'; + var FORWARD_SLASH = '/'; + var ASTERISK = '*'; + var EMPTY_STRING = ''; + + // types + var TYPE_COMMENT = 'comment'; + var TYPE_DECLARATION = 'declaration'; + + /** + * @param {String} style + * @param {Object} [options] + * @return {Object[]} + * @throws {TypeError} + * @throws {Error} + */ + var inlineStyleParser = function(style, options) { + if (typeof style !== 'string') { + throw new TypeError('First argument must be a string'); + } + + if (!style) return []; + + options = options || {}; + + /** + * Positional. + */ + var lineno = 1; + var column = 1; + + /** + * Update lineno and column based on `str`. + * + * @param {String} str + */ + function updatePosition(str) { + var lines = str.match(NEWLINE_REGEX); + if (lines) lineno += lines.length; + var i = str.lastIndexOf(NEWLINE); + column = ~i ? str.length - i : column + str.length; + } + + /** + * Mark position and patch `node.position`. + * + * @return {Function} + */ + function position() { + var start = { line: lineno, column: column }; + return function(node) { + node.position = new Position(start); + whitespace(); + return node; + }; + } + + /** + * Store position information for a node. + * + * @constructor + * @property {Object} start + * @property {Object} end + * @property {undefined|String} source + */ + function Position(start) { + this.start = start; + this.end = { line: lineno, column: column }; + this.source = options.source; + } + + /** + * Non-enumerable source string. + */ + Position.prototype.content = style; + + /** + * Error `msg`. + * + * @param {String} msg + * @throws {Error} + */ + function error(msg) { + var err = new Error( + options.source + ':' + lineno + ':' + column + ': ' + msg + ); + err.reason = msg; + err.filename = options.source; + err.line = lineno; + err.column = column; + err.source = style; + + if (options.silent) ; else { + throw err; + } + } + + /** + * Match `re` and return captures. + * + * @param {RegExp} re + * @return {undefined|Array} + */ + function match(re) { + var m = re.exec(style); + if (!m) return; + var str = m[0]; + updatePosition(str); + style = style.slice(str.length); + return m; + } + + /** + * Parse whitespace. + */ + function whitespace() { + match(WHITESPACE_REGEX); + } + + /** + * Parse comments. + * + * @param {Object[]} [rules] + * @return {Object[]} + */ + function comments(rules) { + var c; + rules = rules || []; + while ((c = comment())) { + if (c !== false) { + rules.push(c); + } + } + return rules; + } + + /** + * Parse comment. + * + * @return {Object} + * @throws {Error} + */ + function comment() { + var pos = position(); + if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return; + + var i = 2; + while ( + EMPTY_STRING != style.charAt(i) && + (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1)) + ) { + ++i; + } + i += 2; + + if (EMPTY_STRING === style.charAt(i - 1)) { + return error('End of comment missing'); + } + + var str = style.slice(2, i - 2); + column += 2; + updatePosition(str); + style = style.slice(i); + column += 2; + + return pos({ + type: TYPE_COMMENT, + comment: str + }); + } + + /** + * Parse declaration. + * + * @return {Object} + * @throws {Error} + */ + function declaration() { + var pos = position(); + + // prop + var prop = match(PROPERTY_REGEX); + if (!prop) return; + comment(); + + // : + if (!match(COLON_REGEX)) return error("property missing ':'"); + + // val + var val = match(VALUE_REGEX); + + var ret = pos({ + type: TYPE_DECLARATION, + property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)), + value: val + ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING)) + : EMPTY_STRING + }); + + // ; + match(SEMICOLON_REGEX); + + return ret; + } + + /** + * Parse declarations. + * + * @return {Object[]} + */ + function declarations() { + var decls = []; + + comments(decls); + + // declarations + var decl; + while ((decl = declaration())) { + if (decl !== false) { + decls.push(decl); + comments(decls); + } + } + + return decls; + } + + whitespace(); + return declarations(); + }; + + /** + * Trim `str`. + * + * @param {String} str + * @return {String} + */ + function trim(str) { + return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING; + } + + /** + * Parses inline style to object. + * + * @example + * // returns { 'line-height': '42' } + * StyleToObject('line-height: 42;'); + * + * @param {String} style - The inline style. + * @param {Function} [iterator] - The iterator function. + * @return {null|Object} + */ + function StyleToObject(style, iterator) { + var output = null; + if (!style || typeof style !== 'string') { + return output; + } + + var declaration; + var declarations = inlineStyleParser(style); + var hasIterator = typeof iterator === 'function'; + var property; + var value; + + for (var i = 0, len = declarations.length; i < len; i++) { + declaration = declarations[i]; + property = declaration.property; + value = declaration.value; + + if (hasIterator) { + iterator(property, value, declaration); + } else if (value) { + output || (output = {}); + output[property] = value; + } + } + + return output; + } + + var styleToObject = StyleToObject; + + var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/; + var HYPHEN_REGEX = /-([a-z])/g; + var NO_HYPHEN_REGEX = /^[^-]+$/; + var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/; + var skipCamelCase = function (property) { + return !property || + NO_HYPHEN_REGEX.test(property) || + CUSTOM_PROPERTY_REGEX.test(property); + }; + var capitalize = function (match, character) { + return character.toUpperCase(); + }; + var trimHyphen = function (match, prefix) { return prefix + "-"; }; + var camelCase = function (property, options) { + if (options === void 0) { options = {}; } + if (skipCamelCase(property)) { + return property; + } + property = property.toLowerCase(); + if (!options.reactCompat) { + property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen); + } + return property.replace(HYPHEN_REGEX, capitalize); + }; + + function StyleToJS(style, options) { + var output = {}; + if (!style || typeof style !== 'string') { + return output; + } + styleToObject(style, function (property, value) { + if (property && value) { + output[camelCase(property, options)] = value; + } + }); + return output; + } + + return StyleToJS; + +}))); +//# sourceMappingURL=style-to-js.js.map diff --git a/node_modules/style-to-js/umd/style-to-js.js.map b/node_modules/style-to-js/umd/style-to-js.js.map new file mode 100644 index 0000000..880f643 --- /dev/null +++ b/node_modules/style-to-js/umd/style-to-js.js.map @@ -0,0 +1 @@ +{"version":3,"file":"style-to-js.js","sources":["../node_modules/inline-style-parser/index.js","../node_modules/style-to-object/index.js","../src/utilities.ts","../src/index.ts"],"sourcesContent":["// http://www.w3.org/TR/CSS21/grammar.html\n// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027\nvar COMMENT_REGEX = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\n\nvar NEWLINE_REGEX = /\\n/g;\nvar WHITESPACE_REGEX = /^\\s*/;\n\n// declaration\nvar PROPERTY_REGEX = /^(\\*?[-#/*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/;\nvar COLON_REGEX = /^:\\s*/;\nvar VALUE_REGEX = /^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^)]*?\\)|[^};])+)/;\nvar SEMICOLON_REGEX = /^[;\\s]*/;\n\n// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill\nvar TRIM_REGEX = /^\\s+|\\s+$/g;\n\n// strings\nvar NEWLINE = '\\n';\nvar FORWARD_SLASH = '/';\nvar ASTERISK = '*';\nvar EMPTY_STRING = '';\n\n// types\nvar TYPE_COMMENT = 'comment';\nvar TYPE_DECLARATION = 'declaration';\n\n/**\n * @param {String} style\n * @param {Object} [options]\n * @return {Object[]}\n * @throws {TypeError}\n * @throws {Error}\n */\nmodule.exports = function(style, options) {\n if (typeof style !== 'string') {\n throw new TypeError('First argument must be a string');\n }\n\n if (!style) return [];\n\n options = options || {};\n\n /**\n * Positional.\n */\n var lineno = 1;\n var column = 1;\n\n /**\n * Update lineno and column based on `str`.\n *\n * @param {String} str\n */\n function updatePosition(str) {\n var lines = str.match(NEWLINE_REGEX);\n if (lines) lineno += lines.length;\n var i = str.lastIndexOf(NEWLINE);\n column = ~i ? str.length - i : column + str.length;\n }\n\n /**\n * Mark position and patch `node.position`.\n *\n * @return {Function}\n */\n function position() {\n var start = { line: lineno, column: column };\n return function(node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n\n /**\n * Store position information for a node.\n *\n * @constructor\n * @property {Object} start\n * @property {Object} end\n * @property {undefined|String} source\n */\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n\n /**\n * Non-enumerable source string.\n */\n Position.prototype.content = style;\n\n var errorsList = [];\n\n /**\n * Error `msg`.\n *\n * @param {String} msg\n * @throws {Error}\n */\n function error(msg) {\n var err = new Error(\n options.source + ':' + lineno + ':' + column + ': ' + msg\n );\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = style;\n\n if (options.silent) {\n errorsList.push(err);\n } else {\n throw err;\n }\n }\n\n /**\n * Match `re` and return captures.\n *\n * @param {RegExp} re\n * @return {undefined|Array}\n */\n function match(re) {\n var m = re.exec(style);\n if (!m) return;\n var str = m[0];\n updatePosition(str);\n style = style.slice(str.length);\n return m;\n }\n\n /**\n * Parse whitespace.\n */\n function whitespace() {\n match(WHITESPACE_REGEX);\n }\n\n /**\n * Parse comments.\n *\n * @param {Object[]} [rules]\n * @return {Object[]}\n */\n function comments(rules) {\n var c;\n rules = rules || [];\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n }\n return rules;\n }\n\n /**\n * Parse comment.\n *\n * @return {Object}\n * @throws {Error}\n */\n function comment() {\n var pos = position();\n if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;\n\n var i = 2;\n while (\n EMPTY_STRING != style.charAt(i) &&\n (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))\n ) {\n ++i;\n }\n i += 2;\n\n if (EMPTY_STRING === style.charAt(i - 1)) {\n return error('End of comment missing');\n }\n\n var str = style.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n style = style.slice(i);\n column += 2;\n\n return pos({\n type: TYPE_COMMENT,\n comment: str\n });\n }\n\n /**\n * Parse declaration.\n *\n * @return {Object}\n * @throws {Error}\n */\n function declaration() {\n var pos = position();\n\n // prop\n var prop = match(PROPERTY_REGEX);\n if (!prop) return;\n comment();\n\n // :\n if (!match(COLON_REGEX)) return error(\"property missing ':'\");\n\n // val\n var val = match(VALUE_REGEX);\n\n var ret = pos({\n type: TYPE_DECLARATION,\n property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),\n value: val\n ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))\n : EMPTY_STRING\n });\n\n // ;\n match(SEMICOLON_REGEX);\n\n return ret;\n }\n\n /**\n * Parse declarations.\n *\n * @return {Object[]}\n */\n function declarations() {\n var decls = [];\n\n comments(decls);\n\n // declarations\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n }\n\n return decls;\n }\n\n whitespace();\n return declarations();\n};\n\n/**\n * Trim `str`.\n *\n * @param {String} str\n * @return {String}\n */\nfunction trim(str) {\n return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;\n}\n","var parse = require('inline-style-parser');\n\n/**\n * Parses inline style to object.\n *\n * @example\n * // returns { 'line-height': '42' }\n * StyleToObject('line-height: 42;');\n *\n * @param {String} style - The inline style.\n * @param {Function} [iterator] - The iterator function.\n * @return {null|Object}\n */\nfunction StyleToObject(style, iterator) {\n var output = null;\n if (!style || typeof style !== 'string') {\n return output;\n }\n\n var declaration;\n var declarations = parse(style);\n var hasIterator = typeof iterator === 'function';\n var property;\n var value;\n\n for (var i = 0, len = declarations.length; i < len; i++) {\n declaration = declarations[i];\n property = declaration.property;\n value = declaration.value;\n\n if (hasIterator) {\n iterator(property, value, declaration);\n } else if (value) {\n output || (output = {});\n output[property] = value;\n }\n }\n\n return output;\n}\n\nmodule.exports = StyleToObject;\n","const CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/;\nconst HYPHEN_REGEX = /-([a-z])/g;\nconst NO_HYPHEN_REGEX = /^[^-]+$/;\nconst VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/;\n\n/**\n * Checks whether to skip camelCase.\n */\nconst skipCamelCase = (property: string) =>\n !property ||\n NO_HYPHEN_REGEX.test(property) ||\n CUSTOM_PROPERTY_REGEX.test(property);\n\n/**\n * Replacer that capitalizes first character.\n */\nconst capitalize = (match: string, character: string) =>\n character.toUpperCase();\n\n/**\n * Replacer that removes beginning hyphen of vendor prefix property.\n */\nconst trimHyphen = (match: string, prefix: string) => `${prefix}-`;\n\n/**\n * CamelCase options.\n */\nexport interface CamelCaseOptions {\n reactCompat?: boolean;\n}\n\n/**\n * CamelCases a CSS property.\n */\nexport const camelCase = (property: string, options: CamelCaseOptions = {}) => {\n if (skipCamelCase(property)) {\n return property;\n }\n\n property = property.toLowerCase();\n\n if (!options.reactCompat) {\n // for non-React, remove first hyphen so vendor prefix is not capitalized\n property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen);\n }\n\n return property.replace(HYPHEN_REGEX, capitalize);\n};\n","import StyleToObject from 'style-to-object';\nimport { camelCase, CamelCaseOptions } from './utilities';\n\ntype StyleObject = Record;\n\ninterface StyleToJSOptions extends CamelCaseOptions {}\n\n/**\n * Parses CSS inline style to JavaScript object (camelCased).\n */\nexport default function StyleToJS(\n style: string,\n options?: StyleToJSOptions\n): StyleObject {\n const output: StyleObject = {};\n\n if (!style || typeof style !== 'string') {\n return output;\n }\n\n StyleToObject(style, (property, value) => {\n // skip CSS comment\n if (property && value) {\n output[camelCase(property, options)] = value;\n }\n });\n\n return output;\n}\n"],"names":["parse","StyleToObject"],"mappings":";;;;;;EAAA;EACA;EACA,IAAI,aAAa,GAAG,iCAAiC,CAAC;AACtD;EACA,IAAI,aAAa,GAAG,KAAK,CAAC;EAC1B,IAAI,gBAAgB,GAAG,MAAM,CAAC;AAC9B;EACA;EACA,IAAI,cAAc,GAAG,wCAAwC,CAAC;EAC9D,IAAI,WAAW,GAAG,OAAO,CAAC;EAC1B,IAAI,WAAW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style-to-js.min.js b/node_modules/style-to-js/umd/style-to-js.min.js new file mode 100644 index 0000000..27c7a9f --- /dev/null +++ b/node_modules/style-to-js/umd/style-to-js.min.js @@ -0,0 +1,2 @@ +!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).StyleToJS=t()}(this,(function(){"use strict";var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,r=/^\s*/,e=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,c=/^\s+|\s+$/g,f="";function a(n){return n?n.replace(c,f):f}var s=function(c,s){var l,p=null;if(!c||"string"!=typeof c)return p;for(var h,m,v=function(c,s){if("string"!=typeof c)throw new TypeError("First argument must be a string");if(!c)return[];s=s||{};var l=1,p=1;function h(n){var r=n.match(t);r&&(l+=r.length);var e=n.lastIndexOf("\n");p=~e?n.length-e:p+n.length}function m(){var n={line:l,column:p};return function(t){return t.position=new v(n),d(),t}}function v(n){this.start=n,this.end={line:l,column:p},this.source=s.source}function g(n){var t=new Error(s.source+":"+l+":"+p+": "+n);if(t.reason=n,t.filename=s.source,t.line=l,t.column=p,t.source=c,!s.silent)throw t}function y(n){var t=n.exec(c);if(t){var r=t[0];return h(r),c=c.slice(r.length),t}}function d(){y(r)}function w(n){var t;for(n=n||[];t=A();)!1!==t&&n.push(t);return n}function A(){var n=m();if("/"==c.charAt(0)&&"*"==c.charAt(1)){for(var t=2;f!=c.charAt(t)&&("*"!=c.charAt(t)||"/"!=c.charAt(t+1));)++t;if(t+=2,f===c.charAt(t-1))return g("End of comment missing");var r=c.slice(2,t-2);return p+=2,h(r),c=c.slice(t),p+=2,n({type:"comment",comment:r})}}function b(){var t=m(),r=y(e);if(r){if(A(),!y(o))return g("property missing ':'");var c=y(i),s=t({type:"declaration",property:a(r[0].replace(n,f)),value:c?a(c[0].replace(n,f)):f});return y(u),s}}return v.prototype.content=c,d(),function(){var n,t=[];for(w(t);n=b();)!1!==n&&(t.push(n),w(t));return t}()}(c),g="function"==typeof s,y=0,d=v.length;y\n !property ||\n NO_HYPHEN_REGEX.test(property) ||\n CUSTOM_PROPERTY_REGEX.test(property);\n\n/**\n * Replacer that capitalizes first character.\n */\nconst capitalize = (match: string, character: string) =>\n character.toUpperCase();\n\n/**\n * Replacer that removes beginning hyphen of vendor prefix property.\n */\nconst trimHyphen = (match: string, prefix: string) => `${prefix}-`;\n\n/**\n * CamelCase options.\n */\nexport interface CamelCaseOptions {\n reactCompat?: boolean;\n}\n\n/**\n * CamelCases a CSS property.\n */\nexport const camelCase = (property: string, options: CamelCaseOptions = {}) => {\n if (skipCamelCase(property)) {\n return property;\n }\n\n property = property.toLowerCase();\n\n if (!options.reactCompat) {\n // for non-React, remove first hyphen so vendor prefix is not capitalized\n property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen);\n }\n\n return property.replace(HYPHEN_REGEX, capitalize);\n};\n","import StyleToObject from 'style-to-object';\nimport { camelCase, CamelCaseOptions } from './utilities';\n\ntype StyleObject = Record;\n\ninterface StyleToJSOptions extends CamelCaseOptions {}\n\n/**\n * Parses CSS inline style to JavaScript object (camelCased).\n */\nexport default function StyleToJS(\n style: string,\n options?: StyleToJSOptions\n): StyleObject {\n const output: StyleObject = {};\n\n if (!style || typeof style !== 'string') {\n return output;\n }\n\n StyleToObject(style, (property, value) => {\n // skip CSS comment\n if (property && value) {\n output[camelCase(property, options)] = value;\n }\n });\n\n return output;\n}\n"],"names":["COMMENT_REGEX","NEWLINE_REGEX","WHITESPACE_REGEX","PROPERTY_REGEX","COLON_REGEX","VALUE_REGEX","SEMICOLON_REGEX","TRIM_REGEX","EMPTY_STRING","trim","str","replace","style","iterator","declaration","output","property","value","declarations","options","TypeError","lineno","column","updatePosition","lines","match","length","i","lastIndexOf","position","start","line","node","Position","whitespace","this","end","source","error","msg","err","Error","reason","filename","silent","re","m","exec","slice","comments","rules","c","comment","push","pos","charAt","type","prop","val","ret","prototype","content","decl","decls","parse","hasIterator","len","CUSTOM_PROPERTY_REGEX","HYPHEN_REGEX","NO_HYPHEN_REGEX","VENDOR_PREFIX_REGEX","capitalize","character","toUpperCase","trimHyphen","prefix","camelCase","test","skipCamelCase","toLowerCase","reactCompat","StyleToObject"],"mappings":"0OAEA,IAAIA,EAAgB,kCAEhBC,EAAgB,MAChBC,EAAmB,OAGnBC,EAAiB,yCACjBC,EAAc,QACdC,EAAc,uDACdC,EAAkB,UAGlBC,EAAa,aAMbC,EAAe,GA8OnB,SAASC,EAAKC,GACZ,OAAOA,EAAMA,EAAIC,QAAQJ,EAAYC,GAAgBA,EC1NvD,MA5BA,SAAuBI,EAAOC,GAC5B,IAKIC,EALAC,EAAS,KACb,IAAKH,GAA0B,iBAAVA,EACnB,OAAOG,EAST,IALA,IAEIC,EACAC,EAHAC,EDaW,SAASN,EAAOO,GAC/B,GAAqB,iBAAVP,EACT,MAAM,IAAIQ,UAAU,mCAGtB,IAAKR,EAAO,MAAO,GAEnBO,EAAUA,GAAW,GAKrB,IAAIE,EAAS,EACTC,EAAS,EAOb,SAASC,EAAeb,GACtB,IAAIc,EAAQd,EAAIe,MAAMxB,GAClBuB,IAAOH,GAAUG,EAAME,QAC3B,IAAIC,EAAIjB,EAAIkB,YAvCF,MAwCVN,GAAUK,EAAIjB,EAAIgB,OAASC,EAAIL,EAASZ,EAAIgB,OAQ9C,SAASG,IACP,IAAIC,EAAQ,CAAEC,KAAMV,EAAQC,OAAQA,GACpC,OAAO,SAASU,GAGd,OAFAA,EAAKH,SAAW,IAAII,EAASH,GAC7BI,IACOF,GAYX,SAASC,EAASH,GAChBK,KAAKL,MAAQA,EACbK,KAAKC,IAAM,CAAEL,KAAMV,EAAQC,OAAQA,GACnCa,KAAKE,OAASlB,EAAQkB,OAgBxB,SAASC,EAAMC,GACb,IAA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-to-object/CHANGELOG.md b/node_modules/style-to-object/CHANGELOG.md new file mode 100644 index 0000000..1c59226 --- /dev/null +++ b/node_modules/style-to-object/CHANGELOG.md @@ -0,0 +1,83 @@ +# Changelog + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [0.3.0](https://github.com/remarkablemark/style-to-object/compare/v0.2.3...v0.3.0) (2019-11-07) + + +### Bug Fixes + +* **index:** update return type of main function (remove `any`) ([c6e8a54](https://github.com/remarkablemark/style-to-object/commit/c6e8a54)) + + +### Features + +* add typescript support ([74a1b83](https://github.com/remarkablemark/style-to-object/commit/74a1b83)) + + +### Tests + +* **index:** add test for TS declaration file ([b029a4b](https://github.com/remarkablemark/style-to-object/commit/b029a4b)) + + + +### [0.2.3](https://github.com/remarkablemark/style-to-object/compare/v0.2.2...v0.2.3) (2019-06-22) + + +### Build System + +* **package:** add field "files" and remove `.npmignore` ([fdf3966](https://github.com/remarkablemark/style-to-object/commit/fdf3966)) +* **package:** update script `build:min` to generate sourcemap ([a13be58](https://github.com/remarkablemark/style-to-object/commit/a13be58)) +* **package:** upgrade devDependencies ([377bb40](https://github.com/remarkablemark/style-to-object/commit/377bb40)) +* **rollup:** remove `uglify-es` from config as it's unneeded ([b0951e0](https://github.com/remarkablemark/style-to-object/commit/b0951e0)) + + +### Tests + +* organize and rename describe blocks ([8d4c004](https://github.com/remarkablemark/style-to-object/commit/8d4c004)) +* organize data (test suites) into cases, errors, and invalids ([513732b](https://github.com/remarkablemark/style-to-object/commit/513732b)) +* rename `test/cases.js` to `test/data.js` ([75d084d](https://github.com/remarkablemark/style-to-object/commit/75d084d)) +* **data:** add more test cases and errors ([c9242c7](https://github.com/remarkablemark/style-to-object/commit/c9242c7)) +* **data:** refactor test data from object to array format ([1a07a38](https://github.com/remarkablemark/style-to-object/commit/1a07a38)) + + + + +## [0.2.2](https://github.com/remarkablemark/style-to-object/compare/v0.2.1...v0.2.2) (2018-09-13) + + + + +## [0.2.1](https://github.com/remarkablemark/style-to-object/compare/v0.2.0...v0.2.1) (2018-05-09) + + +### Bug Fixes + +* **package:** upgrade css@2.2.3 which resolves security vulnerability ([d8b94c0](https://github.com/remarkablemark/style-to-object/commit/d8b94c0)) + + + + +# [0.2.0](https://github.com/remarkablemark/style-to-object/compare/v0.1.0...v0.2.0) (2017-11-26) + + +### Features + +* **parser:** add optional argument iterator ([a3deea8](https://github.com/remarkablemark/style-to-object/commit/a3deea8)) + + + + +# 0.1.0 (2017-11-23) + + +### Bug Fixes + +* **parser:** do not add to output if css value is empty ([0759da7](https://github.com/remarkablemark/style-to-object/commit/0759da7)) + + +### Features + +* **parser:** create client parser ([cd85a31](https://github.com/remarkablemark/style-to-object/commit/cd85a31)) +* **parser:** create parser that returns null for invalid values ([24f4f02](https://github.com/remarkablemark/style-to-object/commit/24f4f02)) +* **parser:** parse inline style to object with css.parse ([04793b0](https://github.com/remarkablemark/style-to-object/commit/04793b0)) diff --git a/node_modules/style-to-object/LICENSE b/node_modules/style-to-object/LICENSE new file mode 100644 index 0000000..e109012 --- /dev/null +++ b/node_modules/style-to-object/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2017 Menglin "Mark" Xu + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/style-to-object/README.md b/node_modules/style-to-object/README.md new file mode 100644 index 0000000..a80dc91 --- /dev/null +++ b/node_modules/style-to-object/README.md @@ -0,0 +1,213 @@ +# style-to-object + +[![NPM](https://nodei.co/npm/style-to-object.png)](https://nodei.co/npm/style-to-object/) + +[![NPM version](https://img.shields.io/npm/v/style-to-object.svg)](https://www.npmjs.com/package/style-to-object) +[![Build Status](https://travis-ci.org/remarkablemark/style-to-object.svg?branch=master)](https://travis-ci.org/remarkablemark/style-to-object) +[![Coverage Status](https://coveralls.io/repos/github/remarkablemark/style-to-object/badge.svg?branch=master)](https://coveralls.io/github/remarkablemark/style-to-object?branch=master) +[![Dependency status](https://david-dm.org/remarkablemark/style-to-object.svg)](https://david-dm.org/remarkablemark/style-to-object) +[![NPM downloads](https://img.shields.io/npm/dm/style-to-object.svg?style=flat-square)](https://www.npmjs.com/package/style-to-object) + +Parses inline style to object: + +```js +var parse = require('style-to-object'); +parse('color: #C0FFEE; background: #BADA55;'); +``` + +Output: + +```js +{ color: '#C0FFEE', background: '#BADA55' } +``` + +[JSFiddle](https://jsfiddle.net/remarkablemark/ykz2meot/) | [Repl.it](https://repl.it/@remarkablemark/style-to-object) | [Examples](https://github.com/remarkablemark/style-to-object/tree/master/examples) + +## Installation + +[NPM](https://www.npmjs.com/package/style-to-object): + +```sh +$ npm install style-to-object --save +``` + +[Yarn](https://yarn.fyi/style-to-object): + +```sh +$ yarn add style-to-object +``` + +[CDN](https://unpkg.com/style-to-object/): + +```html + + +``` + +## Usage + +Import the module: + +```js +// CommonJS +const parse = require('style-to-object'); + +// ES Modules +import parse from 'style-to-object'; +``` + +Parse single declaration: + +```js +parse('line-height: 42'); +``` + +Output: + +```js +{ 'line-height': '42' } +``` + +Parse multiple declarations: + +```js +parse(` + border-color: #ACE; + z-index: 1337; +`); +``` + +Output: + +```js +{ 'border-color': '#ACE', 'z-index': '1337' } +``` + +Parse unknown declarations: + +```js +parse('answer: 42;'); +``` + +Output: + +```js +{ 'answer': '42' } +``` + +Invalid declarations/arguments: + +```js +parse(` + top: ; + right: 1em; +`); // { right: '1em' } + +parse(); // null +parse(null); // null +parse(1); // null +parse(true); // null +parse('top:'); // null +parse(':12px'); // null +parse(':'); // null +parse(';'); // null + +parse('top'); // throws Error +parse('/*'); // throws Error +``` + +### Iterator + +If the 2nd argument is a function, then the parser will return `null`: + +```js +parse('color: #f00', function() {}); // null +``` + +But the function will iterate through each declaration: + +```js +parse('color: #f00', function(name, value, declaration) { + console.log(name); // 'color' + console.log(value); // '#f00' + console.log(declaration); // { type: 'declaration', property: 'color', value: '#f00' } +}); +``` + +This makes it easy to customize the output: + +```js +const style = ` + color: red; + background: blue; +`; +const output = []; + +function iterator(name, value) { + output.push([name, value]); +} + +parse(style, iterator); +console.log(output); // [['color', 'red'], ['background', 'blue']] +``` + +## Testing + +Run tests: + +```sh +$ npm test +``` + +Run tests in watch mode: + +```sh +$ npm run test:watch +``` + +Run tests with coverage: + +```sh +$ npm run test:coverage + +# generate html report +$ npm run test:coverage:report +``` + +Lint files: + +```sh +$ npm run lint +``` + +Fix lint errors: + +```sh +$ npm run lint:fix +``` + +Test TypeScript declaration file for style and correctness: + +```sh +$ npm run lint:dts +``` + +## Release + +Only collaborators with credentials can release and publish: + +```sh +$ npm run release +$ git push --follow-tags && npm publish +``` + +## Special Thanks + +- [inline-style-parser](https://github.com/remarkablemark/inline-style-parser) +- [Contributors](https://github.com/remarkablemark/style-to-object/graphs/contributors) + +## License + +[MIT](https://github.com/remarkablemark/style-to-object/blob/master/LICENSE) diff --git a/node_modules/style-to-object/index.d.ts b/node_modules/style-to-object/index.d.ts new file mode 100644 index 0000000..e666029 --- /dev/null +++ b/node_modules/style-to-object/index.d.ts @@ -0,0 +1,38 @@ +/** + * Parses inline style to object. + * + * @example + * import StyleToObject from 'style-to-object'; + * StyleToObject('line-height: 42;'); + */ +declare function StyleToObject( + style: string, + iterator?: StyleToObject.Iterator +): { [name: string]: string } | null; + +export = StyleToObject; + +declare namespace StyleToObject { + interface DeclarationPos { + line: number; + column: number; + } + + // declaration is an object from module `inline-style-parser` + interface Declaration { + type: string; + property: string; + value: string; + position: { + start: DeclarationPos; + end: DeclarationPos; + source: any; + }; + } + + type Iterator = ( + property: string, + value: string, + declaration: Declaration + ) => void; +} diff --git a/node_modules/style-to-object/index.js b/node_modules/style-to-object/index.js new file mode 100644 index 0000000..5cb85bb --- /dev/null +++ b/node_modules/style-to-object/index.js @@ -0,0 +1,42 @@ +var parse = require('inline-style-parser'); + +/** + * Parses inline style to object. + * + * @example + * // returns { 'line-height': '42' } + * StyleToObject('line-height: 42;'); + * + * @param {String} style - The inline style. + * @param {Function} [iterator] - The iterator function. + * @return {null|Object} + */ +function StyleToObject(style, iterator) { + var output = null; + if (!style || typeof style !== 'string') { + return output; + } + + var declaration; + var declarations = parse(style); + var hasIterator = typeof iterator === 'function'; + var property; + var value; + + for (var i = 0, len = declarations.length; i < len; i++) { + declaration = declarations[i]; + property = declaration.property; + value = declaration.value; + + if (hasIterator) { + iterator(property, value, declaration); + } else if (value) { + output || (output = {}); + output[property] = value; + } + } + + return output; +} + +module.exports = StyleToObject; diff --git a/node_modules/style-to-object/package.json b/node_modules/style-to-object/package.json new file mode 100644 index 0000000..07fe490 --- /dev/null +++ b/node_modules/style-to-object/package.json @@ -0,0 +1,67 @@ +{ + "name": "style-to-object", + "version": "0.3.0", + "description": "Converts inline style to object.", + "author": "Mark ", + "main": "index.js", + "types": "index.d.ts", + "scripts": { + "build": "run-s build:*", + "build:min": "NODE_ENV=production rollup --config --file dist/style-to-object.min.js --sourcemap", + "build:unmin": "NODE_ENV=development rollup --config --file dist/style-to-object.js", + "clean": "rm -rf dist", + "coveralls": "nyc report --reporter=text-lcov | coveralls", + "lint": "eslint --ignore-path .gitignore .", + "lint:fix": "npm run lint -- --fix", + "lint:dts": "dtslint .", + "prepublishOnly": "run-s lint lint:dts test clean build", + "release": "standard-version --no-verify", + "test": "mocha", + "test:coverage": "nyc npm test", + "test:coverage:report": "nyc report --reporter=html", + "test:watch": "mocha --watch" + }, + "repository": { + "type": "git", + "url": "https://github.com/remarkablemark/style-to-object" + }, + "bugs": { + "url": "https://github.com/remarkablemark/style-to-object/issues" + }, + "keywords": [ + "style-to-object", + "inline", + "style", + "parser", + "css", + "object", + "pojo" + ], + "dependencies": { + "inline-style-parser": "0.1.1" + }, + "devDependencies": { + "@commitlint/cli": "^8.2.0", + "@commitlint/config-conventional": "^8.2.0", + "coveralls": "^3.0.7", + "dtslint": "^1.0.3", + "eslint": "^6.6.0", + "eslint-plugin-prettier": "^3.1.1", + "husky": "^3.0.9", + "lint-staged": "^9.4.2", + "mocha": "^6.2.2", + "npm-run-all": "^4.1.5", + "nyc": "^14.1.1", + "prettier": "^1.18.2", + "rollup": "^1.26.3", + "rollup-plugin-commonjs": "^10.1.0", + "rollup-plugin-node-resolve": "^5.2.0", + "rollup-plugin-uglify": "^6.0.3", + "standard-version": "^6" + }, + "files": [ + "/dist", + "index.d.ts" + ], + "license": "MIT" +} diff --git a/search_frontend/.eslintcache b/search_frontend/.eslintcache index d6718f7..edae4c1 100644 --- a/search_frontend/.eslintcache +++ b/search_frontend/.eslintcache @@ -1 +1 @@ -[{"/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/index.js":"1","/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/App.js":"2","/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/reducer.js":"3","/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/stateProvider.js":"4","/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/pages/Home.jsx":"5","/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/pages/SearchPage.jsx":"6","/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/search.js":"7","/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/pages/Footer.jsx":"8","/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/pages/Search.jsx":"9","/home/prahas/Documents/haystack/hayStack/search_frontend/src/index.js":"10","/home/prahas/Documents/haystack/hayStack/search_frontend/src/reducer.js":"11","/home/prahas/Documents/haystack/hayStack/search_frontend/src/stateProvider.js":"12","/home/prahas/Documents/haystack/hayStack/search_frontend/src/App.js":"13","/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/Home.jsx":"14","/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/SearchPage.jsx":"15","/home/prahas/Documents/haystack/hayStack/search_frontend/src/search.js":"16","/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/Search.jsx":"17","/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/Footer.jsx":"18","/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/SearchImg.jsx":"19"},{"size":613,"mtime":1625049343296,"results":"20","hashOfConfig":"21"},{"size":506,"mtime":1625049343296,"results":"22","hashOfConfig":"21"},{"size":590,"mtime":1625049343300,"results":"23","hashOfConfig":"21"},{"size":364,"mtime":1625049343304,"results":"24","hashOfConfig":"21"},{"size":1494,"mtime":1625049343296,"results":"25","hashOfConfig":"21"},{"size":6442,"mtime":1625049343296,"results":"26","hashOfConfig":"21"},{"size":1430,"mtime":1625049343304,"results":"27","hashOfConfig":"21"},{"size":1502,"mtime":1625049343296,"results":"28","hashOfConfig":"21"},{"size":2128,"mtime":1625064194185,"results":"29","hashOfConfig":"21"},{"size":613,"mtime":1625049343296,"results":"30","hashOfConfig":"31"},{"size":590,"mtime":1625049343300,"results":"32","hashOfConfig":"31"},{"size":364,"mtime":1625049343304,"results":"33","hashOfConfig":"31"},{"size":626,"mtime":1627149452974,"results":"34","hashOfConfig":"31"},{"size":1494,"mtime":1625049343296,"results":"35","hashOfConfig":"31"},{"size":7063,"mtime":1627369825436,"results":"36","hashOfConfig":"31"},{"size":1430,"mtime":1625049343304,"results":"37","hashOfConfig":"31"},{"size":2128,"mtime":1627141856054,"results":"38","hashOfConfig":"31"},{"size":1502,"mtime":1625049343296,"results":"39","hashOfConfig":"31"},{"size":8583,"mtime":1627363728462,"results":"40","hashOfConfig":"31"},{"filePath":"41","messages":"42","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"43"},"muac4l",{"filePath":"44","messages":"45","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"43"},{"filePath":"46","messages":"47","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"43"},{"filePath":"48","messages":"49","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"43"},{"filePath":"50","messages":"51","errorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":"52","usedDeprecatedRules":"43"},{"filePath":"53","messages":"54","errorCount":0,"warningCount":6,"fixableErrorCount":0,"fixableWarningCount":0,"source":"55","usedDeprecatedRules":"43"},{"filePath":"56","messages":"57","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"58","usedDeprecatedRules":"43"},{"filePath":"59","messages":"60","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"61","usedDeprecatedRules":"43"},{"filePath":"62","messages":"63","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"64","usedDeprecatedRules":"65"},{"filePath":"66","messages":"67","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"68"},"1t4anou",{"filePath":"69","messages":"70","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"68"},{"filePath":"71","messages":"72","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"68"},{"filePath":"73","messages":"74","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"68"},{"filePath":"75","messages":"76","errorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":"52","usedDeprecatedRules":"68"},{"filePath":"77","messages":"78","errorCount":0,"warningCount":6,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"79","messages":"80","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"58","usedDeprecatedRules":"81"},{"filePath":"82","messages":"83","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"64","usedDeprecatedRules":"68"},{"filePath":"84","messages":"85","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"61","usedDeprecatedRules":"68"},{"filePath":"86","messages":"87","errorCount":0,"warningCount":7,"fixableErrorCount":0,"fixableWarningCount":0,"source":"88","usedDeprecatedRules":"68"},"/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/index.js",[],["89","90"],"/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/App.js",[],"/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/reducer.js",[],"/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/stateProvider.js",[],"/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/pages/Home.jsx",["91","92","93","94"],"import React, {useState, useEffect} from \"react\";\nimport \"./Home.css\";\nimport { Link } from \"react-router-dom\";\nimport AppsIcon from \"@material-ui/icons/Apps\";\nimport { Avatar } from \"@material-ui/core\";\nimport Search from \"./Search\";\nimport logo from './LogoSVGWhiteBG.svg'\nimport haystack from './haystack.png'\nimport Footer from './Footer';\n\nvar elasticsearch = require('elasticsearch');\n\nvar client = new elasticsearch.Client({\n host: 'http://localhost:9200/' \n // http://localhost:9200/ \n // http://root:12345@localhost:9200/ \n // If you have set username and password\n});\n\nfunction Home() {\n const [indexQty, setIndexQty] = useState();\n useEffect(() => {\n client.search({\n index: \"iitd_sites\", // Your index name for example crud \n body: {\n \"query\": {\n \"match_all\": {}\n }\n }\n }).then(function (resp) {\n setIndexQty(resp['hits']['total']['value']);\n }, function (err) {\n console.log(err.message);\n });\n }, [])\n return (\n
    \n
    \n
    \n \"DevClub\n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n );\n}\n\nexport default Home;\n","/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/pages/SearchPage.jsx",["95","96","97","98","99","100"],"import React, { useState, useEffect } from \"react\";\nimport \"./SearchPage.css\";\nimport { actionTypes } from \"../reducer\";\nimport { useStateValue } from \"../stateProvider\";\nimport triggerSearch from \"../search\";\nimport { Link } from \"react-router-dom\";\nimport { useLocation } from 'react-router';\nimport Search from \"./Search\";\nimport logo from './LogoSVGWhiteBG.svg'\nimport Pagination from '@material-ui/lab/Pagination';\nimport Footer from './Footer';\nimport qs from \"qs\";\n\nimport PersonIcon from \"@material-ui/icons/Person\";\nimport SearchIcon from \"@material-ui/icons/Search\";\nimport CourseIcon from \"@material-ui/icons/LocalLibrary\";\n\nvar elasticsearch = require('elasticsearch');\n\nvar client = new elasticsearch.Client({\n host: 'http://localhost:9200/' \n // http://localhost:9200/ \n // http://root:12345@localhost:9200/ \n // If you have set username and password\n});\n\nfunction SearchPage({query}) {\n const [{ term, data }, dispatch] = useStateValue();\n const [page, setPage] = useState(1);\n const [allActive, setAllActive] = useState(\"_active\");\n const [profsOnly, setProfsOnly] = useState(\"\");\n const [coursesOnly, setCoursesOnly] = useState(\"\");\n const handleChange = (event, value) => {\n setPage(value);\n window.scrollTo(0, 0);\n };\n const location = useLocation();\n\n const queryBodyPageUpdate = {\n \"from\": (page-1)*10,\n \"size\": 10,\n \"query\": {\n \"bool\": { \n \"must\" : {\n \"multi_match\" : {\n \"query\": term ?? location['pathname'].split(\"/\")[2],\n \"fields\": profsOnly===\"_active\" ? [ \"url^3\", \"link_text\"] : coursesOnly===\"_active\" ? [ \"url^3\", \"link_text\"] : [\"body\", \"url\"],\n \"fuzziness\": 6,\n }\n },\n \"filter\": {\n \"regexp\": {\n \"url\": coursesOnly===\"_active\" ? \".*[a-zA-Z][a-zA-Z][a-zA-Z].*[1-9][0-9][0-9]\" : \".*\",\n }\n }\n }\n }\n }\n const queryBodyTermUpdate = {\n \"from\": (page-1)*10,\n \"size\": 10,\n \"query\": {\n \"bool\": { \n \"must\" : {\n \"multi_match\" : {\n \"query\": term ?? location['pathname'].split(\"/\")[2],\n \"fields\": profsOnly===\"_active\" ? [ \"url^3\", \"link_text\"] : coursesOnly===\"_active\" ? [ \"url^3\", \"link_text\"] : [\"body\", \"url\"],\n \"fuzziness\": 6,\n }\n },\n \"filter\": {\n \"regexp\": {\n \"url\": coursesOnly===\"_active\" ? \".*[a-zA-Z][a-zA-Z][a-zA-Z].*[1-9][0-9][0-9]\" : \".*\",\n }\n }\n }\n }\n }\n\n useEffect(() => {\n client.search({\n index: \"iitd_sites\", // Your index name for example crud \n body: queryBodyPageUpdate\n }).then(function (resp) {\n console.log(resp);\n dispatch({\n type: actionTypes.SET_RESULTS,\n data: resp,\n term: term,\n });\n }, function (err) {\n console.log(err.message);\n });\n }, [page, allActive, profsOnly, coursesOnly])\n\n useEffect(() => {\n setPage(1);\n client.search({\n index: \"iitd_sites\", // Your index name for example crud \n body: queryBodyTermUpdate\n }).then(function (resp) {\n console.log(resp);\n dispatch({\n type: actionTypes.SET_RESULTS,\n data: resp,\n term: term,\n });\n }, function (err) {\n console.log(err.message);\n });\n }, [term, allActive, profsOnly, coursesOnly])\n\n const allActiveCall = () => { \n setAllActive(\"_active\");\n setProfsOnly(\"\");\n setCoursesOnly(\"\");\n }\n const profsOnlyCall = () => { \n setAllActive(\"\");\n setProfsOnly(\"_active\");\n setCoursesOnly(\"\");\n }\n const coursesOnlyCall = () => { \n setAllActive(\"\");\n setProfsOnly(\"\");\n setCoursesOnly(\"_active\");\n }\n\n return (\n
    \n
    \n \n \n \n
    \n \n
    \n \"DevClub\n
    \n\n
    \n
    \n \n \n \n
    \n
    \n\n {!data && }\n {data && (\n
    \n

    \n {data['hits']['total']['value']} hits for '{term ?? location['pathname'].split(\"/\")[2]}' ({data['took']} milliseconds) ・ Couldn't find your needle? Report\n

    \n {data['hits']['hits'].map((item) => (\n
    \n \n {item['_source']['url']}\n \n {item['_source']['url'] && item['_source']['title'] && \n

    {\" \" + item['_source']['title'].slice(7, -8)}

    \n
    }\n
    \n {item['_source']['link_text']}\n
    \n
    \n ))}\n
    \n )}\n {data && data['hits']['total']['value']>0 &&
    }\n
    \n
    \n\n );\n}\n\n\nexport default SearchPage;\n","/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/search.js",["101"],"import { useState } from \"react\";\nimport { actionTypes } from \"./reducer\";\nimport { useStateValue } from \"./stateProvider\";\n\n\nvar elasticsearch = require('elasticsearch');\n\nvar client = new elasticsearch.Client({\n host: 'http://localhost:9200/' \n // http://localhost:9200/ \n // http://root:12345@localhost:9200/ \n // If you have set username and password\n});\n\n// Check if Connection is ok or not\nclient.ping({\n // ping usually has a 3000ms timeout\n requestTimeout: Infinity,\n}, function (error) {\n if (error) {\n console.trace('Elasticsearch cluster is down!');\n } else {\n console.log('Elasticsearch cluster is up!');\n }\n});\n\n\nconst Search = (term, page, size) => {\n // const [data, setData] = useState(null);\n const [searching, setState] = useState(true);\n const [{}, dispatch] = useStateValue();\n // TODO: Use a environment variable for index\n searching && client.search({\n index: \"iitd_sites\", // Your index name for example crud \n body: {\n \"from\": (page-1)*size,\n \"size\": size,\n \"query\": {\n \"match\": {\n \"body\": {\n \"query\" : term,\n }\n }\n }\n }\n }).then(function (resp) {\n setState(false);\n dispatch({\n type: actionTypes.SET_RESULTS,\n data: resp,\n term: term,\n page: page,\n });\n }, function (err) {\n console.log(err.message);\n });\n};\n\nexport default Search;","/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/pages/Footer.jsx",["102","103","104"],"import React, { useState, useEffect } from \"react\";\nimport \"./Footer.css\";\nimport { Link } from \"react-router-dom\";\nimport Paper from '@material-ui/core/Paper';\nimport Grid from '@material-ui/core/Grid';\n\nfunction Footer({ home }){\n const styles = {\n marginTop: home ? 200 : 0,\n }\n return(\n
    \n \n \n \n
    Learn how haystack works.
    \n
    \n \n \n
    Customize your haystack experience.
    \n
    \n \n \n
    Feedback.
    \n
    \n
    \n\n
    \n © DevClub 2021\n
    \n
    \n ) \n}\n\n\nexport default Footer;\n","/home/prahas/Documents/haystack/old_HayStack/search_frontend/src/pages/Search.jsx",["105","106","107"],"import React, { useState } from \"react\";\nimport \"./Search.css\";\nimport SearchIcon from \"@material-ui/icons/Search\";\nimport { Button } from \"@material-ui/core\";\nimport { useHistory } from \"react-router-dom\";\nimport { useStateValue } from \"../stateProvider\";\nimport { actionTypes } from \"../reducer\";\nimport ClearIcon from \"@material-ui/icons/Clear\";\nimport { useLocation } from 'react-router';\n\n\nfunction Search({ hideButtons = false, query = \"\", qty}) {\n const location = useLocation();\n const [{}, dispatch] = useStateValue();\n const [input, setInput] = useState(query);\n const history = useHistory();\n const handleClear = () => { setInput(\"\")}\n const search = (e) => {\n e.preventDefault();\n // console.log(\"u clicked\", input);\n dispatch({\n type: actionTypes.SET_SEARCH_TERM,\n term: input,\n });\n history.push(`/search/${input}`);\n };\n return (\n
    \n
    \n \n setInput(e.target.value)} />\n {input!=\"\" && }\n
    \n\n {!hideButtons ? (\n <>\n
    \n \n \n
    \n
    \n Index contains ~{qty} pages (soon to be much bigger)\n
    \n \n ) : (\n
    \n \n Haystack Search\n \n \n
    \n )}\n \n );\n}\n\nexport default Search;\n",["108","109"],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/index.js",[],["110","111"],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/reducer.js",[],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/stateProvider.js",[],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/App.js",[],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/Home.jsx",["112","113","114","115"],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/SearchPage.jsx",["116","117","118","119","120","121"],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/search.js",["122"],["123","124"],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/Search.jsx",["125","126","127"],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/Footer.jsx",["128","129","130"],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/SearchImg.jsx",["131","132","133","134","135","136","137"],"import React, { useState, useEffect } from \"react\";\nimport \"./SearchPage.css\";\nimport { actionTypes } from \"../reducer\";\nimport { useStateValue } from \"../stateProvider\";\nimport triggerSearch from \"../search\";\nimport { Link } from \"react-router-dom\";\nimport { useHistory } from \"react-router-dom\";\nimport { useLocation } from 'react-router';\nimport Search from \"./Search\";\nimport SearchPage from \"./SearchPage\";\nimport logo from './LogoSVGWhiteBG.svg'\nimport Pagination from '@material-ui/lab/Pagination';\nimport Footer from './Footer';\nimport qs from \"qs\";\n\nimport PersonIcon from \"@material-ui/icons/Person\";\nimport SearchIcon from \"@material-ui/icons/Search\";\nimport ImageIcon from \"@material-ui/icons/Image\";\nimport CourseIcon from \"@material-ui/icons/LocalLibrary\";\n\nvar elasticsearch = require('elasticsearch');\n\nvar client = new elasticsearch.Client({\n host: 'http://localhost:9200/' \n // http://localhost:9200/ \n // http://root:12345@localhost:9200/ \n // If you have set username and password\n});\n\nfunction SearchImg({query}) {\n const [{ term, data }, dispatch] = useStateValue();\n const [page, setPage] = useState(1);\n // const [allActive, setAllActive] = useState(\"_active\");\n // const [profsOnly, setProfsOnly] = useState(\"\");\n // const [coursesOnly, setCoursesOnly] = useState(\"\");\n const history = useHistory();\n const handleChange = (event, value) => {\n setPage(value);\n window.scrollTo(0, 0);\n };\n const location = useLocation();\n \n const queryBodyPageUpdate = {\n \"from\": (page-1)*10,\n \"size\": 10,\n \"query\": {\n \"bool\": { \n \"must\" : {\n \"multi_match\" : {\n \"query\": term ?? location['pathname'].split(\"/\")[2],\n // \"fields\": profsOnly===\"_active\" ? [ \"url^3\", \"link_text\"] : coursesOnly===\"_active\" ? [ \"url^3\", \"link_text\"] : [\"body\", \"url\"],\n \"fields\": [\"body\", \"url\"],\n \"fuzziness\": 6,\n }\n },\n // \"filter\": {\n // \"regexp\": {\n // \"url\": coursesOnly===\"_active\" ? \".*[a-zA-Z][a-zA-Z][a-zA-Z].*[1-9][0-9][0-9]\" : \".*\",\n // }\n // }\n }\n }\n }\n const queryBodyTermUpdate = {\n \"from\": (page-1)*10,\n \"size\": 10,\n \"query\": {\n \"bool\": { \n \"must\" : {\n \"multi_match\" : {\n \"query\": term ?? location['pathname'].split(\"/\")[2],\n \"fields\": [\"body\", \"url\"],\n //\"fields\": profsOnly===\"_active\" ? [ \"url^3\", \"link_text\"] : coursesOnly===\"_active\" ? [ \"url^3\", \"link_text\"] : [\"body\", \"url\"],\n \"fuzziness\": 6,\n }\n },\n // \"filter\": {\n // \"regexp\": {\n // \"url\": coursesOnly===\"_active\" ? \".*[a-zA-Z][a-zA-Z][a-zA-Z].*[1-9][0-9][0-9]\" : \".*\",\n // }\n // }\n }\n }\n }\n \n useEffect(() => {\n client.search({\n index: \"iitd_sites\", // Your index name for example crud \n body: queryBodyPageUpdate\n }).then(function (resp) {\n console.log(resp);\n dispatch({\n type: actionTypes.SET_RESULTS,\n data: resp,\n term: term,\n });\n }, function (err) {\n console.log(err.message);\n });\n }, [page])\n \n useEffect(() => {\n setPage(1);\n client.search({\n index: \"iitd_sites\", // Your index name for example crud \n body: queryBodyTermUpdate\n }).then(function (resp) {\n console.log(resp);\n dispatch({\n type: actionTypes.SET_RESULTS,\n data: resp,\n term: term,\n });\n }, function (err) {\n console.log(err.message);\n });\n }, [term])\n \n // const allActiveCall = () => { \n // setAllActive(\"_active\");\n // setProfsOnly(\"\");\n // setCoursesOnly(\"\");\n // }\n // const profsOnlyCall = () => { \n // setAllActive(\"\");\n // setProfsOnly(\"_active\");\n // setCoursesOnly(\"\");\n // }\n // const coursesOnlyCall = () => { \n // setAllActive(\"\");\n // setProfsOnly(\"\");\n // setCoursesOnly(\"_active\");\n // }\n const searchImg = (e) => {\n e.preventDefault();\n // setAllActive(\"_active\");\n // setProfsOnly(\"\");\n // setCoursesOnly(\"\");\n // console.log(\"u clicked\", input);\n dispatch({\n // type: actionTypes.SET_SEARCH_TERM,\n term: term,\n });\n history.push(`/Images/${term}`);\n }\n \n return (\n
    \n
    \n \n \n \n
    \n \n
    \n \"DevClub\n
    \n \n
    \n
    \n \n \n \n \n
    \n
    \n \n {!data && }\n {data && (\n //
    \n
    \n

    \n {data['hits']['total']['value']} hits for '{term ?? location['pathname'].split(\"/\")[2]}' ({data['took']} milliseconds) ・ Couldn't find your needle? Report\n

    \n
    \n {data['hits']['hits'].map((item) => (\n
    \n {/* \n {item['_source']['url']}\n */}\n {item['_source']['linked_img'].map((image,index) => (\n
    \n \n
    \n ))}\n {/* {item['_source']['url'] && \n \n } */}\n \n
    \n //
    \n // \n // {item['_source']['url']}\n // \n // {item['_source']['url'] && item['_source']['title'] && \n //

    {\" \" + item['_source']['title'].slice(7, -8)}

    \n //
    }\n //
    \n // {item['_source']['link_text']}\n //
    \n //
    \n ))}\n
    \n // {/*
    */}\n )}\n {data && data['hits']['total']['value']>0 &&
    }\n
    \n
    \n \n );\n }\n \n \n export default SearchImg;\n \n",{"ruleId":"138","replacedBy":"139"},{"ruleId":"140","replacedBy":"141"},{"ruleId":"142","severity":1,"message":"143","line":3,"column":10,"nodeType":"144","messageId":"145","endLine":3,"endColumn":14},{"ruleId":"142","severity":1,"message":"146","line":4,"column":8,"nodeType":"144","messageId":"145","endLine":4,"endColumn":16},{"ruleId":"142","severity":1,"message":"147","line":5,"column":10,"nodeType":"144","messageId":"145","endLine":5,"endColumn":16},{"ruleId":"148","severity":1,"message":"149","line":44,"column":9,"nodeType":"150","endLine":48,"endColumn":11},{"ruleId":"142","severity":1,"message":"151","line":5,"column":8,"nodeType":"144","messageId":"145","endLine":5,"endColumn":21},{"ruleId":"142","severity":1,"message":"152","line":12,"column":8,"nodeType":"144","messageId":"145","endLine":12,"endColumn":10},{"ruleId":"153","severity":1,"message":"154","line":94,"column":6,"nodeType":"155","endLine":94,"endColumn":47,"suggestions":"156"},{"ruleId":"153","severity":1,"message":"157","line":111,"column":6,"nodeType":"155","endLine":111,"endColumn":47,"suggestions":"158"},{"ruleId":"148","severity":1,"message":"149","line":162,"column":17,"nodeType":"150","endLine":162,"endColumn":91},{"ruleId":"148","severity":1,"message":"149","line":174,"column":19,"nodeType":"150","endLine":174,"endColumn":98},{"ruleId":"159","severity":1,"message":"160","line":31,"column":10,"nodeType":"161","messageId":"162","endLine":31,"endColumn":12},{"ruleId":"142","severity":1,"message":"163","line":1,"column":17,"nodeType":"144","messageId":"145","endLine":1,"endColumn":25},{"ruleId":"142","severity":1,"message":"164","line":1,"column":27,"nodeType":"144","messageId":"145","endLine":1,"endColumn":36},{"ruleId":"142","severity":1,"message":"165","line":4,"column":8,"nodeType":"144","messageId":"145","endLine":4,"endColumn":13},{"ruleId":"142","severity":1,"message":"166","line":13,"column":9,"nodeType":"144","messageId":"145","endLine":13,"endColumn":17},{"ruleId":"159","severity":1,"message":"160","line":14,"column":10,"nodeType":"161","messageId":"162","endLine":14,"endColumn":12},{"ruleId":"167","severity":1,"message":"168","line":32,"column":15,"nodeType":"169","messageId":"162","endLine":32,"endColumn":17},{"ruleId":"138","replacedBy":"170"},{"ruleId":"140","replacedBy":"171"},{"ruleId":"138","replacedBy":"172"},{"ruleId":"140","replacedBy":"173"},{"ruleId":"142","severity":1,"message":"143","line":3,"column":10,"nodeType":"144","messageId":"145","endLine":3,"endColumn":14},{"ruleId":"142","severity":1,"message":"146","line":4,"column":8,"nodeType":"144","messageId":"145","endLine":4,"endColumn":16},{"ruleId":"142","severity":1,"message":"147","line":5,"column":10,"nodeType":"144","messageId":"145","endLine":5,"endColumn":16},{"ruleId":"148","severity":1,"message":"149","line":44,"column":9,"nodeType":"150","endLine":48,"endColumn":11},{"ruleId":"142","severity":1,"message":"151","line":5,"column":8,"nodeType":"144","messageId":"145","endLine":5,"endColumn":21},{"ruleId":"142","severity":1,"message":"152","line":13,"column":8,"nodeType":"144","messageId":"145","endLine":13,"endColumn":10},{"ruleId":"153","severity":1,"message":"154","line":97,"column":6,"nodeType":"155","endLine":97,"endColumn":47,"suggestions":"174"},{"ruleId":"153","severity":1,"message":"157","line":114,"column":6,"nodeType":"155","endLine":114,"endColumn":47,"suggestions":"175"},{"ruleId":"148","severity":1,"message":"149","line":181,"column":17,"nodeType":"150","endLine":181,"endColumn":91},{"ruleId":"148","severity":1,"message":"149","line":193,"column":19,"nodeType":"150","endLine":193,"endColumn":98},{"ruleId":"159","severity":1,"message":"160","line":31,"column":10,"nodeType":"161","messageId":"162","endLine":31,"endColumn":12},{"ruleId":"138","replacedBy":"176"},{"ruleId":"140","replacedBy":"177"},{"ruleId":"142","severity":1,"message":"166","line":13,"column":9,"nodeType":"144","messageId":"145","endLine":13,"endColumn":17},{"ruleId":"159","severity":1,"message":"160","line":14,"column":10,"nodeType":"161","messageId":"162","endLine":14,"endColumn":12},{"ruleId":"167","severity":1,"message":"168","line":32,"column":15,"nodeType":"169","messageId":"162","endLine":32,"endColumn":17},{"ruleId":"142","severity":1,"message":"163","line":1,"column":17,"nodeType":"144","messageId":"145","endLine":1,"endColumn":25},{"ruleId":"142","severity":1,"message":"164","line":1,"column":27,"nodeType":"144","messageId":"145","endLine":1,"endColumn":36},{"ruleId":"142","severity":1,"message":"165","line":4,"column":8,"nodeType":"144","messageId":"145","endLine":4,"endColumn":13},{"ruleId":"142","severity":1,"message":"151","line":5,"column":8,"nodeType":"144","messageId":"145","endLine":5,"endColumn":21},{"ruleId":"142","severity":1,"message":"178","line":10,"column":8,"nodeType":"144","messageId":"145","endLine":10,"endColumn":18},{"ruleId":"142","severity":1,"message":"152","line":14,"column":8,"nodeType":"144","messageId":"145","endLine":14,"endColumn":10},{"ruleId":"153","severity":1,"message":"154","line":100,"column":8,"nodeType":"155","endLine":100,"endColumn":14,"suggestions":"179"},{"ruleId":"153","severity":1,"message":"157","line":117,"column":8,"nodeType":"155","endLine":117,"endColumn":14,"suggestions":"180"},{"ruleId":"148","severity":1,"message":"149","line":184,"column":19,"nodeType":"150","endLine":184,"endColumn":93},{"ruleId":"148","severity":1,"message":"149","line":199,"column":54,"nodeType":"150","endLine":199,"endColumn":101},"no-native-reassign",["181"],"no-negated-in-lhs",["182"],"no-unused-vars","'Link' is defined but never used.","Identifier","unusedVar","'AppsIcon' is defined but never used.","'Avatar' is defined but never used.","jsx-a11y/alt-text","img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.","JSXOpeningElement","'triggerSearch' is defined but never used.","'qs' is defined but never used.","react-hooks/exhaustive-deps","React Hook useEffect has missing dependencies: 'dispatch', 'queryBodyPageUpdate', and 'term'. Either include them or remove the dependency array.","ArrayExpression",["183"],"React Hook useEffect has missing dependencies: 'dispatch' and 'queryBodyTermUpdate'. Either include them or remove the dependency array.",["184"],"no-empty-pattern","Unexpected empty object pattern.","ObjectPattern","unexpected","'useState' is defined but never used.","'useEffect' is defined but never used.","'Paper' is defined but never used.","'location' is assigned a value but never used.","eqeqeq","Expected '!==' and instead saw '!='.","BinaryExpression",["181"],["182"],["181"],["182"],["185"],["186"],["181"],["182"],"'SearchPage' is defined but never used.",["187"],["188"],"no-global-assign","no-unsafe-negation",{"desc":"189","fix":"190"},{"desc":"191","fix":"192"},{"desc":"189","fix":"193"},{"desc":"191","fix":"194"},{"desc":"195","fix":"196"},{"desc":"197","fix":"198"},"Update the dependencies array to be: [page, allActive, profsOnly, coursesOnly, queryBodyPageUpdate, dispatch, term]",{"range":"199","text":"200"},"Update the dependencies array to be: [term, allActive, profsOnly, coursesOnly, queryBodyTermUpdate, dispatch]",{"range":"201","text":"202"},{"range":"203","text":"200"},{"range":"204","text":"202"},"Update the dependencies array to be: [dispatch, page, queryBodyPageUpdate, term]",{"range":"205","text":"206"},"Update the dependencies array to be: [dispatch, queryBodyTermUpdate, term]",{"range":"207","text":"208"},[2872,2913],"[page, allActive, profsOnly, coursesOnly, queryBodyPageUpdate, dispatch, term]",[3308,3349],"[term, allActive, profsOnly, coursesOnly, queryBodyTermUpdate, dispatch]",[3038,3079],[3474,3515],[3305,3311],"[dispatch, page, queryBodyPageUpdate, term]",[3740,3746],"[dispatch, queryBodyTermUpdate, term]"] \ No newline at end of file +[{"/home/prahas/Documents/haystack/hayStack/search_frontend/src/index.js":"1","/home/prahas/Documents/haystack/hayStack/search_frontend/src/stateProvider.js":"2","/home/prahas/Documents/haystack/hayStack/search_frontend/src/reducer.js":"3","/home/prahas/Documents/haystack/hayStack/search_frontend/src/App.js":"4","/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/Home.jsx":"5","/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/SearchPage.jsx":"6","/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/SearchImg.jsx":"7","/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/Footer.jsx":"8","/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/Search.jsx":"9","/home/prahas/Documents/haystack/hayStack/search_frontend/src/search.js":"10","/home/prahas/Documents/haystack/HayStack/search_frontend/src/index.js":"11","/home/prahas/Documents/haystack/HayStack/search_frontend/src/reducer.js":"12","/home/prahas/Documents/haystack/HayStack/search_frontend/src/stateProvider.js":"13","/home/prahas/Documents/haystack/HayStack/search_frontend/src/App.js":"14","/home/prahas/Documents/haystack/HayStack/search_frontend/src/pages/SearchImg.jsx":"15","/home/prahas/Documents/haystack/HayStack/search_frontend/src/pages/SearchPage.jsx":"16","/home/prahas/Documents/haystack/HayStack/search_frontend/src/pages/Home.jsx":"17","/home/prahas/Documents/haystack/HayStack/search_frontend/src/search.js":"18","/home/prahas/Documents/haystack/HayStack/search_frontend/src/pages/Footer.jsx":"19","/home/prahas/Documents/haystack/HayStack/search_frontend/src/pages/Search.jsx":"20"},{"size":613,"mtime":1627372441123,"results":"21","hashOfConfig":"22"},{"size":364,"mtime":1627372441131,"results":"23","hashOfConfig":"22"},{"size":590,"mtime":1627372441131,"results":"24","hashOfConfig":"22"},{"size":626,"mtime":1627372441123,"results":"25","hashOfConfig":"22"},{"size":1494,"mtime":1627372441123,"results":"26","hashOfConfig":"22"},{"size":9313,"mtime":1630851455898,"results":"27","hashOfConfig":"22"},{"size":8843,"mtime":1630851455898,"results":"28","hashOfConfig":"22"},{"size":1502,"mtime":1627372441123,"results":"29","hashOfConfig":"22"},{"size":2145,"mtime":1630333427189,"results":"30","hashOfConfig":"22"},{"size":1430,"mtime":1627372441131,"results":"31","hashOfConfig":"22"},{"size":613,"mtime":1627372441123,"results":"32","hashOfConfig":"33"},{"size":590,"mtime":1627372441131,"results":"34","hashOfConfig":"33"},{"size":364,"mtime":1627372441131,"results":"35","hashOfConfig":"33"},{"size":626,"mtime":1627372441123,"results":"36","hashOfConfig":"33"},{"size":8843,"mtime":1630851455898,"results":"37","hashOfConfig":"33"},{"size":9313,"mtime":1630851455898,"results":"38","hashOfConfig":"33"},{"size":1494,"mtime":1627372441123,"results":"39","hashOfConfig":"33"},{"size":1430,"mtime":1627372441131,"results":"40","hashOfConfig":"33"},{"size":1502,"mtime":1627372441123,"results":"41","hashOfConfig":"33"},{"size":2145,"mtime":1630333427189,"results":"42","hashOfConfig":"33"},{"filePath":"43","messages":"44","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1t4anou",{"filePath":"45","messages":"46","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"47","messages":"48","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"49","messages":"50","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"51","messages":"52","errorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"53","messages":"54","errorCount":0,"warningCount":8,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"55","messages":"56","errorCount":0,"warningCount":7,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"57","messages":"58","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"59","messages":"60","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"61","messages":"62","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"63","messages":"64","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"da4wpm",{"filePath":"65","messages":"66","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"67","messages":"68","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"69","messages":"70","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"71","messages":"72","errorCount":0,"warningCount":7,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"73","messages":"74","errorCount":0,"warningCount":8,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"75","messages":"76","errorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"77","messages":"78","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"79","messages":"80","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"81","messages":"82","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/home/prahas/Documents/haystack/hayStack/search_frontend/src/index.js",[],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/stateProvider.js",[],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/reducer.js",[],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/App.js",[],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/Home.jsx",["83","84","85","86"],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/SearchPage.jsx",["87","88","89","90","91","92","93","94"],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/SearchImg.jsx",["95","96","97","98","99","100","101"],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/Footer.jsx",["102","103","104"],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/pages/Search.jsx",["105","106","107"],"/home/prahas/Documents/haystack/hayStack/search_frontend/src/search.js",["108"],"/home/prahas/Documents/haystack/HayStack/search_frontend/src/index.js",[],"/home/prahas/Documents/haystack/HayStack/search_frontend/src/reducer.js",[],"/home/prahas/Documents/haystack/HayStack/search_frontend/src/stateProvider.js",[],"/home/prahas/Documents/haystack/HayStack/search_frontend/src/App.js",[],"/home/prahas/Documents/haystack/HayStack/search_frontend/src/pages/SearchImg.jsx",["109","110","111","112","113","114","115"],"/home/prahas/Documents/haystack/HayStack/search_frontend/src/pages/SearchPage.jsx",["116","117","118","119","120","121","122","123"],"/home/prahas/Documents/haystack/HayStack/search_frontend/src/pages/Home.jsx",["124","125","126","127"],"/home/prahas/Documents/haystack/HayStack/search_frontend/src/search.js",["128"],"/home/prahas/Documents/haystack/HayStack/search_frontend/src/pages/Footer.jsx",["129","130","131"],"/home/prahas/Documents/haystack/HayStack/search_frontend/src/pages/Search.jsx",["132","133","134"],{"ruleId":"135","severity":1,"message":"136","line":3,"column":10,"nodeType":"137","messageId":"138","endLine":3,"endColumn":14},{"ruleId":"135","severity":1,"message":"139","line":4,"column":8,"nodeType":"137","messageId":"138","endLine":4,"endColumn":16},{"ruleId":"135","severity":1,"message":"140","line":5,"column":10,"nodeType":"137","messageId":"138","endLine":5,"endColumn":16},{"ruleId":"141","severity":1,"message":"142","line":44,"column":9,"nodeType":"143","endLine":48,"endColumn":11},{"ruleId":"135","severity":1,"message":"144","line":6,"column":8,"nodeType":"137","messageId":"138","endLine":6,"endColumn":21},{"ruleId":"135","severity":1,"message":"145","line":14,"column":8,"nodeType":"137","messageId":"138","endLine":14,"endColumn":10},{"ruleId":"146","severity":1,"message":"147","line":119,"column":6,"nodeType":"148","endLine":119,"endColumn":47,"suggestions":"149"},{"ruleId":"146","severity":1,"message":"150","line":136,"column":6,"nodeType":"148","endLine":136,"endColumn":47,"suggestions":"151"},{"ruleId":"135","severity":1,"message":"152","line":162,"column":9,"nodeType":"137","messageId":"138","endLine":162,"endColumn":18},{"ruleId":"141","severity":1,"message":"142","line":212,"column":17,"nodeType":"143","endLine":212,"endColumn":91},{"ruleId":"141","severity":1,"message":"142","line":227,"column":54,"nodeType":"143","endLine":227,"endColumn":101},{"ruleId":"141","severity":1,"message":"142","line":244,"column":19,"nodeType":"143","endLine":244,"endColumn":98},{"ruleId":"135","severity":1,"message":"144","line":5,"column":8,"nodeType":"137","messageId":"138","endLine":5,"endColumn":21},{"ruleId":"135","severity":1,"message":"153","line":10,"column":8,"nodeType":"137","messageId":"138","endLine":10,"endColumn":18},{"ruleId":"135","severity":1,"message":"145","line":14,"column":8,"nodeType":"137","messageId":"138","endLine":14,"endColumn":10},{"ruleId":"146","severity":1,"message":"147","line":120,"column":8,"nodeType":"148","endLine":120,"endColumn":14,"suggestions":"154"},{"ruleId":"146","severity":1,"message":"150","line":137,"column":8,"nodeType":"148","endLine":137,"endColumn":14,"suggestions":"155"},{"ruleId":"141","severity":1,"message":"142","line":222,"column":19,"nodeType":"143","endLine":222,"endColumn":93},{"ruleId":"141","severity":1,"message":"142","line":237,"column":54,"nodeType":"143","endLine":237,"endColumn":101},{"ruleId":"135","severity":1,"message":"156","line":1,"column":17,"nodeType":"137","messageId":"138","endLine":1,"endColumn":25},{"ruleId":"135","severity":1,"message":"157","line":1,"column":27,"nodeType":"137","messageId":"138","endLine":1,"endColumn":36},{"ruleId":"135","severity":1,"message":"158","line":4,"column":8,"nodeType":"137","messageId":"138","endLine":4,"endColumn":13},{"ruleId":"135","severity":1,"message":"159","line":13,"column":9,"nodeType":"137","messageId":"138","endLine":13,"endColumn":17},{"ruleId":"160","severity":1,"message":"161","line":14,"column":10,"nodeType":"162","messageId":"163","endLine":14,"endColumn":12},{"ruleId":"164","severity":1,"message":"165","line":32,"column":15,"nodeType":"166","messageId":"163","endLine":32,"endColumn":17},{"ruleId":"160","severity":1,"message":"161","line":31,"column":10,"nodeType":"162","messageId":"163","endLine":31,"endColumn":12},{"ruleId":"135","severity":1,"message":"144","line":5,"column":8,"nodeType":"137","messageId":"138","endLine":5,"endColumn":21},{"ruleId":"135","severity":1,"message":"153","line":10,"column":8,"nodeType":"137","messageId":"138","endLine":10,"endColumn":18},{"ruleId":"135","severity":1,"message":"145","line":14,"column":8,"nodeType":"137","messageId":"138","endLine":14,"endColumn":10},{"ruleId":"146","severity":1,"message":"147","line":120,"column":8,"nodeType":"148","endLine":120,"endColumn":14,"suggestions":"167"},{"ruleId":"146","severity":1,"message":"150","line":137,"column":8,"nodeType":"148","endLine":137,"endColumn":14,"suggestions":"168"},{"ruleId":"141","severity":1,"message":"142","line":222,"column":19,"nodeType":"143","endLine":222,"endColumn":93},{"ruleId":"141","severity":1,"message":"142","line":237,"column":54,"nodeType":"143","endLine":237,"endColumn":101},{"ruleId":"135","severity":1,"message":"144","line":6,"column":8,"nodeType":"137","messageId":"138","endLine":6,"endColumn":21},{"ruleId":"135","severity":1,"message":"145","line":14,"column":8,"nodeType":"137","messageId":"138","endLine":14,"endColumn":10},{"ruleId":"146","severity":1,"message":"147","line":119,"column":6,"nodeType":"148","endLine":119,"endColumn":47,"suggestions":"169"},{"ruleId":"146","severity":1,"message":"150","line":136,"column":6,"nodeType":"148","endLine":136,"endColumn":47,"suggestions":"170"},{"ruleId":"135","severity":1,"message":"152","line":162,"column":9,"nodeType":"137","messageId":"138","endLine":162,"endColumn":18},{"ruleId":"141","severity":1,"message":"142","line":212,"column":17,"nodeType":"143","endLine":212,"endColumn":91},{"ruleId":"141","severity":1,"message":"142","line":227,"column":54,"nodeType":"143","endLine":227,"endColumn":101},{"ruleId":"141","severity":1,"message":"142","line":244,"column":19,"nodeType":"143","endLine":244,"endColumn":98},{"ruleId":"135","severity":1,"message":"136","line":3,"column":10,"nodeType":"137","messageId":"138","endLine":3,"endColumn":14},{"ruleId":"135","severity":1,"message":"139","line":4,"column":8,"nodeType":"137","messageId":"138","endLine":4,"endColumn":16},{"ruleId":"135","severity":1,"message":"140","line":5,"column":10,"nodeType":"137","messageId":"138","endLine":5,"endColumn":16},{"ruleId":"141","severity":1,"message":"142","line":44,"column":9,"nodeType":"143","endLine":48,"endColumn":11},{"ruleId":"160","severity":1,"message":"161","line":31,"column":10,"nodeType":"162","messageId":"163","endLine":31,"endColumn":12},{"ruleId":"135","severity":1,"message":"156","line":1,"column":17,"nodeType":"137","messageId":"138","endLine":1,"endColumn":25},{"ruleId":"135","severity":1,"message":"157","line":1,"column":27,"nodeType":"137","messageId":"138","endLine":1,"endColumn":36},{"ruleId":"135","severity":1,"message":"158","line":4,"column":8,"nodeType":"137","messageId":"138","endLine":4,"endColumn":13},{"ruleId":"135","severity":1,"message":"159","line":13,"column":9,"nodeType":"137","messageId":"138","endLine":13,"endColumn":17},{"ruleId":"160","severity":1,"message":"161","line":14,"column":10,"nodeType":"162","messageId":"163","endLine":14,"endColumn":12},{"ruleId":"164","severity":1,"message":"165","line":32,"column":15,"nodeType":"166","messageId":"163","endLine":32,"endColumn":17},"no-unused-vars","'Link' is defined but never used.","Identifier","unusedVar","'AppsIcon' is defined but never used.","'Avatar' is defined but never used.","jsx-a11y/alt-text","img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.","JSXOpeningElement","'triggerSearch' is defined but never used.","'qs' is defined but never used.","react-hooks/exhaustive-deps","React Hook useEffect has missing dependencies: 'dispatch', 'queryBodyPageUpdate', and 'term'. Either include them or remove the dependency array.","ArrayExpression",["171"],"React Hook useEffect has missing dependencies: 'dispatch' and 'queryBodyTermUpdate'. Either include them or remove the dependency array.",["172"],"'searchImg' is assigned a value but never used.","'SearchPage' is defined but never used.",["173"],["174"],"'useState' is defined but never used.","'useEffect' is defined but never used.","'Paper' is defined but never used.","'location' is assigned a value but never used.","no-empty-pattern","Unexpected empty object pattern.","ObjectPattern","unexpected","eqeqeq","Expected '!==' and instead saw '!='.","BinaryExpression",["175"],["176"],["177"],["178"],{"desc":"179","fix":"180"},{"desc":"181","fix":"182"},{"desc":"183","fix":"184"},{"desc":"185","fix":"186"},{"desc":"183","fix":"187"},{"desc":"185","fix":"188"},{"desc":"179","fix":"189"},{"desc":"181","fix":"190"},"Update the dependencies array to be: [page, allActive, profsOnly, coursesOnly, queryBodyPageUpdate, dispatch, term]",{"range":"191","text":"192"},"Update the dependencies array to be: [term, allActive, profsOnly, coursesOnly, queryBodyTermUpdate, dispatch]",{"range":"193","text":"194"},"Update the dependencies array to be: [dispatch, page, queryBodyPageUpdate, term]",{"range":"195","text":"196"},"Update the dependencies array to be: [dispatch, queryBodyTermUpdate, term]",{"range":"197","text":"198"},{"range":"199","text":"196"},{"range":"200","text":"198"},{"range":"201","text":"192"},{"range":"202","text":"194"},[3593,3634],"[page, allActive, profsOnly, coursesOnly, queryBodyPageUpdate, dispatch, term]",[4029,4070],"[term, allActive, profsOnly, coursesOnly, queryBodyTermUpdate, dispatch]",[3727,3733],"[dispatch, page, queryBodyPageUpdate, term]",[4162,4168],"[dispatch, queryBodyTermUpdate, term]",[3727,3733],[4162,4168],[3593,3634],[4029,4070]] \ No newline at end of file diff --git a/search_frontend/package-lock.json b/search_frontend/package-lock.json index c281233..747f34a 100644 --- a/search_frontend/package-lock.json +++ b/search_frontend/package-lock.json @@ -5515,6 +5515,21 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.1.0.tgz", "integrity": "sha512-LsTgx/L5VpD+Q8lmsXSHW2WpA+eBlZ9HPf3erD1IoPF00/3JKHZ3BknUVA2QGDNu69ZNmyFmCWBSO45XjYKC5w==" + }, + "domhandler": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.2.tgz", + "integrity": "sha512-PzE9aBMsdZO8TK4BnuJwH0QT41wgMbRzuZrHUcpYncEjmQazq8QEaBWgLG7ZyC/DAZKEgglpIA6j4Qn/HmxS3w==", + "requires": { + "domelementtype": "^2.2.0" + }, + "dependencies": { + "domelementtype": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", + "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==" + } + } } } }, @@ -7689,6 +7704,30 @@ "resolved": "https://registry.npmjs.org/html-comment-regex/-/html-comment-regex-1.1.2.tgz", "integrity": "sha512-P+M65QY2JQ5Y0G9KKdlDpo0zK+/OHptU5AaBwUfAIDJZk1MYf32Frm84EcOytfJE0t5JvkAnKlmjsXDnWzCJmQ==" }, + "html-dom-parser": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/html-dom-parser/-/html-dom-parser-1.0.1.tgz", + "integrity": "sha512-uKXISKlHzB/l9A08jrs2wseQJ9b864ZfEdmIZskj10cuP6HxCOMHSK0RdluV8NVQaWs0PwefN7d8wqG3jR0IbQ==", + "requires": { + "domhandler": "4.2.0", + "htmlparser2": "6.1.0" + }, + "dependencies": { + "domelementtype": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", + "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==" + }, + "domhandler": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.0.tgz", + "integrity": "sha512-zk7sgt970kzPks2Bf+dwT/PLzghLnsivb9CcxkvR8Mzr66Olr0Ofd8neSbglHJHaHa2MadfoSdNlKYAaafmWfA==", + "requires": { + "domelementtype": "^2.2.0" + } + } + } + }, "html-encoding-sniffer": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz", @@ -7721,6 +7760,32 @@ "terser": "^4.6.3" } }, + "html-react-parser": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/html-react-parser/-/html-react-parser-1.2.7.tgz", + "integrity": "sha512-gUUEgrZV0YaCxtZO2XuJDUnHSq7gOqKu1krye97cxgiZ+ipaIzspGMhATeq9lhy9gwYmwBF2YCHe/accrMMo8Q==", + "requires": { + "domhandler": "4.2.0", + "html-dom-parser": "1.0.1", + "react-property": "1.0.1", + "style-to-js": "1.1.0" + }, + "dependencies": { + "domelementtype": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", + "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==" + }, + "domhandler": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.0.tgz", + "integrity": "sha512-zk7sgt970kzPks2Bf+dwT/PLzghLnsivb9CcxkvR8Mzr66Olr0Ofd8neSbglHJHaHa2MadfoSdNlKYAaafmWfA==", + "requires": { + "domelementtype": "^2.2.0" + } + } + } + }, "html-webpack-plugin": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-4.5.0.tgz", @@ -7767,22 +7832,48 @@ } }, "htmlparser2": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz", - "integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", + "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==", "requires": { - "domelementtype": "^1.3.1", - "domhandler": "^2.3.0", - "domutils": "^1.5.1", - "entities": "^1.1.1", - "inherits": "^2.0.1", - "readable-stream": "^3.1.1" + "domelementtype": "^2.0.1", + "domhandler": "^4.0.0", + "domutils": "^2.5.2", + "entities": "^2.0.0" }, "dependencies": { - "entities": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", - "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==" + "dom-serializer": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz", + "integrity": "sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==", + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^4.2.0", + "entities": "^2.0.0" + } + }, + "domelementtype": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", + "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==" + }, + "domhandler": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.2.tgz", + "integrity": "sha512-PzE9aBMsdZO8TK4BnuJwH0QT41wgMbRzuZrHUcpYncEjmQazq8QEaBWgLG7ZyC/DAZKEgglpIA6j4Qn/HmxS3w==", + "requires": { + "domelementtype": "^2.2.0" + } + }, + "domutils": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz", + "integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==", + "requires": { + "dom-serializer": "^1.0.1", + "domelementtype": "^2.2.0", + "domhandler": "^4.2.0" + } } } }, @@ -8118,6 +8209,11 @@ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" }, + "inline-style-parser": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.1.1.tgz", + "integrity": "sha512-7NXolsK4CAS5+xvdj5OMMbI962hU/wvwoxk+LWR9Ek9bVtyuuYScDN6eS0rUm6TxApFpw7CX1o4uJzcd4AyD3Q==" + }, "internal-ip": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/internal-ip/-/internal-ip-4.3.0.tgz", @@ -13287,6 +13383,11 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, + "react-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/react-property/-/react-property-1.0.1.tgz", + "integrity": "sha512-1tKOwxFn3dXVomH6pM9IkLkq2Y8oh+fh/lYW3MJ/B03URswUTqttgckOlbxY2XHF3vPG6uanSc4dVsLW/wk3wQ==" + }, "react-refresh": { "version": "0.8.3", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.8.3.tgz", @@ -13664,6 +13765,24 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" }, + "entities": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", + "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==" + }, + "htmlparser2": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz", + "integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==", + "requires": { + "domelementtype": "^1.3.1", + "domhandler": "^2.3.0", + "domutils": "^1.5.1", + "entities": "^1.1.1", + "inherits": "^2.0.1", + "readable-stream": "^3.1.1" + } + }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", @@ -15194,6 +15313,22 @@ "schema-utils": "^2.7.0" } }, + "style-to-js": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/style-to-js/-/style-to-js-1.1.0.tgz", + "integrity": "sha512-1OqefPDxGrlMwcbfpsTVRyzwdhr4W0uxYQzeA2F1CBc8WG04udg2+ybRnvh3XYL4TdHQrCahLtax2jc8xaE6rA==", + "requires": { + "style-to-object": "0.3.0" + } + }, + "style-to-object": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-0.3.0.tgz", + "integrity": "sha512-CzFnRRXhzWIdItT3OmF8SQfWyahHhjq3HwcMNCNLn+N7klOOqPjMeG/4JSu77D7ypZdGvSzvkrbyeTMizz2VrA==", + "requires": { + "inline-style-parser": "0.1.1" + } + }, "stylehacks": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/stylehacks/-/stylehacks-4.0.3.tgz", diff --git a/search_frontend/package.json b/search_frontend/package.json index 929ec7c..06de8ec 100644 --- a/search_frontend/package.json +++ b/search_frontend/package.json @@ -3,6 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { + "html-react-parser": "^1.2.7", "@elastic/elasticsearch": "^7.10.0", "@material-ui/core": "^4.11.3", "@material-ui/icons": "^4.11.2", diff --git a/search_frontend/src/pages/Footer.css b/search_frontend/src/pages/Footer.css index 4f19e01..fde1b66 100644 --- a/search_frontend/src/pages/Footer.css +++ b/search_frontend/src/pages/Footer.css @@ -44,7 +44,6 @@ .fine_text{ text-decoration: none; padding:20px; - width: 100%; text-align: center; margin: auto; } diff --git a/search_frontend/src/pages/Search.jsx b/search_frontend/src/pages/Search.jsx index b8484d5..506d077 100644 --- a/search_frontend/src/pages/Search.jsx +++ b/search_frontend/src/pages/Search.jsx @@ -40,7 +40,9 @@ function Search({ hideButtons = false, query = "", qty}) { +
    + Index contains ~{qty} pages (soon to be much bigger)
    diff --git a/search_frontend/src/pages/SearchImg.jsx b/search_frontend/src/pages/SearchImg.jsx index 21b09ad..b0fa4bd 100644 --- a/search_frontend/src/pages/SearchImg.jsx +++ b/search_frontend/src/pages/SearchImg.jsx @@ -59,7 +59,17 @@ function SearchImg({query}) { // } // } } - } + }, + "highlight" : { + "pre_tags" : [""], + "post_tags" : [""], + "fields" : { + "body" : {} + } + }, + "sort" :[ + { "visits":{"order":"desc"} } + ] } const queryBodyTermUpdate = { "from": (page-1)*10, @@ -80,7 +90,17 @@ function SearchImg({query}) { // } // } } - } + }, + "highlight" : { + "pre_tags" : [""], + "post_tags" : [""], + "fields" : { + "body" : {} + } + }, + "sort" :[ + { "visits":{"order":"desc"} } + ] } useEffect(() => { @@ -116,21 +136,39 @@ function SearchImg({query}) { }); }, [term]) - // const allActiveCall = () => { - // setAllActive("_active"); + const allActiveCall = (e) => { + e.preventDefault(); + // setAllActive("_active"); // setProfsOnly(""); - // setCoursesOnly(""); - // } - // const profsOnlyCall = () => { + // setCoursesOnly("") + dispatch({ + // type: actionTypes.SET_SEARCH_TERM, + term: term, + }); + history.push(`/search/${term}`);; + } + const profsOnlyCall = (e) => { + e.preventDefault(); // setAllActive(""); // setProfsOnly("_active"); // setCoursesOnly(""); - // } - // const coursesOnlyCall = () => { + dispatch({ + // type: actionTypes.SET_SEARCH_TERM, + term: term, + }); + history.push(`/search/${term}`); + } + const coursesOnlyCall = (e) => { + e.preventDefault(); // setAllActive(""); // setProfsOnly(""); // setCoursesOnly("_active"); - // } + dispatch({ + // type: actionTypes.SET_SEARCH_TERM, + term: term, + }); + history.push(`/search/${term}`); + } const searchImg = (e) => { e.preventDefault(); // setAllActive("_active"); @@ -162,15 +200,15 @@ function SearchImg({query}) {
    - - - @@ -194,7 +232,7 @@ function SearchImg({query}) { {/* {item['_source']['url']} */} - {item['_source']['linked_img'].map((image,index) => ( + {item['_source']['linked_images']["img"].map((image,index) => (
    @@ -204,17 +242,7 @@ function SearchImg({query}) { } */}
    - //
    - // - // {item['_source']['url']} - // - // {item['_source']['url'] && item['_source']['title'] && - //

    {" " + item['_source']['title'].slice(7, -8)}

    - //
    } - //
    - // {item['_source']['link_text']} - //
    - //
    + ))}
    // {/* */} diff --git a/search_frontend/src/pages/SearchPage.css b/search_frontend/src/pages/SearchPage.css index c451deb..89b94fa 100644 --- a/search_frontend/src/pages/SearchPage.css +++ b/search_frontend/src/pages/SearchPage.css @@ -127,8 +127,7 @@ position: relative; vertical-align: top; grid-template-columns: 1fr 1fr 1fr 1fr; - align-items: center; - justify-content: center; + white-space: normal; width: 100%; } @@ -175,7 +174,9 @@ font-weight: 300 !important; font-size: 0.9em !important; } - +.foundElement>b{ + font-weight: 800; +} .searchPage__resultLink { align-items: center; text-decoration: none; diff --git a/search_frontend/src/pages/SearchPage.jsx b/search_frontend/src/pages/SearchPage.jsx index 1eb9d07..deaeeb6 100644 --- a/search_frontend/src/pages/SearchPage.jsx +++ b/search_frontend/src/pages/SearchPage.jsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from "react"; import "./SearchPage.css"; import { actionTypes } from "../reducer"; +import parse from 'html-react-parser'; import { useStateValue } from "../stateProvider"; import triggerSearch from "../search"; import { Link } from "react-router-dom"; @@ -26,12 +27,13 @@ var client = new elasticsearch.Client({ // If you have set username and password }); -function SearchPage({query, all="_active",profs="",courses=""}) { +function SearchPage({query, all="_active",profs="",courses="", images=""}) { const [{ term, data }, dispatch] = useStateValue(); const [page, setPage] = useState(1); const [allActive, setAllActive] = useState(all); const [profsOnly, setProfsOnly] = useState(profs); const [coursesOnly, setCoursesOnly] = useState(courses); + const [imagesOnly, setImagesOnly] = useState(images); const history = useHistory(); const handleChange = (event, value) => { setPage(value); @@ -44,40 +46,60 @@ function SearchPage({query, all="_active",profs="",courses=""}) { "size": 10, "query": { "bool": { - "must" : { - "multi_match" : { - "query": term ?? location['pathname'].split("/")[2], - "fields": profsOnly==="_active" ? [ "url^3", "link_text"] : coursesOnly==="_active" ? [ "url^3", "link_text"] : ["body", "url"], - "fuzziness": 6, - } - }, - "filter": { - "regexp": { - "url": coursesOnly==="_active" ? ".*[a-zA-Z][a-zA-Z][a-zA-Z].*[1-9][0-9][0-9]" : ".*", - } - } + "must" : { + "multi_match" : { + "query": term ?? location['pathname'].split("/")[2], + "fields": profsOnly==="_active" ? [ "url^3", "body"] : coursesOnly==="_active" ? [ "url^3", "body"] :["body"], + "fuzziness": "AUTO", + } + }, + "filter": { + "regexp": { + "url": coursesOnly==="_active" ? ".*[a-zA-Z][a-zA-Z][a-zA-Z].*[1-9][0-9][0-9]" : ".*", + } + } } - } + }, + "highlight" : { + "pre_tags" : [""], + "post_tags" : [""], + "fields" : { + "body" : {} + } + }, + "sort" :[ + { "visits":{"order":"desc"} } + ] } const queryBodyTermUpdate = { "from": (page-1)*10, "size": 10, "query": { "bool": { - "must" : { - "multi_match" : { - "query": term ?? location['pathname'].split("/")[2], - "fields": profsOnly==="_active" ? [ "url^3", "link_text"] : coursesOnly==="_active" ? [ "url^3", "link_text"] : ["body", "url"], - "fuzziness": 6, - } - }, - "filter": { - "regexp": { - "url": coursesOnly==="_active" ? ".*[a-zA-Z][a-zA-Z][a-zA-Z].*[1-9][0-9][0-9]" : ".*", - } - } + "must" : { + "multi_match" : { + "query": term ?? location['pathname'].split("/")[2], + "fields": profsOnly==="_active" ? [ "url^3", "body"] : coursesOnly==="_active" ? [ "url^3", "body"] :["body"], + "fuzziness": "AUTO", + } + }, + "filter": { + "regexp": { + "url": coursesOnly==="_active" ? ".*[a-zA-Z][a-zA-Z][a-zA-Z].*[1-9][0-9][0-9]" : ".*", + } + } + }, + }, + "highlight" : { + "pre_tags" : [""], + "post_tags" : [""], + "fields" : { + "body" : {} } - } + }, + "sort" :[ + { "visits":{"order":"desc"} } + ] } useEffect(() => { @@ -117,16 +139,25 @@ function SearchPage({query, all="_active",profs="",courses=""}) { setAllActive("_active"); setProfsOnly(""); setCoursesOnly(""); + setImagesOnly(""); } const profsOnlyCall = () => { setAllActive(""); setProfsOnly("_active"); setCoursesOnly(""); + setImagesOnly(""); } const coursesOnlyCall = () => { setAllActive(""); setProfsOnly(""); setCoursesOnly("_active"); + setImagesOnly(""); + } + const imagesOnlyCall = () => { + setAllActive(""); + setProfsOnly(""); + setCoursesOnly(""); + setImagesOnly("_active"); } const searchImg = (e) => { //e.preventDefault(); @@ -159,19 +190,19 @@ function SearchPage({query, all="_active",profs="",courses=""}) {
    - - + - + - @@ -183,20 +214,47 @@ function SearchPage({query, all="_active",profs="",courses=""}) {

    {data['hits']['total']['value']} hits for '{term ?? location['pathname'].split("/")[2]}' ({data['took']} milliseconds) ・ Couldn't find your needle? Report -

    - {data['hits']['hits'].map((item) => ( +

    + + {imagesOnly==='_active'? + data['hits']['hits'].map((item) => ( +
    + {/* + {item['_source']['url']} + */} + {item['_source']['linked_images']["img"].map((image,index) => ( +
    + +
    + ))} + {/* {item['_source']['url'] && + + } */} + +
    + + )) + : + data['hits']['hits'].map((item) => (
    - + linkClicked(item['_source'])}> {item['_source']['url']} - {item['_source']['url'] && item['_source']['title'] && -

    {" " + item['_source']['title'].slice(7, -8)}

    + {item['_source']['url'] && item['_source']['title'] &&
    linkClicked(item['_source'])}> +

    {" " + item['_source']['title']}

    } -
    - {item['_source']['link_text']} -
    + {item['highlight']['body'].map((found) =>( +
    +
    {parse(found)}
    + + {/*
    */} +
    + ))} +
    VISITS: {item['_source']['visits']}
    - ))} + ))} + +
    )} {data && data['hits']['total']['value']>0 &&
    } @@ -205,8 +263,20 @@ function SearchPage({query, all="_active",profs="",courses=""}) { ); } + +function linkClicked(item) +{ +alert(item["visits"]); +client.update({ + index: "iitd_sites", + id:item["url"], + body: { + doc:{ + visits:item["visits"]+1 + } + } +}); +} export default SearchPage; - -