Popular New Releases in Search Engine
elasticsearch
Elasticsearch 8.1.3
MeiliSearch
v0.25.2
elasticsearch-analysis-ik
v8.1.2
Fuse
searx
1.0.0
Popular Libraries in Search Engine
by elastic java
59266 NOASSERTION
Free and Open, Distributed, RESTful Search Engine
by meilisearch rust
20889 MIT
Powerful, fast, and an easy to use search engine
by medcl java
13516 Apache-2.0
The IK Analysis plugin integrates Lucene IK analyzer into elasticsearch, support customized dictionary.
by krisk javascript
12628 Apache-2.0
Lightweight fuzzy-search, in JavaScript
by valeriansaliou rust
11888 MPL-2.0
π¦ Fast, lightweight & schema-less search backend. An alternative to Elasticsearch that runs on a few MBs of RAM.
by searx python
10396 AGPL-3.0
Privacy-respecting metasearch engine
by milvus-io go
10097 Apache-2.0
An open-source vector database for scalable similarity search and AI applications.
by typesense c++
9551 GPL-3.0
Open Source alternative to Algolia and an Easier-to-Use alternative to ElasticSearch β‘ π β¨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences
by seatgeek python
8138 GPL-2.0
Fuzzy String Matching in Python
Trending New libraries in Search Engine
by benbusby python
4865 MIT
A self-hosted, ad-free, privacy-respecting metasearch engine
by opensearch-project java
4846 Apache-2.0
π Open source distributed and RESTful search engine.
by qdrant rust
1316 Apache-2.0
Qdrant - vector similarity search engine with extended filtering support
by amirgamil go
1162 MIT
A Unix-style personal search engine and web crawler for your digital footprint.
by quickwit-inc rust
1123 NOASSERTION
Quickwit is a fast and cost-efficient distributed search engine for large-scale, immutable data.
by apache java
759 Apache-2.0
Apache Lucene open-source search software
by thesephist javascript
725 MIT
Universal personal search engine, powered by a full text search algorithm written in pure Ink, indexing Linus's blogs and private note archives, contacts, tweets, and over a decade of journals.
by ajitid typescript
509 BSD-3-Clause
Do fuzzy matching using FZF algorithm in JavaScript
by bleroy csharp
453 MIT
A port of LUNR.js to .NET Core
Top Authors in Search Engine
1
18 Libraries
1034
2
17 Libraries
7986
3
17 Libraries
59657
4
15 Libraries
741
5
12 Libraries
979
6
9 Libraries
85
7
9 Libraries
688
8
8 Libraries
93
9
8 Libraries
7099
10
7 Libraries
153
1
18 Libraries
1034
2
17 Libraries
7986
3
17 Libraries
59657
4
15 Libraries
741
5
12 Libraries
979
6
9 Libraries
85
7
9 Libraries
688
8
8 Libraries
93
9
8 Libraries
7099
10
7 Libraries
153
Trending Kits in Search Engine
Java Search Engine Libraries are used to make search engines for specific applications. It is the most popular language in the world, and it is also a platform for many other applications. The search engine libraries have been designed to provide quality results and fast response times. A Java search engine library is a collection of algorithms that allows you to quickly and easily create your own custom-built searches. These libraries are designed to allow programmers who do not have extensive knowledge of computer science to implement their own searches. Elasticsearch is a distributed RESTful search engine capable of solving many use cases encountered when searching large volumes of data held in an elasticsearch cluster. It combines the scalability and flexibility of NoSQL with the power of search so you can make sense of your data. OpenSearch provides an abstraction layer for a number of search APIs including Google, Bing, Yahoo and Yandex. It allows you to easily write your own implementation of a search engine and plug it into your application by just adding a few lines of code. The macrobase library was created by the Google Search team, which means that it's well tested and very stable. This library allows you to build scalable search engines without having to worry about the details of indexing, searching and ranking results. Full list of the best open source Java Search Engine Libraries are below.
JavaScript search engine libraries can be used to create custom search engines. These search engine libraries can be used to create custom search engines. They are easy to install and use, and they have a simple code base that you can customize according to your needs. Some of the most popular JavaScript search engine libraries include Algolia, Google Autocomplete, etc. Jets.js is a JavaScript library which allows developers to easily create their own search engine using Express and Elasticsearch. It supports all major browsers including IE8+, Firefox, Chrome, Safari and Opera. Jets helps developers implement common features like autocomplete and autocapitalization in their applications using a simple API. ambar is a jQuery-based library that uses Google's Custom Search Engine for results, but it also allows you to use other engines such as Bing, Yahoo!, DuckDuckGo, etc... It also comes with support for highlighting matches in the page content textarea element which makes it more user-friendly than other libraries. The following is a comprehensive list of the best open source JavaScript search engine libraries.
Ruby Search Engines are an area of Ruby programming that gets less attention than it deserves. Itβs a great way to get started with Ruby, and search engines can be used for a variety of things. It is really simple to use and does not require any special setup. The use of Ruby Search Engine libraries is an effective way to enhance your websiteβs visibility in search engines. These libraries come with a number of methods that can be used to improve the visibility of your website. Meta tags are used to describe a page and its content in HTML. They help users find relevant information on the Internet and also help search engines index websites efficiently. Meta tags are an important part of building a website and should not be overlooked. he retire method allows you to remove content from search results by telling the search engine that it is obsolete or irrelevant. This can be useful if you have pages on your site that need to be removed from searches but do not want them deleted completely from your site because they may still be useful in other ways. Search cops are another way of reducing the impact of low quality content on search engine rankings by penalizing sites with a high ratio of spammy pages in their index. The idea behind this method is simple: if there are many spammy pages on one site then this affects all other. The following is a list of the most popular open source Ruby Search Engines libraries:
The Python search engine libraries are the most commonly used search engine APIs to perform the crawling and indexing of web pages. A python search engine library is a collection of classes and functions that you can use to build your own search engine. sis is a Python library for developing statistical natural language processing tools. It is an open source project and has been developed by IBM's Columbia University research lab. The main aim of this project is to provide a flexible API for researchers and developers who want to create their own NLP tools. Mwmbl is an open source project that provides a Python API for the well-known Apache Mahout Machine Learning Library. The iffse project (if this, then that) is an open source project providing a simple way to write search rules in natural language. Check out the list of free, open source Python search engine libraries to help you with your projects.
C# Search Engine libraries are very useful in helping developers to build search engines. There are many libraries available for the purpose and they can be used to build search engines. These libraries provide the functionality to search books, e-books and scientific articles from different repositories like PubMed, Google Scholar etc. The user can easily search for a specific document, filter the results based on different parameters and download the result as a file or save it in an XML file. The most popular C# Search Engine library is Lucenenet which is open source and a very flexible tool. Lucene can be used to build a full-blown search engine or just for simple tasks like searching for keywords in a string. SymSpell is a lightweight spell checker library for .NET written in C# which uses the Microsoft Word dictionary data files as its source of verification against words from any other dictionary file or any custom word list file (e.g., Wikipedia). Resinis a simple but powerful indexer that supports many features such as fuzzy search, spell checking, and auto-correction. It also works well with Unity's built-in filesystem API and allows you to customize how your data is stored in memory through a custom implementation of IStorageProvider. The entire list of open source C# Search Engine libraries are provided below.
The use of a library for searching is important in C++ because it allows you to get all the functionality needed for searching from a single location, instead of having to write everything yourself. It helps avoid code duplication and makes your program easier to maintain. C++ Search Engine libraries like typesense, annoy, nanoflann are great for providing fast and easy-to-use search functionality. Typesense is a library for building search engines in C++. It uses the same algorithm as Lucene (the Java library used in Elasticsearch) and has very similar APIs. The biggest difference between Typesense and Lucene is that Typesense uses compile-time reflection to generate code for each indexing operation and uses template metaprogramming to generate code for the query engine. Nanoflann is a C++ template library with bindings in other languages such as C#, Java and Python. The library provides support for approximate nearest neighbors queries on multi-dimensional data sets stored in binary formats such as BLASTER XML or HDF5 with multithreaded computation. The following is a list of the most popular C++ Search Engine libraries,
The Go Search Engine libraries provide the search engine capabilities in your web application. These libraries are widely used in the development of different types of applications such as web search engines, social networking sites, and online shopping websites. The Go Search Engine library is a collection of packages that allow you to implement various search algorithms within your application. The main aim of this library is to allow developers to create their own custom search engine without having to re-invent the wheel. Zinc is a Go library for building web crawlers. It is a library for building high-performance cloud-native applications that needs real-time access to data from multiple sources such as databases or message queues with low latency and high throughput requirements. Magnetico is a simple search engine library written in Go. Riot is a simple, fast and efficient search engine which can be used to build real-time distributed applications. Some of the most popular Go Search Engine libraries among developers are,
PHP Search Engine libraries are the tools used to create search engines in PHP. These libraries can be used to find documents on a website, or to perform a search on large amounts of data. They provide the user with a wide range of tools that can be used to create search engines with ease. These libraries allow you to create complex search engines, which perform multiple tasks like sorting, pagination, ranking, caching, spell checking and much more! diskover-community is another very popular php library for searching through websites or documents. It has been developed by YOOtheme team and can be used for searching through websites or documents. The best part about this library is that it supports multiple search engines like Google, Bing, Yahoo etc. ElasticSuite is another PHP library that helps you to search through your data using ElasticSearch or Solr server(s). tntsearch is a very popular php library for searching through websites. It is developed by Thomas Rabaix and can be used for searching through websites or documents. Some of the most widely used open source PHP Search Engine libraries among developers include,
Trending Discussions on Search Engine
Does CRAN (or any of its relatives) have an API?
Can I improve memory efficiency of a dictionary with recurring values
Redux toolkit store reset automatically in navigating between pages in next js
.htaccess redirect based on a part of URL
Firefox could not install the search engine fromβ¦
Execute two functions with one button click
Customized label and Emphasis label overlap
How to do a non-text based search on a datatable when a select changes
Angular SSR with Universal and Ionic doesn't show actual data in page source
Why is blazor HeadOutlet rendering after the App
QUESTION
Does CRAN (or any of its relatives) have an API?
Asked 2022-Mar-22 at 16:11I am interested in retieving machine readable meta information about R packages.
For example, when I go to CRAN I can see a short description about the package, before I download it: https://cran.r-project.org/web/packages/MASS/
I could not find any way to retrieve a different output from the CRAN server than HTML. I would like to avoid parsing HTML and instead somehow retrieve meta information about packages in a more convenient format (e.g., JSON).
I saw that each R package (at least to my knowledge) has a yaml-like (?) description text inside its source code package (the file is called DESCRIPTION
). However, so far I could only find this kind of description inside tar archives, which means that I would have to download the package before I can access its description.
Here an example of the DESCRIPTION
from the MASS package:
1Package: MASS
2Priority: recommended
3Version: 7.3-55
4Date: 2022-01-12
5Revision: $Rev: 3559 $
6Depends: R (>= 3.3.0), grDevices, graphics, stats, utils
7Imports: methods
8Suggests: lattice, nlme, nnet, survival
9Authors@R: c(person("Brian", "Ripley", role = c("aut", "cre", "cph"),
10 email = "ripley@stats.ox.ac.uk"),
11 person("Bill", "Venables", role = "ctb"),
12 person(c("Douglas", "M."), "Bates", role = "ctb"),
13 person("Kurt", "Hornik", role = "trl",
14 comment = "partial port ca 1998"),
15 person("Albrecht", "Gebhardt", role = "trl",
16 comment = "partial port ca 1998"),
17 person("David", "Firth", role = "ctb"))
18Description: Functions and datasets to support Venables and Ripley,
19 "Modern Applied Statistics with S" (4th edition, 2002).
20Title: Support Functions and Datasets for Venables and Ripley's MASS
21LazyData: yes
22ByteCompile: yes
23License: GPL-2 | GPL-3
24URL: http://www.stats.ox.ac.uk/pub/MASS4/
25Contact: <MASS@stats.ox.ac.uk>
26NeedsCompilation: yes
27Packaged: 2022-01-13 05:06:37 UTC; ripley
28Author: Brian Ripley [aut, cre, cph],
29 Bill Venables [ctb],
30 Douglas M. Bates [ctb],
31 Kurt Hornik [trl] (partial port ca 1998),
32 Albrecht Gebhardt [trl] (partial port ca 1998),
33 David Firth [ctb]
34Maintainer: Brian Ripley <ripley@stats.ox.ac.uk>
35Repository: CRAN
36Date/Publication: 2022-01-13 08:05:04 UTC
37
Any suggestions how to get that directly in a machine-readable and convenient form?
I tried to look it up, but search engines did not bring me any useful result so far.
Edit / Clarification: I am looking for a solution that does not rely on R, but rather a web API that is agnostic of the used framework / language for meta data retrieval.
ANSWER
Answered 2022-Mar-22 at 14:38An acceptable solution is the METACRAN API that is available here: https://crandb.r-pkg.org/
QUESTION
Can I improve memory efficiency of a dictionary with recurring values
Asked 2022-Mar-07 at 12:45I am working on a search engine implementation in Python, and would ideally like to store as much of an inverted index into memory.
The current data structure of the index is as follows:
{term: [doc_frequency, {doc_number: [doc_positions]}]}
, where term
is a string and doc_frequency
, doc_number
and doc_positions
are integers. The size of this blows up really quickly for multiple documents.
As the document numbers and positions are frequently recurring integers for different terms, I was thinking if there is a way to leverage this characteristic by not storing a new integer every time but just referencing to the same integer multiple times?
I'm not an expert in data structures or Python at all, so forgive me if this is a stupid question. If there are any other suggestions than my specific question that could improve the memory usage, those are more than welcome as well.
ANSWER
Answered 2022-Mar-07 at 12:45I am afraid that storing a pointer (reference) to an integer instead of an integer will not help as the size of the pointer is most probably 64 bits on your system (might be 32 if you are using 32bit python).
Python uses variable sizes of integers but on average it should be less or equal than 64 bits per integer. If you are most frequently use small numbers, see: https://www.pythontutorial.net/advanced-python/python-integers/.
If you can work with some limited range of integer, you can try to use numpy with dtype specified see: https://numpy.org/devdocs/user/basics.types.html. However you will probably need to change the structure of your storage.
QUESTION
Redux toolkit store reset automatically in navigating between pages in next js
Asked 2022-Feb-09 at 19:52I'm a new Next user and have been using Redux with React for a long time I had a lot of trouble in using Redux with Next
I'm done with this solution
store.js
1import { configureStore } from '@reduxjs/toolkit';
2import reducers from './rootReducer';
3
4export function makeStore() {
5 return configureStore({
6 reducer: reducers,
7 });
8}
9
10const store = makeStore();
11
12export default store;
13
rootReducer.js
1import { configureStore } from '@reduxjs/toolkit';
2import reducers from './rootReducer';
3
4export function makeStore() {
5 return configureStore({
6 reducer: reducers,
7 });
8}
9
10const store = makeStore();
11
12export default store;
13import { combineReducers } from '@reduxjs/toolkit';
14import tes from './test/tes';
15
16const reducers = combineReducers({
17 test: tes,
18});
19
20export default reducers;
21
_app.js
1import { configureStore } from '@reduxjs/toolkit';
2import reducers from './rootReducer';
3
4export function makeStore() {
5 return configureStore({
6 reducer: reducers,
7 });
8}
9
10const store = makeStore();
11
12export default store;
13import { combineReducers } from '@reduxjs/toolkit';
14import tes from './test/tes';
15
16const reducers = combineReducers({
17 test: tes,
18});
19
20export default reducers;
21import React from 'react';
22import { Provider } from 'react-redux';
23import store from '../redux/store';
24import { createWrapper } from 'next-redux-wrapper';
25
26const MyApp = ({ Component, ...rest }) => {
27 return (
28 <Provider store={store}>
29 <Component {...rest} />
30 </Provider>
31 );
32};
33const makestore = () => store;
34const wrapper = createWrapper(makestore);
35
36export default wrapper.withRedux(MyApp);
37
But I discovered that any use of the useDispatch Inside any page, the search engine does not recognize the content of the page after fetching the data
1import { configureStore } from '@reduxjs/toolkit';
2import reducers from './rootReducer';
3
4export function makeStore() {
5 return configureStore({
6 reducer: reducers,
7 });
8}
9
10const store = makeStore();
11
12export default store;
13import { combineReducers } from '@reduxjs/toolkit';
14import tes from './test/tes';
15
16const reducers = combineReducers({
17 test: tes,
18});
19
20export default reducers;
21import React from 'react';
22import { Provider } from 'react-redux';
23import store from '../redux/store';
24import { createWrapper } from 'next-redux-wrapper';
25
26const MyApp = ({ Component, ...rest }) => {
27 return (
28 <Provider store={store}>
29 <Component {...rest} />
30 </Provider>
31 );
32};
33const makestore = () => store;
34const wrapper = createWrapper(makestore);
35
36export default wrapper.withRedux(MyApp);
37import React, { useEffect } from 'react';
38import { Test } from '../../redux/test/tes';
39import { useDispatch, useSelector } from 'react-redux';
40import Link from 'next/link';
41
42function TestPage() {
43 const dispatch = useDispatch();
44 const { data } = useSelector((state) => state.test);
45 useEffect(() => {
46 dispatch(Test('hi'));
47 }, []);
48 return (
49 <div>
50 <Link href="/">
51 <a>home</a>
52 </Link>{' '}
53 {data.map((name) => (
54 <h1>{name.title}</h1>
55 ))}
56 </div>
57 );
58}
59
60export default TestPage;
61
One of the next pre-render methods must be used
I wonder if this is normal with next
or there Is a better way for doing that?
#1 Update
Now after moving data fetching to getStaticProps
TestPage.js
1import { configureStore } from '@reduxjs/toolkit';
2import reducers from './rootReducer';
3
4export function makeStore() {
5 return configureStore({
6 reducer: reducers,
7 });
8}
9
10const store = makeStore();
11
12export default store;
13import { combineReducers } from '@reduxjs/toolkit';
14import tes from './test/tes';
15
16const reducers = combineReducers({
17 test: tes,
18});
19
20export default reducers;
21import React from 'react';
22import { Provider } from 'react-redux';
23import store from '../redux/store';
24import { createWrapper } from 'next-redux-wrapper';
25
26const MyApp = ({ Component, ...rest }) => {
27 return (
28 <Provider store={store}>
29 <Component {...rest} />
30 </Provider>
31 );
32};
33const makestore = () => store;
34const wrapper = createWrapper(makestore);
35
36export default wrapper.withRedux(MyApp);
37import React, { useEffect } from 'react';
38import { Test } from '../../redux/test/tes';
39import { useDispatch, useSelector } from 'react-redux';
40import Link from 'next/link';
41
42function TestPage() {
43 const dispatch = useDispatch();
44 const { data } = useSelector((state) => state.test);
45 useEffect(() => {
46 dispatch(Test('hi'));
47 }, []);
48 return (
49 <div>
50 <Link href="/">
51 <a>home</a>
52 </Link>{' '}
53 {data.map((name) => (
54 <h1>{name.title}</h1>
55 ))}
56 </div>
57 );
58}
59
60export default TestPage;
61import React from 'react';
62import { Test } from '../../redux/test/tes';
63import { useSelector } from 'react-redux';
64import Link from 'next/link';
65import { wrapper } from '../../redux/store';
66
67function TestPage({ pageProps }) {
68 const { data } = useSelector((state) => state.test);
69 console.log(data);
70
71 return (
72 <div>
73 <Link href="/">
74 <a>home</a>
75 </Link>{' '}
76 {data && data.map((name) => (
77 <h1>{name.name}</h1>
78 ))}
79 </div>
80 );
81}
82export const getStaticProps = wrapper.getStaticProps(
83 (store) => async (context) => {
84 const loading = store.getState().test.loading;
85 if (loading === 'idle') {
86 await store.dispatch(Test('hi'));
87
88 }
89
90 return {
91 props: { },
92 };
93 }
94);
95
96export default TestPage;
97
The problem now is that the store is not updating
useSelector return []
Although console.log (data)
from getStaticProps the data is present
__NEXT_REDUX_WRAPPER_HYDRATE__
i'm stuck
#2 Update
It was really hard to get here and after that, there are still problems getting Redux with Next js
Now everything works until navigating to any page have getStaticProps
or getServerProps
state getting reset automatically
store.js
1import { configureStore } from '@reduxjs/toolkit';
2import reducers from './rootReducer';
3
4export function makeStore() {
5 return configureStore({
6 reducer: reducers,
7 });
8}
9
10const store = makeStore();
11
12export default store;
13import { combineReducers } from '@reduxjs/toolkit';
14import tes from './test/tes';
15
16const reducers = combineReducers({
17 test: tes,
18});
19
20export default reducers;
21import React from 'react';
22import { Provider } from 'react-redux';
23import store from '../redux/store';
24import { createWrapper } from 'next-redux-wrapper';
25
26const MyApp = ({ Component, ...rest }) => {
27 return (
28 <Provider store={store}>
29 <Component {...rest} />
30 </Provider>
31 );
32};
33const makestore = () => store;
34const wrapper = createWrapper(makestore);
35
36export default wrapper.withRedux(MyApp);
37import React, { useEffect } from 'react';
38import { Test } from '../../redux/test/tes';
39import { useDispatch, useSelector } from 'react-redux';
40import Link from 'next/link';
41
42function TestPage() {
43 const dispatch = useDispatch();
44 const { data } = useSelector((state) => state.test);
45 useEffect(() => {
46 dispatch(Test('hi'));
47 }, []);
48 return (
49 <div>
50 <Link href="/">
51 <a>home</a>
52 </Link>{' '}
53 {data.map((name) => (
54 <h1>{name.title}</h1>
55 ))}
56 </div>
57 );
58}
59
60export default TestPage;
61import React from 'react';
62import { Test } from '../../redux/test/tes';
63import { useSelector } from 'react-redux';
64import Link from 'next/link';
65import { wrapper } from '../../redux/store';
66
67function TestPage({ pageProps }) {
68 const { data } = useSelector((state) => state.test);
69 console.log(data);
70
71 return (
72 <div>
73 <Link href="/">
74 <a>home</a>
75 </Link>{' '}
76 {data && data.map((name) => (
77 <h1>{name.name}</h1>
78 ))}
79 </div>
80 );
81}
82export const getStaticProps = wrapper.getStaticProps(
83 (store) => async (context) => {
84 const loading = store.getState().test.loading;
85 if (loading === 'idle') {
86 await store.dispatch(Test('hi'));
87
88 }
89
90 return {
91 props: { },
92 };
93 }
94);
95
96export default TestPage;
97import reducers from './rootReducer';
98import { configureStore } from '@reduxjs/toolkit';
99import { createWrapper, HYDRATE } from 'next-redux-wrapper';
100
101const reducer = (state, action) => {
102 if (action.type === HYDRATE) {
103 let nextState = {
104 ...state,
105 ...action.payload,
106 };
107 return nextState;
108 } else {
109 return reducers(state, action);
110 }
111};
112
113const isDev = process.env.NODE_ENV === 'development';
114
115const makeStore = (context) => {
116 let middleware = [];
117
118 const store = configureStore({
119 reducer,
120 middleware: (getDefaultMiddleware) =>
121 getDefaultMiddleware().concat(middleware),
122 devTools: isDev,
123 preloadedState: undefined,
124 });
125
126 return store;
127};
128
129export const wrapper = createWrapper(makeStore, { debug: isDev });
130
ANSWER
Answered 2022-Feb-05 at 09:401.) Does using Redux with Nextjs eliminate the SEO advantage?
No, using Redux with NextJs does not hinder the SEO advantage. Redux goes well with NextJS.
The problem lies with your implementation of the data fetching. NextJS does not see the fetched content, because you need to fetch it in either getInitialProps
, getServerSideProps
, or getStaticProps
depending on the way you want your app to work.
See the Data Fetching documentation from NextJS.
Note that getServerSideProps
and getStaticProps
are the recommended ways of dealing with data fetching.
If you go for getStaticProps
, you will need getStaticPaths
. Check this answer to see use cases and the difference between the getStaticPaths
and getStaticProps
as it can be confusing.
TLDR; Instead of putting the data fetching in a useEffect hook, move it inside a getServerSideProps
or a getStaticProps
function.
QUESTION
.htaccess redirect based on a part of URL
Asked 2022-Jan-26 at 21:29After site crash a redirect php script doesn't work as expected. We try to fix it, but in the meantime we are looking for a quick solution to redirect search engine results so our visitors can at least visit after clicking a relative web page.
The url structure or the search engines result are something like this:
1https://www.example.com/MainCategory/SubCategory_1/SubCategory_2/Product?page=1
2
and I'd like to redirect using the "SubCategory_2" part of the URL to something like this
1https://www.example.com/MainCategory/SubCategory_1/SubCategory_2/Product?page=1
2https://www.example.com/SubCategory_2.php
3
so until we fully repair the script at least our visitors will se a relative web page.
I'm quite stuck... Any ideas? Thank you
ANSWER
Answered 2022-Jan-26 at 21:29To redirect the stated URL, where all parts are variable (including an entirely variable, but present query string) then you can do something like the following using mod_rewrite near the top of your root .htaccess
file (or crucially, before any existing internal rewrites):
1https://www.example.com/MainCategory/SubCategory_1/SubCategory_2/Product?page=1
2https://www.example.com/SubCategory_2.php
3RewriteEngine On
4
5RewriteCond %{QUERY_STRING} .
6RewriteRule ^[^/]+/[^/]+/([^/]+)/[^/]+$ /$1.php [QSD,R=302,L]
7
The QSD
flag is necessary to discard the original query string from the redirected response.
The above will redirect:
/MainCategory/SubCategory_1/SubCategory_2/Product?page=1
to/SubCategory_2.php
/foo/bar/baz/qux?something
to/baz.php
You can test it here using this htaccess tester.
UPDATE:
unfortunately without success. I get 404 error.
You'll get a 404 if the directive did not match the requested URL, or /SubCategory_2.php
does not exist.
Is the URL redirected? What do you see in the browser's address bar?
If there was no redirect then the above rule did not match the requested URL and the rule did nothing. Either because:
- The URL format is not as stated in the question.
- The rule is in the wrong place in the
.htaccess
file. As stated, this rule needs to be near the top of the config file.
I found a basic solution here htaccess redirect if URL contains a certain string I crate something like this
RewriteRule ^(.*)SubCategory_2(.*)$ https://example.com/SubCategory_2.php[L,R=301]
and works just fine. My problem is that this is a "static solution" since "SubCategory_2" is a variable.
Ok, but that is a very generic (arguably "too generic") solution for the problem you appear to be attempting to solve. This matches "SubCategory_2" anywhere in the URL-path (not just whole path segments) and preserves any query string (present on your example URL) through the redirect. So, this would not perform the stated redirect on the example URL in your question.
However, the directive you've posted (which you say "works just fine") cannot possibly work as written, at least not by itself. Ignoring the missing space (a typo I assume) before the flags argument, this would result in an endless redirect loop, since the target URL /SubCategory_2.php
also matches the regex ^(.*)SubCategory_2(.*)$
.
Also, should this be a 301 (permanent) redirect? You seem to imply this is a "temporary" solution?
HOWEVER, it's not technically possible to make "SubCategory_2" entirely variable in this "basic solution" and search for this variable "something" in a larger string and redirect to "something.php". How do you know that you have found the correct part of a much larger URL? You need to be more specific about what you are searching for.
In your original question you are extracting the 3rd path segment in a URL-path that consists of 4 path segments and a query string. That is a perfectly reasonable pattern, but you can't extract "something" when you don't know what or where "something" is.
QUESTION
Firefox could not install the search engine fromβ¦
Asked 2022-Jan-20 at 20:20I'm trying to make APLcart work with OpenSearch, but keep getting Firefox could not install the search engine from: https://aplcart.info/opensearch.xml
with:
1<link rel="search" type="application/opensearchdescription+xml" title="APLcart"
2href="/opensearch.xml">
3
Where /opensearch.xml
is:
1<link rel="search" type="application/opensearchdescription+xml" title="APLcart"
2href="/opensearch.xml">
3<OpenSearchDescription>
4<ShortName>APLcart</ShortName>
5<Description>
6Search APLcart: A novel approach to finding your way in APL
7</Description>
8<InputEncoding>UTF-8</InputEncoding>
9<Image width="16" height="16" type="image/x-icon">https://aplcart.info/favicon.ico</Image>
10<Url type="text/html" template="https://aplcart.info/?q={searchTerms}"/>
11</OpenSearchDescription>
12
- Note that this is not the same issue, since I do have
Url type="text/html"
. - I've tried with
method="get"
What do I need to change for my OpenSearch specification to be compliant?
ANSWER
Answered 2022-Jan-20 at 20:20You have to use the correct namespace
1<link rel="search" type="application/opensearchdescription+xml" title="APLcart"
2href="/opensearch.xml">
3<OpenSearchDescription>
4<ShortName>APLcart</ShortName>
5<Description>
6Search APLcart: A novel approach to finding your way in APL
7</Description>
8<InputEncoding>UTF-8</InputEncoding>
9<Image width="16" height="16" type="image/x-icon">https://aplcart.info/favicon.ico</Image>
10<Url type="text/html" template="https://aplcart.info/?q={searchTerms}"/>
11</OpenSearchDescription>
12<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
13
If you open the browser console (CTRL+Shift+J) you can see the error message
Invalid search plugin due to namespace not matching.
QUESTION
Execute two functions with one button click
Asked 2021-Dec-31 at 01:28I'm having a time trying to figure this one out. First, let me say I'm a total javascript novice, but I haven't figured this out. I want to run two separate functions, both referencing the value in the search box created in the code. The idea is, the script will search for the value in the search box, opening up 2 new tabs, each searching the value accompanied by different secondary terms prescribed in the code. What do I need to get this script to run?
1<!DOCTYPE html>
2<html lang="en">
3 <head>
4 <meta charset="UTF-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7 <title>Programmable Search Engine Two</title>
8 <link rel="stylesheet" href="style.css" />
9 </head>
10 <body>
11 <section>
12 <div class="main">
13 <div class="searchBox">
14 <input type="text" name="" class="query" value="" />
15 </div>
16 <div class="button">
17 <button class="searchBtn">Search</button>
18 </div>
19 </div>
20 </section>
21
22<script type="text/javascript">
23
24let query = document.querySelector(".query");
25 let searchBtn = document.querySelector(".searchBtn");
26
27 searchBtn.onclick = "function One(); function Two();"
28
29 function One() {
30 let url = "https://www.google.com/search?q=" + query.value + " " + "hotels";
31 window.open(url, (target = "blank"))
32
33 },
34
35 function Two() {
36 let url = "https://www.google.com/search?q=" + query.value + " " + "hotels";
37 window.open(url, (target = "blank"))
38
39 };
40
41</script>
42
43 </body>
44</html>
45
46
ANSWER
Answered 2021-Dec-31 at 01:05You should change
1<!DOCTYPE html>
2<html lang="en">
3 <head>
4 <meta charset="UTF-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7 <title>Programmable Search Engine Two</title>
8 <link rel="stylesheet" href="style.css" />
9 </head>
10 <body>
11 <section>
12 <div class="main">
13 <div class="searchBox">
14 <input type="text" name="" class="query" value="" />
15 </div>
16 <div class="button">
17 <button class="searchBtn">Search</button>
18 </div>
19 </div>
20 </section>
21
22<script type="text/javascript">
23
24let query = document.querySelector(".query");
25 let searchBtn = document.querySelector(".searchBtn");
26
27 searchBtn.onclick = "function One(); function Two();"
28
29 function One() {
30 let url = "https://www.google.com/search?q=" + query.value + " " + "hotels";
31 window.open(url, (target = "blank"))
32
33 },
34
35 function Two() {
36 let url = "https://www.google.com/search?q=" + query.value + " " + "hotels";
37 window.open(url, (target = "blank"))
38
39 };
40
41</script>
42
43 </body>
44</html>
45
46searchBtn.onclick = "function One(); function Two();"
47
to
1<!DOCTYPE html>
2<html lang="en">
3 <head>
4 <meta charset="UTF-8" />
5 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7 <title>Programmable Search Engine Two</title>
8 <link rel="stylesheet" href="style.css" />
9 </head>
10 <body>
11 <section>
12 <div class="main">
13 <div class="searchBox">
14 <input type="text" name="" class="query" value="" />
15 </div>
16 <div class="button">
17 <button class="searchBtn">Search</button>
18 </div>
19 </div>
20 </section>
21
22<script type="text/javascript">
23
24let query = document.querySelector(".query");
25 let searchBtn = document.querySelector(".searchBtn");
26
27 searchBtn.onclick = "function One(); function Two();"
28
29 function One() {
30 let url = "https://www.google.com/search?q=" + query.value + " " + "hotels";
31 window.open(url, (target = "blank"))
32
33 },
34
35 function Two() {
36 let url = "https://www.google.com/search?q=" + query.value + " " + "hotels";
37 window.open(url, (target = "blank"))
38
39 };
40
41</script>
42
43 </body>
44</html>
45
46searchBtn.onclick = "function One(); function Two();"
47searchBtn.addEventListener('click', function() {
48 One();
49 Two();
50})
51
QUESTION
Customized label and Emphasis label overlap
Asked 2021-Dec-13 at 03:19I try to make the pie chart show 'customized label',change label when the mouse triggered. But except blue data everything else will overlap with 'emphasis label'.
'avoidLabelOverlap' not working.
Is there way?
enter image description here
enter image description here
this is a example
1var option = {
2 tooltip: {
3 trigger: 'item'
4 },
5 legend: {
6 top: '5%',
7 left: 'center'
8 },
9 series: [
10 {
11 name: 'Access From',
12 type: 'pie',
13 radius: ['40%', '70%'],
14 avoidLabelOverlap: false,
15 itemStyle: {
16 borderRadius: 10,
17 borderColor: '#fff',
18 borderWidth: 2
19 },
20 label: {
21 show: true,
22 position: 'center',
23 formatter: function (params) {
24 var html = 'TEST';
25 return html;
26 }
27 },
28 emphasis: {
29 label: {
30 show: true,
31 fontSize: '40',
32 fontWeight: 'bold'
33 }
34 },
35 labelLine: {
36 show: false
37 },
38 data: [
39 { value: 1048, name: 'Search Engine' },
40 { value: 735, name: 'Direct' },
41 { value: 580, name: 'Email' },
42 { value: 484, name: 'Union Ads' },
43 { value: 300, name: 'Video Ads' }
44 ]
45 }
46 ]
47};
48
ANSWER
Answered 2021-Nov-18 at 09:07I think there's no way to solve this problem.
QUESTION
How to do a non-text based search on a datatable when a select changes
Asked 2021-Dec-07 at 01:25I am trying to filter the datatable column status
via select when the content of the column is not a text.
What I've tried so far:
Basically I tried using the search engine this way:
1$('#search2').on('change', () =>
2{
3 DT1.search($('#search2').val()).draw();
4});
5
But as is obvious, if we compare a String with a 'colored square' there is no result.
How can I do so that if the user selects Active, only the green squares are shown and if the user selects inactive, only the red squares are shown?
Any help will be highly appreciated
ANSWER
Answered 2021-Dec-07 at 01:25Not the most optimal way I can write in a rush at late night though thought I'd provide a working solution in case no one else does.
1$('#search2').on('change', () =>
2{
3 DT1.search($('#search2').val()).draw();
4});
5$(document).ready(function() {
6 var DT1 = $('#example').DataTable({
7 columnDefs: [{
8 orderable: false,
9 className: 'select-checkbox',
10 targets: 0,
11 }],
12 select: {
13 style: 'os',
14 selector: 'td:first-child'
15 },
16 order: [
17 [1, 'asc']
18 ],
19 dom: 'lrt'
20 });
21 $(".selectAll").on("click", function(e) {
22 if ($(this).is(":checked")) {
23 DT1.rows().select();
24 } else {
25 DT1.rows().deselect();
26 }
27 });
28
29 $('#search').on('input', () => {
30 DT1.search($('#search').val()).draw();
31 });
32 $('#search2').on('change', () => {
33 const state = $("#search2").val();
34 if (state === "none") {
35 $(".status-active").parent().parent().attr("hidden", false);
36 $(".status-inactive").parent().parent().attr("hidden", false);
37 return;
38 }
39
40 $(".status-" + ((state === "active") ? 'inactive' : 'active')).parent().parent().attr("hidden", true);
41 $(".status-" + state).parent().parent().attr("hidden", false);
42
43 });
44});
1$('#search2').on('change', () =>
2{
3 DT1.search($('#search2').val()).draw();
4});
5$(document).ready(function() {
6 var DT1 = $('#example').DataTable({
7 columnDefs: [{
8 orderable: false,
9 className: 'select-checkbox',
10 targets: 0,
11 }],
12 select: {
13 style: 'os',
14 selector: 'td:first-child'
15 },
16 order: [
17 [1, 'asc']
18 ],
19 dom: 'lrt'
20 });
21 $(".selectAll").on("click", function(e) {
22 if ($(this).is(":checked")) {
23 DT1.rows().select();
24 } else {
25 DT1.rows().deselect();
26 }
27 });
28
29 $('#search').on('input', () => {
30 DT1.search($('#search').val()).draw();
31 });
32 $('#search2').on('change', () => {
33 const state = $("#search2").val();
34 if (state === "none") {
35 $(".status-active").parent().parent().attr("hidden", false);
36 $(".status-inactive").parent().parent().attr("hidden", false);
37 return;
38 }
39
40 $(".status-" + ((state === "active") ? 'inactive' : 'active')).parent().parent().attr("hidden", true);
41 $(".status-" + state).parent().parent().attr("hidden", false);
42
43 });
44});body {
45 font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
46 margin: 0;
47 padding: 0;
48 color: #333;
49 background-color: #fff;
50}
51
52.status-active {
53 height: 25px;
54 width: 25px;
55 background-color: #385C0B;
56 margin: 0 auto;
57}
58
59.status-inactive {
60 height: 25px;
61 width: 25px;
62 background-color: #CC000C;
63 margin: 0 auto;
64}
1$('#search2').on('change', () =>
2{
3 DT1.search($('#search2').val()).draw();
4});
5$(document).ready(function() {
6 var DT1 = $('#example').DataTable({
7 columnDefs: [{
8 orderable: false,
9 className: 'select-checkbox',
10 targets: 0,
11 }],
12 select: {
13 style: 'os',
14 selector: 'td:first-child'
15 },
16 order: [
17 [1, 'asc']
18 ],
19 dom: 'lrt'
20 });
21 $(".selectAll").on("click", function(e) {
22 if ($(this).is(":checked")) {
23 DT1.rows().select();
24 } else {
25 DT1.rows().deselect();
26 }
27 });
28
29 $('#search').on('input', () => {
30 DT1.search($('#search').val()).draw();
31 });
32 $('#search2').on('change', () => {
33 const state = $("#search2").val();
34 if (state === "none") {
35 $(".status-active").parent().parent().attr("hidden", false);
36 $(".status-inactive").parent().parent().attr("hidden", false);
37 return;
38 }
39
40 $(".status-" + ((state === "active") ? 'inactive' : 'active')).parent().parent().attr("hidden", true);
41 $(".status-" + state).parent().parent().attr("hidden", false);
42
43 });
44});body {
45 font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
46 margin: 0;
47 padding: 0;
48 color: #333;
49 background-color: #fff;
50}
51
52.status-active {
53 height: 25px;
54 width: 25px;
55 background-color: #385C0B;
56 margin: 0 auto;
57}
58
59.status-inactive {
60 height: 25px;
61 width: 25px;
62 background-color: #CC000C;
63 margin: 0 auto;
64}<!DOCTYPE html>
65<html>
66
67<head>
68 <meta name="description" content="stackoverflow" />
69 <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
70
71 <link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
72 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
73 <script src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>
74 <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/select/1.3.3/js/dataTables.select.min.js"></script>
75 <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>
76 <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.3.3/css/select.dataTables.min.css">
77
78 <meta charset=utf-8 />
79 <title>DataTables - JS Bin</title>
80</head>
81
82<body>
83
84
85 <div class="container">
86 <div class="row">
87 <div class="form-inline">
88 <input id="search" title="Search" placeholder="Search" class="filter-input form-control form-control-sm m-2" type="text" name="filter-project" value="">
89 <select id="search2" name="expense_category" class="form-control form-control-sm m-2">
90 <option value="none">Select a Status</option>
91 <option value="active">Active</option>
92 <option value="inactive">Inactive</option>
93 </select>
94 </div>
95 <table id="example" class="display nowrap" width="100%">
96 <thead>
97 <tr>
98 <th class="text-center"><input type="checkbox" class="selectAll" name="selectAll" value="all"></th>
99 <th>Name</th>
100 <th>Status</th>
101 <th>Office</th>
102 <th>Age</th>
103 <th>Start date</th>
104 <th>Salary</th>
105 </tr>
106 </thead>
107
108 <tbody>
109 <tr>
110 <td></td>
111 <td>Tiger Nixon</td>
112 <td>
113 <div class="status-active" title="Active"></div>
114 </td>
115 <td>Edinburgh</td>
116 <td>61</td>
117 <td>2011/04/25</td>
118 <td>$3,120</td>
119 </tr>
120 <tr>
121 <td></td>
122 <td>Garrett Winters</td>
123 <td>
124 <div class="status-active" title="Active"></div>
125 </td>
126 <td>Edinburgh</td>
127 <td>63</td>
128 <td>2011/07/25</td>
129 <td>$5,300</td>
130 </tr>
131 <tr>
132 <td></td>
133 <td>Donna Snider</td>
134 <td>
135 <div class="status-inactive"></div>
136 </td>
137 <td>New York</td>
138 <td>27</td>
139 <td>2011/01/25</td>
140 <td>$3,120</td>
141 </tr>
142 </tbody>
143 </table>
144 </div>
145</body>
146
147</html>
We are focusing primarily on the event handler for when the status dropdown is changed.
1$('#search2').on('change', () =>
2{
3 DT1.search($('#search2').val()).draw();
4});
5$(document).ready(function() {
6 var DT1 = $('#example').DataTable({
7 columnDefs: [{
8 orderable: false,
9 className: 'select-checkbox',
10 targets: 0,
11 }],
12 select: {
13 style: 'os',
14 selector: 'td:first-child'
15 },
16 order: [
17 [1, 'asc']
18 ],
19 dom: 'lrt'
20 });
21 $(".selectAll").on("click", function(e) {
22 if ($(this).is(":checked")) {
23 DT1.rows().select();
24 } else {
25 DT1.rows().deselect();
26 }
27 });
28
29 $('#search').on('input', () => {
30 DT1.search($('#search').val()).draw();
31 });
32 $('#search2').on('change', () => {
33 const state = $("#search2").val();
34 if (state === "none") {
35 $(".status-active").parent().parent().attr("hidden", false);
36 $(".status-inactive").parent().parent().attr("hidden", false);
37 return;
38 }
39
40 $(".status-" + ((state === "active") ? 'inactive' : 'active')).parent().parent().attr("hidden", true);
41 $(".status-" + state).parent().parent().attr("hidden", false);
42
43 });
44});body {
45 font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
46 margin: 0;
47 padding: 0;
48 color: #333;
49 background-color: #fff;
50}
51
52.status-active {
53 height: 25px;
54 width: 25px;
55 background-color: #385C0B;
56 margin: 0 auto;
57}
58
59.status-inactive {
60 height: 25px;
61 width: 25px;
62 background-color: #CC000C;
63 margin: 0 auto;
64}<!DOCTYPE html>
65<html>
66
67<head>
68 <meta name="description" content="stackoverflow" />
69 <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
70
71 <link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
72 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
73 <script src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>
74 <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/select/1.3.3/js/dataTables.select.min.js"></script>
75 <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>
76 <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.3.3/css/select.dataTables.min.css">
77
78 <meta charset=utf-8 />
79 <title>DataTables - JS Bin</title>
80</head>
81
82<body>
83
84
85 <div class="container">
86 <div class="row">
87 <div class="form-inline">
88 <input id="search" title="Search" placeholder="Search" class="filter-input form-control form-control-sm m-2" type="text" name="filter-project" value="">
89 <select id="search2" name="expense_category" class="form-control form-control-sm m-2">
90 <option value="none">Select a Status</option>
91 <option value="active">Active</option>
92 <option value="inactive">Inactive</option>
93 </select>
94 </div>
95 <table id="example" class="display nowrap" width="100%">
96 <thead>
97 <tr>
98 <th class="text-center"><input type="checkbox" class="selectAll" name="selectAll" value="all"></th>
99 <th>Name</th>
100 <th>Status</th>
101 <th>Office</th>
102 <th>Age</th>
103 <th>Start date</th>
104 <th>Salary</th>
105 </tr>
106 </thead>
107
108 <tbody>
109 <tr>
110 <td></td>
111 <td>Tiger Nixon</td>
112 <td>
113 <div class="status-active" title="Active"></div>
114 </td>
115 <td>Edinburgh</td>
116 <td>61</td>
117 <td>2011/04/25</td>
118 <td>$3,120</td>
119 </tr>
120 <tr>
121 <td></td>
122 <td>Garrett Winters</td>
123 <td>
124 <div class="status-active" title="Active"></div>
125 </td>
126 <td>Edinburgh</td>
127 <td>63</td>
128 <td>2011/07/25</td>
129 <td>$5,300</td>
130 </tr>
131 <tr>
132 <td></td>
133 <td>Donna Snider</td>
134 <td>
135 <div class="status-inactive"></div>
136 </td>
137 <td>New York</td>
138 <td>27</td>
139 <td>2011/01/25</td>
140 <td>$3,120</td>
141 </tr>
142 </tbody>
143 </table>
144 </div>
145</body>
146
147</html>$('#search2').on('change', () =>
148{
149 const state = $("#search2").val();
150 if (state === "none") {
151 $(".status-active").parent().parent().attr("hidden", false);
152 $(".status-inactive").parent().parent().attr("hidden", false);
153 return;
154 }
155
156 $(".status-" + ((state === "active") ? 'inactive' : 'active')).parent().parent().attr("hidden", true);
157 $(".status-" + state).parent().parent().attr("hidden", false);
158
159});
160
First, we fetch the state of the dropdown menu and what is selected by fetching the value of the selection with .val()
, this will give us either active
, inactive
, or none
. (I made the necessary adjustment to your HTML dropdown to add these values.)
With this information, we know what type of filtering we need to do.
Updating StatesIf no status is selected (none
) then we unhide all rows by fetching every element with the classes .status-active
and .status-inactive
, this is done in the following manner:
1$('#search2').on('change', () =>
2{
3 DT1.search($('#search2').val()).draw();
4});
5$(document).ready(function() {
6 var DT1 = $('#example').DataTable({
7 columnDefs: [{
8 orderable: false,
9 className: 'select-checkbox',
10 targets: 0,
11 }],
12 select: {
13 style: 'os',
14 selector: 'td:first-child'
15 },
16 order: [
17 [1, 'asc']
18 ],
19 dom: 'lrt'
20 });
21 $(".selectAll").on("click", function(e) {
22 if ($(this).is(":checked")) {
23 DT1.rows().select();
24 } else {
25 DT1.rows().deselect();
26 }
27 });
28
29 $('#search').on('input', () => {
30 DT1.search($('#search').val()).draw();
31 });
32 $('#search2').on('change', () => {
33 const state = $("#search2").val();
34 if (state === "none") {
35 $(".status-active").parent().parent().attr("hidden", false);
36 $(".status-inactive").parent().parent().attr("hidden", false);
37 return;
38 }
39
40 $(".status-" + ((state === "active") ? 'inactive' : 'active')).parent().parent().attr("hidden", true);
41 $(".status-" + state).parent().parent().attr("hidden", false);
42
43 });
44});body {
45 font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
46 margin: 0;
47 padding: 0;
48 color: #333;
49 background-color: #fff;
50}
51
52.status-active {
53 height: 25px;
54 width: 25px;
55 background-color: #385C0B;
56 margin: 0 auto;
57}
58
59.status-inactive {
60 height: 25px;
61 width: 25px;
62 background-color: #CC000C;
63 margin: 0 auto;
64}<!DOCTYPE html>
65<html>
66
67<head>
68 <meta name="description" content="stackoverflow" />
69 <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
70
71 <link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
72 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
73 <script src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>
74 <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/select/1.3.3/js/dataTables.select.min.js"></script>
75 <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>
76 <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.3.3/css/select.dataTables.min.css">
77
78 <meta charset=utf-8 />
79 <title>DataTables - JS Bin</title>
80</head>
81
82<body>
83
84
85 <div class="container">
86 <div class="row">
87 <div class="form-inline">
88 <input id="search" title="Search" placeholder="Search" class="filter-input form-control form-control-sm m-2" type="text" name="filter-project" value="">
89 <select id="search2" name="expense_category" class="form-control form-control-sm m-2">
90 <option value="none">Select a Status</option>
91 <option value="active">Active</option>
92 <option value="inactive">Inactive</option>
93 </select>
94 </div>
95 <table id="example" class="display nowrap" width="100%">
96 <thead>
97 <tr>
98 <th class="text-center"><input type="checkbox" class="selectAll" name="selectAll" value="all"></th>
99 <th>Name</th>
100 <th>Status</th>
101 <th>Office</th>
102 <th>Age</th>
103 <th>Start date</th>
104 <th>Salary</th>
105 </tr>
106 </thead>
107
108 <tbody>
109 <tr>
110 <td></td>
111 <td>Tiger Nixon</td>
112 <td>
113 <div class="status-active" title="Active"></div>
114 </td>
115 <td>Edinburgh</td>
116 <td>61</td>
117 <td>2011/04/25</td>
118 <td>$3,120</td>
119 </tr>
120 <tr>
121 <td></td>
122 <td>Garrett Winters</td>
123 <td>
124 <div class="status-active" title="Active"></div>
125 </td>
126 <td>Edinburgh</td>
127 <td>63</td>
128 <td>2011/07/25</td>
129 <td>$5,300</td>
130 </tr>
131 <tr>
132 <td></td>
133 <td>Donna Snider</td>
134 <td>
135 <div class="status-inactive"></div>
136 </td>
137 <td>New York</td>
138 <td>27</td>
139 <td>2011/01/25</td>
140 <td>$3,120</td>
141 </tr>
142 </tbody>
143 </table>
144 </div>
145</body>
146
147</html>$('#search2').on('change', () =>
148{
149 const state = $("#search2").val();
150 if (state === "none") {
151 $(".status-active").parent().parent().attr("hidden", false);
152 $(".status-inactive").parent().parent().attr("hidden", false);
153 return;
154 }
155
156 $(".status-" + ((state === "active") ? 'inactive' : 'active')).parent().parent().attr("hidden", true);
157 $(".status-" + state).parent().parent().attr("hidden", false);
158
159});
160$(".status-active").parent().parent().attr("hidden", false);
161
The $(".status-active")
fetches all rows with the active class, and gets the parent of the parent which gives us the row element itself, and sets the hidden
attribute to false
, making it visible.
Here is the code that actually does the filtering:
1$('#search2').on('change', () =>
2{
3 DT1.search($('#search2').val()).draw();
4});
5$(document).ready(function() {
6 var DT1 = $('#example').DataTable({
7 columnDefs: [{
8 orderable: false,
9 className: 'select-checkbox',
10 targets: 0,
11 }],
12 select: {
13 style: 'os',
14 selector: 'td:first-child'
15 },
16 order: [
17 [1, 'asc']
18 ],
19 dom: 'lrt'
20 });
21 $(".selectAll").on("click", function(e) {
22 if ($(this).is(":checked")) {
23 DT1.rows().select();
24 } else {
25 DT1.rows().deselect();
26 }
27 });
28
29 $('#search').on('input', () => {
30 DT1.search($('#search').val()).draw();
31 });
32 $('#search2').on('change', () => {
33 const state = $("#search2").val();
34 if (state === "none") {
35 $(".status-active").parent().parent().attr("hidden", false);
36 $(".status-inactive").parent().parent().attr("hidden", false);
37 return;
38 }
39
40 $(".status-" + ((state === "active") ? 'inactive' : 'active')).parent().parent().attr("hidden", true);
41 $(".status-" + state).parent().parent().attr("hidden", false);
42
43 });
44});body {
45 font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
46 margin: 0;
47 padding: 0;
48 color: #333;
49 background-color: #fff;
50}
51
52.status-active {
53 height: 25px;
54 width: 25px;
55 background-color: #385C0B;
56 margin: 0 auto;
57}
58
59.status-inactive {
60 height: 25px;
61 width: 25px;
62 background-color: #CC000C;
63 margin: 0 auto;
64}<!DOCTYPE html>
65<html>
66
67<head>
68 <meta name="description" content="stackoverflow" />
69 <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
70
71 <link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
72 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
73 <script src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>
74 <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/select/1.3.3/js/dataTables.select.min.js"></script>
75 <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>
76 <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.3.3/css/select.dataTables.min.css">
77
78 <meta charset=utf-8 />
79 <title>DataTables - JS Bin</title>
80</head>
81
82<body>
83
84
85 <div class="container">
86 <div class="row">
87 <div class="form-inline">
88 <input id="search" title="Search" placeholder="Search" class="filter-input form-control form-control-sm m-2" type="text" name="filter-project" value="">
89 <select id="search2" name="expense_category" class="form-control form-control-sm m-2">
90 <option value="none">Select a Status</option>
91 <option value="active">Active</option>
92 <option value="inactive">Inactive</option>
93 </select>
94 </div>
95 <table id="example" class="display nowrap" width="100%">
96 <thead>
97 <tr>
98 <th class="text-center"><input type="checkbox" class="selectAll" name="selectAll" value="all"></th>
99 <th>Name</th>
100 <th>Status</th>
101 <th>Office</th>
102 <th>Age</th>
103 <th>Start date</th>
104 <th>Salary</th>
105 </tr>
106 </thead>
107
108 <tbody>
109 <tr>
110 <td></td>
111 <td>Tiger Nixon</td>
112 <td>
113 <div class="status-active" title="Active"></div>
114 </td>
115 <td>Edinburgh</td>
116 <td>61</td>
117 <td>2011/04/25</td>
118 <td>$3,120</td>
119 </tr>
120 <tr>
121 <td></td>
122 <td>Garrett Winters</td>
123 <td>
124 <div class="status-active" title="Active"></div>
125 </td>
126 <td>Edinburgh</td>
127 <td>63</td>
128 <td>2011/07/25</td>
129 <td>$5,300</td>
130 </tr>
131 <tr>
132 <td></td>
133 <td>Donna Snider</td>
134 <td>
135 <div class="status-inactive"></div>
136 </td>
137 <td>New York</td>
138 <td>27</td>
139 <td>2011/01/25</td>
140 <td>$3,120</td>
141 </tr>
142 </tbody>
143 </table>
144 </div>
145</body>
146
147</html>$('#search2').on('change', () =>
148{
149 const state = $("#search2").val();
150 if (state === "none") {
151 $(".status-active").parent().parent().attr("hidden", false);
152 $(".status-inactive").parent().parent().attr("hidden", false);
153 return;
154 }
155
156 $(".status-" + ((state === "active") ? 'inactive' : 'active')).parent().parent().attr("hidden", true);
157 $(".status-" + state).parent().parent().attr("hidden", false);
158
159});
160$(".status-active").parent().parent().attr("hidden", false);
161$(".status-" + ((state === "active") ? 'inactive' : 'active')).parent().parent().attr("hidden", true);
162$(".status-" + state).parent().parent().attr("hidden", false);
163
Examining the first line more closely, there is a ternary operator which checks to see if the state
is equal to active
, in which case if it is, it will output inactive
, or vise versa, the purpose of this is to select the opposite class attribute so we can hide it.
The second line simply fetches all rows with the state that was selected, and makes them visible.
QUESTION
Angular SSR with Universal and Ionic doesn't show actual data in page source
Asked 2021-Nov-07 at 19:31I have an Angular 11 project with nguniversal. My homepage is fetching data from services, internal (translation keys object) and external (an express node server to display a list of links). The backend domain is different from the frontend domain address.
The website is displayed correctly, but for some reason, the translations and list of links are not loaded initially when I inspect the page source. Also, the meta and title tags are not visible in the page source. Although they are working.
I believe this should be essential for Search Engine Optimization.
I am loading the language keys from an internal translation service, as observable into the app.component.ts. The translation service itself is dependent on a window service which waits for the browser to load, isPlatformBrowser. The window service is needed to simulate the window object on the server.
I also tried fetching the api data, before or after platform browser initializes, but with no success.
What else am I missing?
EDIT, part of the code. Not sure if I should include the whole project code here:
1"dependencies": {
2 "@angular/animations": "11.0.5",
3 "@angular/common": "~11.0.5",
4 "@angular/core": "~11.0.5",
5 "@angular/forms": "~11.0.5",
6 "@angular/platform-browser": "~11.0.5",
7 "@angular/platform-browser-dynamic": "~11.0.5",
8 "@angular/platform-server": "~11.0.5",
9 "@angular/router": "~11.0.5",
10 "@capacitor/core": "2.4.5",
11 "@ionic-native/core": "^5.0.0",
12 "@ionic-native/splash-screen": "^5.0.0",
13 "@ionic-native/status-bar": "^5.0.0",
14 "@ionic/angular": "^5.0.0",
15 "@nguniversal/express-engine": "11.0.1",
16 "@schematics/angular": "11.0.5",
17 "@types/memory-cache": "0.2.1",
18 "cors": "2.8.5",
19 "express": "^4.15.2",
20 "ion2-calendar": "3.5.0",
21 "leaflet": "1.7.1",
22 "memory-cache": "0.2.0",
23 "moment": "2.29.1",
24 "ng2-completer": "9.0.1",
25 "ng2-file-upload": "1.4.0",
26 "rxjs": "~6.5.5",
27 "socket.io-client": "4.1.2",
28 "tslib": "^2.0.0",
29 "url-search-params-polyfill": "8.1.0",
30 "zone.js": "~0.10.3"
31},
32"devDependencies": {
33 "@angular-devkit/build-angular": "~0.1100.5",
34 "@angular/cli": "~11.0.5",
35 "@angular/compiler": "~11.0.5",
36 "@angular/compiler-cli": "~11.0.5",
37 "@angular/language-service": "~11.0.5",
38 "@capacitor/cli": "2.4.5",
39 "@ionic/angular-server": "5.6.0-dev.202012021910.3a763f4",
40 "@ionic/angular-toolkit": "^2.3.0",
41 "@nguniversal/builders": "^11.0.1",
42 "@types/express": "^4.17.0",
43 "@types/jasmine": "~3.5.0",
44 "@types/jasminewd2": "~2.0.3",
45 "@types/node": "^12.11.1",
46 "codelyzer": "^6.0.0",
47 "jasmine-core": "~3.5.0",
48 "jasmine-spec-reporter": "~5.0.0",
49 "karma": "~5.1.1",
50 "karma-chrome-launcher": "~3.1.0",
51 "karma-coverage-istanbul-reporter": "~3.0.2",
52 "karma-jasmine": "~3.3.0",
53 "karma-jasmine-html-reporter": "^1.5.0",
54 "protractor": "~7.0.0",
55 "ts-node": "~8.3.0",
56 "tslint": "~6.1.0",
57 "typescript": "~4.0.5"
58
ANSWER
Answered 2021-Nov-07 at 19:31Actually I needed to implement a resolver for my component. So it waits for data to be fetched from a service.
This question actually helped with the implementation.
Some questions still remain, but it looks like a step in the right direction.
QUESTION
Why is blazor HeadOutlet rendering after the App
Asked 2021-Nov-01 at 19:31I'm using a HeadOutlet on a server side pre-rendered net6.0 app to set some header tags such as meta description but the server renders the app first and then the headers which makes search engines ignore it.
1@page "/"
2@namespace Example.Pages
3@using Microsoft.AspNetCore.Components.Web
4@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
5
6@{
7 Layout = null;
8}
9
10<!DOCTYPE html>
11<html lang="en">
12<head>
13 <component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
14 <base href="~/" />
15
16 <link href="css/site.css" rel="stylesheet" />
17 <link rel="preconnect" href="https://fonts.gstatic.com">
18</head>
19<body>
20 <component type="typeof(App)" render-mode="ServerPrerendered" />
21
22 <div id="blazor-error-ui">
23 <environment include="Staging,Production">
24 An error has occurred. This application may no longer respond until reloaded.
25 </environment>
26 <environment include="Development">
27 An unhandled exception has occurred. See browser dev tools for details.
28 </environment>
29 <a href="/" class="reload">Reload</a>
30 <a href="#" class="dismiss">π</a>
31 </div>
32
33 <script src="_framework/blazor.server.js"></script>
34 <script src="~/outsideHandleContainerJsInterop.js"></script>
35</body>
36</html>
37
1@page "/"
2@namespace Example.Pages
3@using Microsoft.AspNetCore.Components.Web
4@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
5
6@{
7 Layout = null;
8}
9
10<!DOCTYPE html>
11<html lang="en">
12<head>
13 <component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
14 <base href="~/" />
15
16 <link href="css/site.css" rel="stylesheet" />
17 <link rel="preconnect" href="https://fonts.gstatic.com">
18</head>
19<body>
20 <component type="typeof(App)" render-mode="ServerPrerendered" />
21
22 <div id="blazor-error-ui">
23 <environment include="Staging,Production">
24 An error has occurred. This application may no longer respond until reloaded.
25 </environment>
26 <environment include="Development">
27 An unhandled exception has occurred. See browser dev tools for details.
28 </environment>
29 <a href="/" class="reload">Reload</a>
30 <a href="#" class="dismiss">π</a>
31 </div>
32
33 <script src="_framework/blazor.server.js"></script>
34 <script src="~/outsideHandleContainerJsInterop.js"></script>
35</body>
36</html>
37@page "/test"
38
39<HeadContent>
40 <meta name="description" content="Hello World">
41</HeadContent>
42
Viewing the page in a browser will render the meta tags in the head as expected but doing a get request in insomnia/postman returns the initial headers and a blazor pre-render tag comment
1@page "/"
2@namespace Example.Pages
3@using Microsoft.AspNetCore.Components.Web
4@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
5
6@{
7 Layout = null;
8}
9
10<!DOCTYPE html>
11<html lang="en">
12<head>
13 <component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
14 <base href="~/" />
15
16 <link href="css/site.css" rel="stylesheet" />
17 <link rel="preconnect" href="https://fonts.gstatic.com">
18</head>
19<body>
20 <component type="typeof(App)" render-mode="ServerPrerendered" />
21
22 <div id="blazor-error-ui">
23 <environment include="Staging,Production">
24 An error has occurred. This application may no longer respond until reloaded.
25 </environment>
26 <environment include="Development">
27 An unhandled exception has occurred. See browser dev tools for details.
28 </environment>
29 <a href="/" class="reload">Reload</a>
30 <a href="#" class="dismiss">π</a>
31 </div>
32
33 <script src="_framework/blazor.server.js"></script>
34 <script src="~/outsideHandleContainerJsInterop.js"></script>
35</body>
36</html>
37@page "/test"
38
39<HeadContent>
40 <meta name="description" content="Hello World">
41</HeadContent>
42<!--Blazor:{"sequence":0,"type":"server","prerenderId":"b0376004567c4aaf9c07defc4341e21e","descriptor":"<long string here>"}--><!--Blazor:{"prerenderId":"b0376004567c4aaf9c07defc4341e21e"}-->
43
Is this a bug or am I missing something? I need the head to be rendered before or with the rest of the page so search engines can pick it up.
ANSWER
Answered 2021-Nov-01 at 19:31This was solved by moving the html/head/body from _Host.cshtml to _Layout.html. More info described in this post: https://github.com/dotnet/aspnetcore/issues/37293
Community Discussions contain sources that include Stack Exchange Network
Tutorials and Learning Resources in Search Engine
Tutorials and Learning Resources are not available at this moment for Search Engine