Repository: internetarchive/openlibrary

Issue:
Add openstax to Trusted Book Providers
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

Subtask of #5792 

### Describe the problem that you'd like solved
<!-- A clear and concise description of what you want to happen. -->

### Proposal & Constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->

<!-- Which suggestions or requirements should be considered for how feature needs to appear or be implemented? -->

### Additional context
<!-- Add any other context or screenshots about the feature request here. -->

### Stakeholders
<!-- @ tag stakeholders of this bug -->





Discussion:

Resolving patch:
diff --git a/openlibrary/book_providers.py b/openlibrary/book_providers.py
--- a/openlibrary/book_providers.py
+++ b/openlibrary/book_providers.py
@@ -144,12 +144,21 @@ def is_own_ocaid(self, ocaid: str) -> bool:
         return False
 
 
+class OpenStaxProvider(AbstractBookProvider):
+    short_name = 'openstax'
+    identifier_key = 'openstax'
+
+    def is_own_ocaid(self, ocaid: str) -> bool:
+        return False
+
+
 PROVIDER_ORDER: list[AbstractBookProvider] = [
     # These providers act essentially as their own publishers, so link to the first when
     # we're on an edition page
     LibriVoxProvider(),
     ProjectGutenbergProvider(),
     StandardEbooksProvider(),
+    OpenStaxProvider(),
     # Then link to IA
     InternetArchiveProvider(),
 ]
diff --git a/openlibrary/plugins/worksearch/code.py b/openlibrary/plugins/worksearch/code.py
--- a/openlibrary/plugins/worksearch/code.py
+++ b/openlibrary/plugins/worksearch/code.py
@@ -154,6 +154,7 @@
     'id_project_gutenberg',
     'id_librivox',
     'id_standard_ebooks',
+    'id_openstax',
 }
 OLID_URLS = {'A': 'authors', 'M': 'books', 'W': 'works'}
 
@@ -594,6 +595,7 @@ def get_doc(doc):  # called from work_search template
     e_id_project_gutenberg = doc.find("arr[@name='id_project_gutenberg']") or []
     e_id_librivox = doc.find("arr[@name='id_librivox']") or []
     e_id_standard_ebooks = doc.find("arr[@name='id_standard_ebooks']") or []
+    e_id_openstax = doc.find("arr[@name='id_openstax']") or []
 
     first_pub = None
     e_first_pub = doc.find("int[@name='first_publish_year']")
@@ -662,6 +664,7 @@ def get_doc(doc):  # called from work_search template
         id_project_gutenberg=[e.text for e in e_id_project_gutenberg],
         id_librivox=[e.text for e in e_id_librivox],
         id_standard_ebooks=[e.text for e in e_id_standard_ebooks],
+        id_openstax=[e.text for e in e_id_openstax],
     )
 
     doc.url = doc.key + '/' + urlsafe(doc.title)
@@ -694,6 +697,7 @@ def work_object(w):  # called by works_by_author
         id_project_gutenberg=w.get('id_project_gutenberg'),
         id_librivox=w.get('id_librivox'),
         id_standard_ebooks=w.get('id_standard_ebooks'),
+        id_openstax=w.get('id_openstax'),
     )
 
     for f in 'has_fulltext', 'subtitle':
@@ -847,6 +851,7 @@ def works_by_author(
                     'id_project_gutenberg',
                     'id_librivox',
                     'id_standard_ebooks',
+                    'id_openstax',
                     'cover_i',
                 ]
             ),


Test patch: